hi Radek,

On 01/25/2010 07:21 AM, Radek Rekas wrote:
> Hi,
>
> I am trying to change the values for a static list field in a wiki class 
> programatically but so far I have only figured out how to display them. Is it 
> possible to set class property values for static list fields programatically 
> through velocity or groovy code?

yes, it is possible but you will need programming rights for that.

>
> The code that I'm using to display the values is pasted below:
> #set($classdocname = "Test.TestClass")
> #set($classdoc = $xwiki.getDocument($classdocname))
> #foreach($field in $classdoc.getxWikiClass().properties)
>   * $field.prettyName

why iterating here? You should just
#set($field = $classdoc.getxWikiClass().get("name of your static list property 
here"))

see http://platform.xwiki.org/xwiki/bin/view/DevGuide/API for the API (the 
'core' part)

>   $doc.displayEdit($field.xWikiClass.get("values"), "${field.name}_" , $field)

I couldn't say I really understand how this line displays the values of the 
property...

However, in order to change them, you need to use the protected PropertyClass 
(com.xpn.xwiki.objects.classes.PropertyClass) of the $field, namely:

$field.propertyClass

which will be of type com.xpn.xwiki.objects.classes.StaticListClass if your 
field is a static list. Then you just play around with its values using:

$field.propertyClass.values

(for display) and

#set($field.propertyClass.values = "val1|val2|val3")

for edit.

Happy hacking,
Anca

> #end
>
> Thanks,
>
>
> Radek
> _______________________________________________
> 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

Reply via email to