--- En date de : Lun 9.2.15, Clemens Klein-Robbenhaar <[email protected]> a écrit :
De: Clemens Klein-Robbenhaar <[email protected]> Objet: Re: [xwiki-users] Need doc about access object in a page (and use doc) À: [email protected] Date: Lundi 9 février 2015, 13h29 On 02/09/2015 10:15 AM, Pascal BASTIEN wrote:
Hello, I read/apply this doc with succcess: http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsina...
With this code I can display all objects ATTACHED to THIS page. ***********
#set($class = $obj.xWikiClass) ## access the class object representing SomeSpace.SomeClass
#foreach($prop in $class.properties) ## go through all properties
...
***********
but if I attached some class to another page, how can I list properties?
the $xwiki object has a method to access the class if you know the name
#set( $someClass = $xwiki.getClass("SomeSpace.SomeClass"))
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/XWiki...
This code (probably false) doesn't work. #set( $Class = $xwiki.getClass("MySpace.MyClass")) #foreach($prop in $class.properties) ## go through all properties * ${prop.prettyName} : $doc.display($prop.getName()) #end
Another question: I have a page with 3 same Class, how to list them (like ?editor=class did)?
you can get a list of of objects of a certain class via $doc.getObjects("SomeSpace.SomeClass")
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum...
$doc.getObjects("SomeSpace.SomeClass") I failed to :-( The thing I don't understand is, my values are stored in a doc with attached class. I need theses value from another doc but all method have Class name parameter ... Class name contain only field (properties) name? (Hope I will understand how find answer in javadoc to avoid disturbed nice people of user list) Thxs
An example:
MySpaceMyClass contain this Class properties:
- My Field ID (IdField: String) - My Lib Field (LibField: String) I create MySpace.MyNiceDoc and add my previous Class MySpace/MyNiceDoc?editor=object and contain: Objets de type MySpace.MyClass (2) * MyClass 0 - My Field ID - My Lib Field
*MyClass 1:
- My Field ID - My Lib Field
With it I like to fill a select list from this doc (but from another doc to). How can I proceed? because on MySpace.MyNiceDoc I can only display one/First Lib values with this code: {{velocity}} ## Retrieve the first object (index [0]) among all objects attached to this page and of a certain class #set($obj = $doc.getObject('MySpace.MyClass')) #set($class = $obj.xWikiClass) ## access the class object representing SomeSpace.SomeClass #foreach($prop in $class.properties) ## go through all properties * ${prop.prettyName} : $doc.display($prop.getName()) #end {{/velocity}} I guess i need a loop but which one?
And the big question (who I think it will interest everyone), how can I use documentation ( http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?xpage=embed and or http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/org... ) to guess xWikiClass (or my loop) by example?
A doc/example to use documentation will be welcome. :-)
thxs for any help.
Pascal B
_______________________________________________
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
mit freundlichen Grüßen Clemens Klein-Robbenhaar
-- Clemens Klein-Robbenhaar Software Development EsPresto AG Breite Str. 30-31 10178 Berlin/Germany Tel: +49.(0)30.90 226.763 Fax: +49.(0)30.90 226.760 [email protected]
HRB 77554 B - Berlin-Charlottenburg Vorstand: Maya Biersack, Peter Biersack Vorsitzender des Aufsichtsrats: Dipl.-Wirtsch.-Ing. Winfried Weber Zertifiziert nach ISO 9001:2008 _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users