Hi Matthias,
the problem is that if loaded via HQL the objects do not come with all their properties
loaded; but you can load them by extending the HQL query:
{{groovy}}
hql ="select obj, prop from BaseObject as obj, StringProperty as prop where
obj.className='MySpace.MyClass' and obj.id=prop.id.id and
prop.name='MyProperty'"
results = services.query.hql(hql).execute()
println "|= Title |= Value"
results.each { item ->
println "|[[${item[0].name}>>${item[0].name}]]| ${item[1].getValue()}"
}
{{/groovy}}
(This is assuming that 'MyProperty' is actually a StringProperty, and not e.g. a
DateProperty)
There is more about it on the Query Module page:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Query+Module
Hope this helps,
Clemens
BTW, for me the "magic query completion" that e.g. make the HQL-query containing
the empty string list all documents in the current wiki does no longer work, while it is
given as example in the documentation. A "where 1=1" works flawlessly however.
Is this just me?
On 01/29/2014 10:42 PM, Matthias Albert wrote:
hi Marius,
thanks for your answer.
My problem seems to be different: I would like to show property values
of objects not contained in the current document.
At last, I tried this
{{groovy}}
hql = "select obj from BaseObject obj where
obj.className='MySpace.MyClass'"
results = xwiki.search(hql, 0, 0)
xclass = results[0].getxWikiClass(xcontext.context)
println "|=Title |= Value
results.each { item ->
println "|[[$item.name>>$item.name]] |${item.get('MyProperty')} |
}
{{/groovy}}
(I hope, I didn't copy it wrong)
Mostly you did, but something has eaten the closing quotes of the println statements.
Pretty easy to find this out, however ;)
This should print a table iterating over all objects
of MyClass, with
the first column showing the object title, which works fine. The second
column should show some property value. But no combination of method
invocations of BaseCollection, BaseObject, PropertyInterface etc. worked.
Thanks
Matthias
Am 29.01.2014 08:25, schrieb Marius Dumitru Florea:
See
http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsin…
. You should also check the sheet generated by AWM for your class
structure. See
http://extensions.xwiki.org/xwiki/bin/view/Extension/App+Within+Minutes+App…
.
Hope this helps,
Marius
On Tue, Jan 28, 2014 at 6:39 PM, Matthias Albert <matthias.albert(a)gmx.de> wrote:
Hi all,
after I managed to create a class structure using AppWithinMinutes, I
could create objects of this class in the Application's start page.
Now I am trying to create a different xwiki page, that should show a
filtered table view of the objects created using velocity statements.
I could create a #foreach loop iterating over the objects and show each
object's name.
My problem is: how can I show some of the property values? The class
properties have names like:
Beschreibung (shortText1: String)
Can anyone give a hint?
Thank you in advance
Matthias
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
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
robbenhaar(a)espresto.com
HRB 77554 B - Berlin-Charlottenburg
Vorstand: Maya Biersack, Peter Biersack
Vorsitzender des Aufsichtsrats: Dipl.-Wirtsch.-Ing. Winfried Weber
Zertifiziert nach ISO 9001:2008