[xwiki-users] [Velocity] get items of static list
Hi, I am currently implementing my first XWiki application and starting to learn velocity. There is one thing that makes me mad. There is a static list field with code "ddlProductFamily". I try to display the items in this list in a nice way (one below the other). Different approaches including googling didn't lead to any outcome. #foreach ($prodFam in $ddlProductFamily) $prodFam\\ #end #foreach ($prodFam in $doc.display('ddlProductFamily')) $prodFam\\ #end On the frontend it's always empty. Other #foreach loops work fine. I'm sure I just misunderstand something but I can't find the fault myself. Can somebody please help me? Thanks in advance, Dennis
On Thu, Jun 23, 2016 at 5:32 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
I am currently implementing my first XWiki application and starting to learn velocity. There is one thing that makes me mad.
There is a static list field with code "ddlProductFamily".
I try to display the items in this list in a nice way (one below the other).
It's not very clear what you want to display: (1) the value of the ddlProductFamily field? i.e. the selected values? Does this field have multiple selection enabled? (2) the list of values the ddlProductFamily field can chose from? i.e. the allowed values, what is specified in the static list definition In any case you should check http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsina... . And before you try to iterate something you should first display/print it to see if it's really something that can be iterated (a list or an array). Hope this helps, Marius
Different approaches including googling didn't lead to any outcome.
#foreach ($prodFam in $ddlProductFamily) $prodFam\\ #end
#foreach ($prodFam in $doc.display('ddlProductFamily')) $prodFam\\ #end
On the frontend it's always empty. Other #foreach loops work fine.
I'm sure I just misunderstand something but I can't find the fault myself. Can somebody please help me?
Thanks in advance, Dennis _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Hi, Yes, I want to display the values of the field ddlProductFamily. It is a multi-select list field. In the application I added a new item where I selected "Value1" and "Value3" of the list field. It displays fine using $doc.display('ddlProductFamily') but I want to print the selected values below each other so I used the #foreach loop but it's always empty. I have another #foreach loop where I display attachments which works fine so I wonder what's special about the list field items. Regards, Dennis 2016-06-24 8:59 GMT+02:00 Marius Dumitru Florea < mariusdumitru.florea@xwiki.com>:
On Thu, Jun 23, 2016 at 5:32 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
I am currently implementing my first XWiki application and starting to learn velocity. There is one thing that makes me mad.
There is a static list field with code "ddlProductFamily".
I try to display the items in this list in a nice way (one below the other).
It's not very clear what you want to display: (1) the value of the ddlProductFamily field? i.e. the selected values? Does this field have multiple selection enabled? (2) the list of values the ddlProductFamily field can chose from? i.e. the allowed values, what is specified in the static list definition
In any case you should check
http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsina... . And before you try to iterate something you should first display/print it to see if it's really something that can be iterated (a list or an array).
Hope this helps, Marius
Different approaches including googling didn't lead to any outcome.
#foreach ($prodFam in $ddlProductFamily) $prodFam\\ #end
#foreach ($prodFam in $doc.display('ddlProductFamily')) $prodFam\\ #end
On the frontend it's always empty. Other #foreach loops work fine.
I'm sure I just misunderstand something but I can't find the fault
myself.
Can somebody please help me?
Thanks in advance, Dennis _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Have you checked the link I gave you? It has an example that shows how to "Retrieve the raw value of the property". On Tue, Jun 28, 2016 at 4:43 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
Yes, I want to display the values of the field ddlProductFamily. It is a multi-select list field. In the application I added a new item where I selected "Value1" and "Value3" of the list field. It displays fine using $doc.display('ddlProductFamily') but I want to print the selected values below each other so I used the #foreach loop but it's always empty. I have another #foreach loop where I display attachments which works fine so I wonder what's special about the list field items.
Regards, Dennis
2016-06-24 8:59 GMT+02:00 Marius Dumitru Florea < mariusdumitru.florea@xwiki.com>:
On Thu, Jun 23, 2016 at 5:32 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
I am currently implementing my first XWiki application and starting to learn velocity. There is one thing that makes me mad.
There is a static list field with code "ddlProductFamily".
I try to display the items in this list in a nice way (one below the other).
It's not very clear what you want to display: (1) the value of the ddlProductFamily field? i.e. the selected values? Does this field have multiple selection enabled? (2) the list of values the ddlProductFamily field can chose from? i.e. the allowed values, what is specified in the static list definition
In any case you should check
http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsina...
. And before you try to iterate something you should first display/print it to see if it's really something that can be iterated (a list or an array).
Hope this helps, Marius
Different approaches including googling didn't lead to any outcome.
#foreach ($prodFam in $ddlProductFamily) $prodFam\\ #end
#foreach ($prodFam in $doc.display('ddlProductFamily')) $prodFam\\ #end
On the frontend it's always empty. Other #foreach loops work fine.
I'm sure I just misunderstand something but I can't find the fault
myself.
Can somebody please help me?
Thanks in advance, Dennis _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Hi, many thanks. So now I have #set($obj = $doc.getObject('Customer Profile.Code.Customer ProfileClass')) #set($rawValue = $obj.getProperty('sListSupportLevel').value) #foreach( $level in $rawValue ) $level <br /> #end and it displays the raw values. I feel dumb asking this but I was not able to get it working: How to get the pretty names of the raw values in the foreach loop? Thanks again, Dennis 2016-07-13 11:04 GMT+02:00 Marius Dumitru Florea < mariusdumitru.florea@xwiki.com>:
Have you checked the link I gave you? It has an example that shows how to "Retrieve the raw value of the property".
On Tue, Jun 28, 2016 at 4:43 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
Yes, I want to display the values of the field ddlProductFamily. It is a multi-select list field. In the application I added a new item where I selected "Value1" and "Value3" of the list field. It displays fine using $doc.display('ddlProductFamily') but I want to print the selected values below each other so I used the #foreach loop but it's always empty. I have another #foreach loop where I display attachments which works fine so I wonder what's special about the list field items.
Regards, Dennis
2016-06-24 8:59 GMT+02:00 Marius Dumitru Florea < mariusdumitru.florea@xwiki.com>:
On Thu, Jun 23, 2016 at 5:32 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
I am currently implementing my first XWiki application and starting to learn velocity. There is one thing that makes me mad.
There is a static list field with code "ddlProductFamily".
I try to display the items in this list in a nice way (one below the other).
It's not very clear what you want to display: (1) the value of the ddlProductFamily field? i.e. the selected values? Does this field have multiple selection enabled? (2) the list of values the ddlProductFamily field can chose from? i.e. the allowed values, what is specified in the static list definition
In any case you should check
http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsina...
. And before you try to iterate something you should first display/print it to see if it's really something that can be iterated (a list or an array).
Hope this helps, Marius
Different approaches including googling didn't lead to any outcome.
#foreach ($prodFam in $ddlProductFamily) $prodFam\\ #end
#foreach ($prodFam in $doc.display('ddlProductFamily')) $prodFam\\ #end
On the frontend it's always empty. Other #foreach loops work fine.
I'm sure I just misunderstand something but I can't find the fault
myself.
Can somebody please help me?
Thanks in advance, Dennis _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
On Tue, Jul 26, 2016 at 5:36 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
many thanks. So now I have
#set($obj = $doc.getObject('Customer Profile.Code.Customer ProfileClass')) #set($rawValue = $obj.getProperty('sListSupportLevel').value) #foreach( $level in $rawValue ) $level <br /> #end
and it displays the raw values. I feel dumb asking this but I was not able to get it working: How to get the pretty names of the raw values in the foreach loop?
On the same link I gave you there is an example for how to "access the class object representing SomeSpace.SomeClass" and to access a property from the class. Then you can use http://platform.xwiki.org/xwiki/bin/view/ScriptingDocumentation/?url=http:%2...) to get the mapping between the raw values and the display pretty value. Hope this helps, Marius
Thanks again, Dennis
2016-07-13 11:04 GMT+02:00 Marius Dumitru Florea < mariusdumitru.florea@xwiki.com>:
Have you checked the link I gave you? It has an example that shows how to "Retrieve the raw value of the property".
On Tue, Jun 28, 2016 at 4:43 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
Yes, I want to display the values of the field ddlProductFamily. It is a multi-select list field. In the application I added a new item where I selected "Value1" and "Value3" of the list field. It displays fine using $doc.display('ddlProductFamily') but I want to print the selected values below each other so I used the #foreach loop but it's always empty. I have another #foreach loop where I display attachments which works fine so I wonder what's special about the list field items.
Regards, Dennis
2016-06-24 8:59 GMT+02:00 Marius Dumitru Florea < mariusdumitru.florea@xwiki.com>:
On Thu, Jun 23, 2016 at 5:32 PM, D R <rir.ceg@gmail.com> wrote:
Hi,
I am currently implementing my first XWiki application and starting to learn velocity. There is one thing that makes me mad.
There is a static list field with code "ddlProductFamily".
I try to display the items in this list in a nice way (one below the other).
It's not very clear what you want to display: (1) the value of the ddlProductFamily field? i.e. the selected values? Does this field have multiple selection enabled? (2) the list of values the ddlProductFamily field can chose from? i.e. the allowed values, what is specified in the static list definition
In any case you should check
http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsina...
. And before you try to iterate something you should first display/print it to see if it's really something that can be iterated (a list or an array).
Hope this helps, Marius
Different approaches including googling didn't lead to any outcome.
#foreach ($prodFam in $ddlProductFamily) $prodFam\\ #end
#foreach ($prodFam in $doc.display('ddlProductFamily')) $prodFam\\ #end
On the frontend it's always empty. Other #foreach loops work fine.
I'm sure I just misunderstand something but I can't find the fault
myself.
Can somebody please help me?
Thanks in advance, Dennis _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Thanks, Marius Well, looks like it is not supposed to be easy to display the items of a select field. After playing around for some time I have: #set($obj = $doc.getObject('Customer Profile.Code.Customer ProfileClass')) #set($rawValue = $obj.getProperty('sListSupportLevel').value) #set($class = $obj.xWikiClass) $class.get('sListSupportLevel').MapValues This displays the map like {Code1=[Code1, PrettyName1, ], Code2=[Code2, PrettyName2, ]...} Now I feel lost again because I don't know how to get the "PrettyNames" matching the selected items out of the map. Boy I didn't imagine that it would be so complicated to display the selected items one beneath the other. Hope you guys could help me get this working and sorry for the hassle. Regards, Dennis
On Wed, Jul 27, 2016 at 3:43 PM, D R <rir.ceg@gmail.com> wrote:
Thanks, Marius
Well, looks like it is not supposed to be easy to display the items of a select field.
After playing around for some time I have: #set($obj = $doc.getObject('Customer Profile.Code.Customer ProfileClass')) #set($rawValue = $obj.getProperty('sListSupportLevel').value) #set($class = $obj.xWikiClass)
$class.get('sListSupportLevel').MapValues
Try this: #set ($mapValues = $class.get('sListSupportLevel').mapValues) $mapValues.get($rawValue).value Hope this helps, Marius
This displays the map like {Code1=[Code1, PrettyName1, ], Code2=[Code2, PrettyName2, ]...}
Now I feel lost again because I don't know how to get the "PrettyNames" matching the selected items out of the map.
Boy I didn't imagine that it would be so complicated to display the selected items one beneath the other.
Hope you guys could help me get this working and sorry for the hassle.
Regards, Dennis _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
That worked, many thanks. I still have much to learn. 2016-07-28 14:24 GMT+02:00 Marius Dumitru Florea < mariusdumitru.florea@xwiki.com>:
On Wed, Jul 27, 2016 at 3:43 PM, D R <rir.ceg@gmail.com> wrote:
Thanks, Marius
Well, looks like it is not supposed to be easy to display the items of a select field.
After playing around for some time I have: #set($obj = $doc.getObject('Customer Profile.Code.Customer ProfileClass')) #set($rawValue = $obj.getProperty('sListSupportLevel').value) #set($class = $obj.xWikiClass)
$class.get('sListSupportLevel').MapValues
Try this:
#set ($mapValues = $class.get('sListSupportLevel').mapValues) $mapValues.get($rawValue).value
Hope this helps, Marius
This displays the map like {Code1=[Code1, PrettyName1, ], Code2=[Code2, PrettyName2, ]...}
Now I feel lost again because I don't know how to get the "PrettyNames" matching the selected items out of the map.
Boy I didn't imagine that it would be so complicated to display the selected items one beneath the other.
Hope you guys could help me get this working and sorry for the hassle.
Regards, Dennis _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
D R -
Marius Dumitru Florea