On Mon, Feb 2, 2009 at 17:11, Jean Couteau <couteau(a)codelutin.com> wrote:
Dear all,
I have a class with a UserList attribute. I am trying to add users to
The UserList property is not that well maintained, and actually it
does not use a list internally. The actual data type inside is the
LargeStringProperty, which is a string (the same as TextArea). You
should instead use a DBListProperty, which is maintained and should
work as expected. The following code (and corrections) should work
with a DBList property only (also, only if Multiple select and
Relational storage are checked for the property, since otherwise you'd
also get a LargeStringProperty instead of a list).
this list from an other page with no success. I try
using the following
code :
#if($joinTask!="")
#set($taskDoc = $xwiki.getDocument("Project.${joinTask}"))
#set($taskObj = $taskDoc.getObject("XWiki.TaskClass"))
#set($list = $taskObj.get("assignedPeople"))
$taskObj.get doesn't return the internal value of the property, but it
actually displays the value as HTML. The right approach is:
#set($list = $taskObj.getProperty('assignedPeople').value)
Now $list is a real java ArrayList, so the next code will work.
$list.add($xwiki.getUser())
$taskObj.set("assignedPeople", ${list})
^ This is not needed, the list is already the property value. It's
enough to save the document.
> $taskDoc.save()
> #end
>
> but $list.add does not exist so I tried differently :
>
> #if($joinTask!="")
> #set($taskDoc = $xwiki.getDocument("Project.${joinTask}"))
> #set($taskObj = $taskDoc.getObject("XWiki.TaskClass"))
> #set($list = $util.getArrayList())
$list.add($xwiki.getUser())
$taskObj.set("assignedPeople", ${list})
> $taskDoc.save()
> #end
>
> but I have a casting exception.
>
> I had a look on the velocity website, on this list archives,... with no
> success
>
> My question is : Can I add users like that or the only way is through
> the edit panel and if yes, what is my mistake ?
--
http://purl.org/net/sergiu