[xwiki-users] Custom class field as field on a different class
Is it possible to create a simple custom class that can then be used within another custom class as a property? For example: Class A Category TAC Rule Class B Question Answer Category (populated from all Categories) Thanks! .:. Kevin -- View this message in context: http://n2.nabble.com/Custom-class-field-as-field-on-a-different-class-tp2152... Sent from the XWiki- Users mailing list archive at Nabble.com.
OK, I found an example of this but it's not really clear how the pieces fit together. ArticleClass has a property called Category which is basically what I am looking to do. This is the HQL query for that property: select prop.value from BaseObject as obj, StringProperty as prop where obj.className='Blog.Categories' and obj.name = 'Blog.Categories' and prop.id.id = obj.id and prop.id.name='name' The problem is I don't see a class called Blog.Categories. There is a class called Categories, how does Blog.Categories relate? Also, what is StringProperty (I see Property in the API docs)? The references to prop.id.id and prop.id.name don't really make much sense either but maybe once I know where StringProperty comes from they will. Thanks! .:. Kevin -- View this message in context: http://n2.nabble.com/Custom-class-field-as-field-on-a-different-class-tp2152... Sent from the XWiki- Users mailing list archive at Nabble.com.
On Tue, Jan 13, 2009 at 8:22 PM, Kevin_C <[email protected]> wrote:
OK, I found an example of this but it's not really clear how the pieces fit together.
ArticleClass has a property called Category which is basically what I am looking to do. This is the HQL query for that property:
select prop.value from BaseObject as obj, StringProperty as prop where obj.className='Blog.Categories' and obj.name = 'Blog.Categories' and prop.id.id = obj.id and prop.id.name='name'
The problem is I don't see a class called Blog.Categories. There is a class
The class name is the full name of the document where it is stored, so here it's located in Blog/Categories and will be called Blog.Categories where you are using it. The class name always contains a Space.Something since you can't have a document without storing it in a space.
called Categories, how does Blog.Categories relate? Also, what is StringProperty (I see Property in the API docs)? The references to prop.id.id and prop.id.name don't really make much sense either but maybe once I know where StringProperty comes from they will.
Thanks! .:. Kevin -- View this message in context: http://n2.nabble.com/Custom-class-field-as-field-on-a-different-class-tp2152... Sent from the XWiki- Users mailing list archive at Nabble.com.
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
Interesting... I just noticed that the Blog.Categories page just has a series of Category Objects added to it. Is there something special I need to do in order to use a link like the one used in the Categories app in order to add my object to a *holder* page? This is the link used for adding new categories: http://localhost:9090/xwiki/bin/objectadd/Blog/Categories?classname=Blog.Cat... I'm going to try and create something like this for my purpose.. Thanks for the info! .:. Kevin -- View this message in context: http://n2.nabble.com/Custom-class-field-as-field-on-a-different-class-tp2152... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi I'm trying to execute another script on "Save" event. I've created a notification class (based on xwiki example http://dev.xwiki.org/xwiki/bin/view/Drafts/GroovyNotifications) and pointed to it in "Administration > Programming > Notification pages". This script gets called every time which is fine and when I try to display name of a document that is being saved (doc.fullName) all works well. document name it works fine but when I try to display one of the fieldnames doc.display('Summary') I get groovy.lang.MissingMethodException: No signature of method com.xpn.xwiki.doc.XWikiDocument.display() is applicable for argument types: (java.lang.String) values: {"Summary"} I tried def tmpDoc = context.getWiki().getDocument(doc.fullName, context); But again fullName is OK but display('Summary') isn't Am I missing something in my syntax? How do I make document values available in my Notification class? Ajdin B. Coventry University -------------------------------------------------------- NOTICE This message and any files transmitted with it is intended for the addressee only and may contain information that is confidential or privileged. Unauthorised use is strictly prohibited. If you are not the addressee, you should not read, copy, disclose or otherwise use this message, except for the purpose of delivery to the addressee. Any views or opinions expressed within this e-mail are those of the author and do not necessarily represent those of Coventry University.
Is Summary a property you've added to a custom class that this document is an instance of? By default an XWiki document doesn't have a summary property which I believe is why you are getting that error. Hope this helps! .:. Kevin -- View this message in context: http://n2.nabble.com/Custom-class-field-as-field-on-a-different-class-tp2152... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi Kevin Yes, you are correct. So how do I get the correct instance? Ajdin -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Kevin_C Sent: 14 January 2009 15:12 To: [email protected] Subject: Re: [xwiki-users] groovy.lang.MissingMethodException Is Summary a property you've added to a custom class that this document is an instance of? By default an XWiki document doesn't have a summary property which I believe is why you are getting that error. Hope this helps! .:. Kevin -- View this message in context: http://n2.nabble.com/Custom-class-field-as-field-on-a-different-class-tp 2152709p2157296.html Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users -------------------------------------------------------- NOTICE This message and any files transmitted with it is intended for the addressee only and may contain information that is confidential or privileged. Unauthorised use is strictly prohibited. If you are not the addressee, you should not read, copy, disclose or otherwise use this message, except for the purpose of delivery to the addressee. Any views or opinions expressed within this e-mail are those of the author and do not necessarily represent those of Coventry University.
Ajdin Brandic wrote:
Hi
I'm trying to execute another script on "Save" event. I've created a notification class (based on xwiki example http://dev.xwiki.org/xwiki/bin/view/Drafts/GroovyNotifications) and pointed to it in "Administration > Programming > Notification pages".
This script gets called every time which is fine and when I try to display name of a document that is being saved (doc.fullName) all works well. document name it works fine but when I try to display one of the fieldnames doc.display('Summary') I get
groovy.lang.MissingMethodException: No signature of method com.xpn.xwiki.doc.XWikiDocument.display() is applicable for argument types: (java.lang.String) values: {"Summary"}
I tried def tmpDoc = context.getWiki().getDocument(doc.fullName, context); But again fullName is OK but display('Summary') isn't
Am I missing something in my syntax? How do I make document values available in my Notification class?
As you see, that is not an api object, but an internal class (com.xpn.xwiki.doc.XWikiDocument vs. com.xpn.xwiki.api.Document). This means that API methods don't work, unless they have an equivalent in the other class. You can either look at the methods of the XWikiDocument class, or get an API object and work with it (new com.xpn.xwiki.apiDocument(tmpDoc) -- Sergiu Dumitriu http://purl.org/net/sergiu/
As written previously I'm trying to trigger some code on document save. Sergiu explained issue I had with (com.xpn.xwiki.doc.XWikiDocument vs. com.xpn.xwiki.api.Document). I got most the stuff to work except (last two lines of code) I am not able to save image from url as attachment. I get Wrapped Exception: No signature of method com.xpn.xwiki.doc.XWikiDocument.addAttachment() is applicable for argument types: (java.lang.String, [B, com.xpn.xwiki.XWikiContext) values: {"notif1.png", [-119,.., ["vcontext":...]} Looking at the documentation at http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn /xwiki/doc/XWikiDocument.html Says " XWikiAttachment | addAttachment(java.lang.String fileName, byte[] data, XWikiContext context) " Have I got type issue here or??? This is what I'm doing def doc = xwiki.getDocument(docName, context); //use this for com.xpn.xwiki.XWiki def tmpElList = el.split("[\"]") def umlImage = tmpElList[1] def imgAsBites = xwiki.getURLContentAsBytes("http://www.websequencediagrams.com/index.php "+umlImage, context); def newAttachment = doc.addAttachment(filenameToSavaAs,imgAsBites, context); //use this for com.xpn.xwiki.XWiki saveAttachmentContent(newAttachment,context); Has anyone had a similar problem? Ajdin -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Sergiu Dumitriu Sent: 14 January 2009 17:03 To: XWiki Users Subject: Re: [xwiki-users] groovy.lang.MissingMethodException Ajdin Brandic wrote:
Hi
I'm trying to execute another script on "Save" event. I've created a notification class (based on xwiki example http://dev.xwiki.org/xwiki/bin/view/Drafts/GroovyNotifications) and pointed to it in "Administration > Programming > Notification pages".
This script gets called every time which is fine and when I try to display name of a document that is being saved (doc.fullName) all works well. document name it works fine but when I try to display one of the fieldnames doc.display('Summary') I get
groovy.lang.MissingMethodException: No signature of method com.xpn.xwiki.doc.XWikiDocument.display() is applicable for argument types: (java.lang.String) values: {"Summary"}
I tried def tmpDoc = context.getWiki().getDocument(doc.fullName, context); But again fullName is OK but display('Summary') isn't
Am I missing something in my syntax? How do I make document values available in my Notification class?
As you see, that is not an api object, but an internal class (com.xpn.xwiki.doc.XWikiDocument vs. com.xpn.xwiki.api.Document). This means that API methods don't work, unless they have an equivalent in the other class. You can either look at the methods of the XWikiDocument class, or get an API object and work with it (new com.xpn.xwiki.apiDocument(tmpDoc) -- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users -------------------------------------------------------- NOTICE This message and any files transmitted with it is intended for the addressee only and may contain information that is confidential or privileged. Unauthorised use is strictly prohibited. If you are not the addressee, you should not read, copy, disclose or otherwise use this message, except for the purpose of delivery to the addressee. Any views or opinions expressed within this e-mail are those of the author and do not necessarily represent those of Coventry University.
participants (4)
-
Ajdin Brandic -
Kevin_C -
Sergiu Dumitriu -
Thomas Mortagne