Ludovic Dubost a écrit :
> Hi Antoine,
>
> To access properties you should do something like:
>
> Object obj = (Object) doc.getObjects("XWiki.AnnotationClass").get(0);
> doc.use(obj);
> doc.display("comment");
> doc.getValue("comment");
> doc.displat("comment","edit");
>
> etc...
>
> Ludovic
>
>   
Hi,
That's a solution i had tested, to use velocity to access properties.
But i had like to create my own method in java code.
Indeed, i want to list all the annotation written by an user (or 
something like that) and so i'd like to implement a method 
getUserAnnotation(username) in java code and then call this method in 
velocity script.

Thank for your help.

> antoine SEILLES wrote:
>   
>> I have an AnnotationPluginApi.java class and i have a method to get all 
>> the annotations associated to a document:
>> public Vector getAnnotations(Document doc){
>> return doc.getObjects("AnnotationClass");
>>   }
>>
>> Now i'd like to have a method to get all the annotations associated to a 
>> document having a specific value specified in parameters for one field :
>> public Vector getAnnotations(Document doc, String field, String value)
>> Wich should return all the annotations having the value "value" for the 
>> field "field".
>>
>> How to do that?
>> In fact, how to access fields of my objects "AnnotationClass"?
>>
>> Thank for your time.
>>
>> Ps: in AnnotationPlugin i have this method:
>>
>> public BaseClass getAnnotationClass(XWikiContext context) throws 
>> XWikiException {
>>       XWikiDocument doc;
>>       XWiki xwiki = context.getWiki();
>>       boolean needsUpdate = false;
>>
>>       try {
>>           doc = xwiki.getDocument("XWiki.AnnotationClass", context);
>>       } catch (Exception e) {
>>           doc = new XWikiDocument();
>>           doc.setSpace("XWiki");
>>           doc.setName("AnnotationClass");
>>           needsUpdate = true;
>>       }
>>
>>       BaseClass bclass = doc.getxWikiClass();
>>       bclass.setName("XWiki.AnnotationClass");
>>       needsUpdate |= bclass.addTextField("author", "Author", 30);
>>       needsUpdate |= bclass.addDateField("created", "Created", 
>> "dd/MM/yyyy");
>>       needsUpdate |= bclass.addTextAreaField("comment", "Comment", 40, 5);
>>       needsUpdate |= bclass.addTextAreaField("selection", "Selection", 
>> 40, 5);
>>       needsUpdate |= bclass.addTextAreaField("reformulation", 
>> "Reformulation", 40, 5);
>>       needsUpdate |= bclass.addNumberField("begin", "Begin", 100, 
>> "integer");
>>       needsUpdate |= bclass.addNumberField("end", "End", 100, "integer");
>>       needsUpdate |= bclass.addTextField("emotion", "Emotion", 30);
>>       needsUpdate |= bclass.addTextField("judgmentUniversel", 
>> "JudgmentUniversel", 30);
>>       needsUpdate |= bclass.addTextField("judgmentParticulier", 
>> "JudgmentParticulier", 30);
>>       needsUpdate |= bclass.addTextField("domain", "Domain", 30);
>>
>>       String content = doc.getContent();
>>       if ((content == null) || (content.equals(""))) {
>>           needsUpdate = true;
>>           doc.setContent("1 AnnotationClass");
>>       }
>>
>>       if (needsUpdate)
>>           xwiki.saveDocument(doc, context);
>>       return bclass;
>>   }
>> _______________________________________________
>> devs mailing list
>> [email protected]
>> http://lists.xwiki.org/mailman/listinfo/devs
>>
>>   
>>     
>
>
>   

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to