Pascal Voitot wrote:
OK,
I don't have solved everything but I have found the origin of the
stackoverflow...
I coded a Recursive VelocityMacro and apparently variables inside VM macro
are not local and it makes my recursion infinite!!!
Apparently, there is an option in velocity to make local macro variables
have only a local scope. Do you see any problem about this?
Yes, I had my share of pain with the fact that variables defined inside
macros are global... I am +1 for making them local, but all the macros
should be checked, since some of them might use this "feature".
I have modified my dbstringlist SQL query to use only
one column to be sure
this is the easiest case...
I then add a listitem manually to the list property of the object in my
velocity script. Everything is OK but sometimes the list item appears in the
object editor, sometimes not and i don't understand why yet!
It should always be there. The code says that if the selected item is
not in the list obtained from the DB, then it is manually added at the end.
Still investigating!
best regards
PAscal
On Thu, Oct 2, 2008 at 6:22 PM, Pascal Voitot
<pascal.voitot.dev(a)gmail.com>wrote;wrote:
> plz see below
>
> thks
> Pascal
>
> On Thu, Oct 2, 2008 at 6:01 PM, Sergiu Dumitriu <sergiu(a)xwiki.com> wrote:
>
>> Pascal Voitot wrote:
>>> hello guys,
>>> I do the following:
>>> - I have a class with a DBStringList property "mylist"
>>> - In a velocity script, I do:
>>> #set($obj = $doc.getObject("MyClass", $mynb)
>>>
>>> #set($mylist = $obj.get("mylist"))
>>> #set($mylist = "${mylist}|${mynewlistitem}")
>>> #set($ret = $obj.set("mylist", $mylist))
>>>
>>> #set($ret = $doc.save())
>>>
>>> - I run this script and I can see in the DB that "mynewlistitem"
was
>> added
>>> as listitem to "mylist" but the item doesn't appear in the
object editor
>> for
>>> property "mylist" in my document.
>>> - Moreover, I get some rendering exception in contentview.vm when I try
>> to
>>> access this object in other velocity scripts.
>>> - When I create the link using the Object editor, then everything works
>> well
>>> but I don't see anything different in the DB from the previous state.
>>>
>>> - I have tried the same with:
>>> #set($obj = $doc.getObject("MyClass", $mynb)
>>>
>>> #set($mylist = $obj.getProperty("mylist").getValue())
>>> #set($ret = $mylist.add("${mynewlistitem}"))
>>>
>>> #set($ret = $doc.save())
>>>
>>> same result...
>>>
>>> It seems the Object property is saved but it is not taken into account
>> by
>>> the object in the document.
>>>
>>> Do you any clue for me?
>>>
>> - is the property multiselect? relational storage?
>
> multiselect relation storage
>
>> - would the mynewlistitem value be returned by the DB search? Or is it a
>> new value you want to include manually?
>
> in Object editor, I use the DB search to return this value (which is stored
> in DB) plus another string (which is the displayed value)
>
> select myvalue, mystring from ...
>
> In my velocity script, I had this value manually directly accessing the
> property... But after that, I verify it has been stored using the Object
> editor...
>
>
>> - does the DB query normally return one or two values?
>
> 2 values
>
>
>> - what exactly is the error you receive?
>
> I don't have it here now but this is a kind of StackOverflow in
> getRenderedContent()
>
> I will search with the debugger if you don't have any quick idea... In
> fact, as my property is well stored in the DB (I have verified manually), I
> don't see the wrong interaction between this property and its object in this
> case... what's different between accessing the property from the object
> editor or from my velocity script?
--
Sergiu Dumitriu
http://purl.org/net/sergiu/