[xwiki-devs] Problem with a test on 1.8 Snapshot
Hello guys, I'm developing my first application in syntax 2 for a customer. I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest build - 05/16). Here is my problem : I have a little #if in a #foreach that works on my 1.8.2 but not on my 1.8 Snapshot and I totally don't know why. #set($tradliste = $doc.getObjects("RimayCode.Traduction")) #foreach($traduc in $tradliste) #if($!traduc.langue == "Francais") $!traduc.langue : $!traduc.traduction <br /> #end #end On my 1.8.2 the "foreach" returns all the objects with the good values, and the "if" is a filter to display the items with a "Francais" value in the "langue" field. On my 1.8 Snapshot the "foreach" returns all the objects with the good values, but the "if" doesn't work : not any result. There is probably a pb, something new to do to create a test like this but I can't see what... "langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...) Any idea ? Thomas
Hi, On Mon, May 18, 2009 at 17:53, Thomas Eveilleau <[email protected]> wrote:
Hello guys,
I'm developing my first application in syntax 2 for a customer. I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest build - 05/16).
Here is my problem : I have a little #if in a #foreach that works on my 1.8.2 but not on my 1.8 Snapshot and I totally don't know why.
#set($tradliste = $doc.getObjects("RimayCode.Traduction")) #foreach($traduc in $tradliste) #if($!traduc.langue == "Francais") $!traduc.langue : $!traduc.traduction <br /> #end #end
On my 1.8.2 the "foreach" returns all the objects with the good values, and the "if" is a filter to display the items with a "Francais" value in the "langue" field. On my 1.8 Snapshot the "foreach" returns all the objects with the good values, but the "if" doesn't work : not any result.
There is probably a pb, something new to do to create a test like this but I can't see what...
"langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...)
Any idea ?
The problem is that com.xpn.xwiki.api.Object.get(String) call XWikiDocument display internally and don't just return the value. Since XWikiDocument display is supposed to return html, in 2.0 it's always enclosed in a {{html}}{{/html}}. Maybe we should: 1) put the {{html}}{{/html}} only if we find "<" or ">" in the content 2) or just never put the {{html}} when it's a StringProperty. I think the best would be that Object.get does not use display but return the value but it's too big change to be done on the old model (something to thing about for the new one) so I would prefer 1) for now. WDYT ?
Thomas
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Mon, May 18, 2009 at 18:06, Thomas Mortagne <[email protected]> wrote:
Hi,
On Mon, May 18, 2009 at 17:53, Thomas Eveilleau <[email protected]> wrote:
Hello guys,
I'm developing my first application in syntax 2 for a customer. I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest build - 05/16).
Here is my problem : I have a little #if in a #foreach that works on my 1.8.2 but not on my 1.8 Snapshot and I totally don't know why.
#set($tradliste = $doc.getObjects("RimayCode.Traduction")) #foreach($traduc in $tradliste) #if($!traduc.langue == "Francais") $!traduc.langue : $!traduc.traduction <br /> #end #end
On my 1.8.2 the "foreach" returns all the objects with the good values, and the "if" is a filter to display the items with a "Francais" value in the "langue" field. On my 1.8 Snapshot the "foreach" returns all the objects with the good values, but the "if" doesn't work : not any result.
There is probably a pb, something new to do to create a test like this but I can't see what...
"langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...)
Any idea ?
The problem is that com.xpn.xwiki.api.Object.get(String) call XWikiDocument display internally and don't just return the value. Since XWikiDocument display is supposed to return html, in 2.0 it's always enclosed in a {{html}}{{/html}}. Maybe we should: 1) put the {{html}}{{/html}} only if we find "<" or ">" in the content 2) or just never put the {{html}} when it's a StringProperty.
I think the best would be that Object.get does not use display but return the value but it's too big change to be done on the old model (something to thing about for the new one) so I would prefer 1) for now.
WDYT ?
Note that there is no way to get the value from com.xpn.xwiki.api.Object without using display() so it's kind of blocker for scripting.
Thomas
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne
Thomas Mortagne wrote: > On Mon, May 18, 2009 at 18:06, Thomas Mortagne > <[email protected]> wrote: >> Hi, >> >> On Mon, May 18, 2009 at 17:53, Thomas Eveilleau <[email protected]> wrote: >>> Hello guys, >>> >>> I'm developing my first application in syntax 2 for a customer. >>> I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest >>> build - 05/16). >>> >>> Here is my problem : >>> I have a little #if in a #foreach that works on my 1.8.2 but not on my >>> 1.8 Snapshot and I totally don't know why. >>> >>> #set($tradliste = $doc.getObjects("RimayCode.Traduction")) >>> #foreach($traduc in $tradliste) >>> #if($!traduc.langue == "Francais") >>> $!traduc.langue : $!traduc.traduction <br /> >>> #end >>> #end >>> >>> On my 1.8.2 the "foreach" returns all the objects with the good values, >>> and the "if" is a filter to display the items with a "Francais" value in >>> the "langue" field. >>> On my 1.8 Snapshot the "foreach" returns all the objects with the good >>> values, but the "if" doesn't work : not any result. >>> >>> There is probably a pb, something new to do to create a test like this >>> but I can't see what... >>> >>> "langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...) >>> >>> Any idea ? >> The problem is that com.xpn.xwiki.api.Object.get(String) call >> XWikiDocument display internally and don't just return the value. >> Since XWikiDocument display is supposed to return html, in 2.0 it's >> always enclosed in a {{html}}{{/html}}. Maybe we should: >> 1) put the {{html}}{{/html}} only if we find "<" or ">" in the content >> 2) or just never put the {{html}} when it's a StringProperty. >> >> I think the best would be that Object.get does not use display but >> return the value but it's too big change to be done on the old model >> (something to thing about for the new one) so I would prefer 1) for >> now. >> >> WDYT ? > > Note that there is no way to get the value from > com.xpn.xwiki.api.Object without using display() so it's kind of > blocker for scripting. Don't make false statements. $object.getProperty('propertyName').getValue() returns the value. There is no simple way to get the "display value", which can be a different value if the list uses different internal and display values, or which can be localized. Perhaps we should add an API method for retrieving this "display" value, but the main concern is what to do with multi-select properties. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Thomas Eveilleau wrote:
Hello guys,
I'm developing my first application in syntax 2 for a customer. I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest build - 05/16).
Here is my problem : I have a little #if in a #foreach that works on my 1.8.2 but not on my 1.8 Snapshot and I totally don't know why.
#set($tradliste = $doc.getObjects("RimayCode.Traduction")) #foreach($traduc in $tradliste) #if($!traduc.langue == "Francais") $!traduc.langue : $!traduc.traduction <br /> #end #end
On my 1.8.2 the "foreach" returns all the objects with the good values, and the "if" is a filter to display the items with a "Francais" value in the "langue" field. On my 1.8 Snapshot the "foreach" returns all the objects with the good values, but the "if" doesn't work : not any result.
There is probably a pb, something new to do to create a test like this but I can't see what...
"langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...)
Any idea ?
What is the value returned by $traduc.langue? -- Sergiu Dumitriu http://purl.org/net/sergiu/
Hi Thomas, On May 18, 2009, at 5:53 PM, Thomas Eveilleau wrote:
Hello guys,
I'm developing my first application in syntax 2 for a customer. I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest build - 05/16).
Here is my problem : I have a little #if in a #foreach that works on my 1.8.2 but not on my 1.8 Snapshot and I totally don't know why.
#set($tradliste = $doc.getObjects("RimayCode.Traduction")) #foreach($traduc in $tradliste) #if($!traduc.langue == "Francais") $!traduc.langue : $!traduc.traduction <br /> #end #end
On my 1.8.2 the "foreach" returns all the objects with the good values, and the "if" is a filter to display the items with a "Francais" value in the "langue" field. On my 1.8 Snapshot the "foreach" returns all the objects with the good values, but the "if" doesn't work : not any result.
There is probably a pb, something new to do to create a test like this but I can't see what...
"langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...)
Any idea ?
This is strange. We haven't changed the velocity version or our velocity code. Are you sure you didn't change anything else? Like "Francais" to "Français" for ex, or a white space added before the F or after the "s"? Can you print the value of $traduc.langue before the if to see what gets printed? Thanks -Vincent
We debugged it with Thomas M. $traduc.langue returns "Francais". But we checkd the length and saw that the value was 52 instead of 8 (with a $traduc.langue.length()) So we made a : #foreach($char in $traduc.langue.toCharArray()) $char #end And saw that the result was something like : {{html wiki="false"}}Francais{{/html}} I'm still in need of a solution. Thomas Le 18/05/09 18:08, Vincent Massol a écrit :
Hi Thomas,
On May 18, 2009, at 5:53 PM, Thomas Eveilleau wrote:
Hello guys,
I'm developing my first application in syntax 2 for a customer. I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest build - 05/16).
Here is my problem : I have a little #if in a #foreach that works on my 1.8.2 but not on my 1.8 Snapshot and I totally don't know why.
#set($tradliste = $doc.getObjects("RimayCode.Traduction")) #foreach($traduc in $tradliste) #if($!traduc.langue == "Francais") $!traduc.langue : $!traduc.traduction<br /> #end #end
On my 1.8.2 the "foreach" returns all the objects with the good values, and the "if" is a filter to display the items with a "Francais" value in the "langue" field. On my 1.8 Snapshot the "foreach" returns all the objects with the good values, but the "if" doesn't work : not any result.
There is probably a pb, something new to do to create a test like this but I can't see what...
"langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...)
Any idea ?
This is strange. We haven't changed the velocity version or our velocity code. Are you sure you didn't change anything else? Like "Francais" to "Français" for ex, or a white space added before the F or after the "s"?
Can you print the value of $traduc.langue before the if to see what gets printed?
Thanks -Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Jean-Vincent just gave me a workaround : $traduc.getProperty("langue").getValue() It returns the Id in the static list instead of the associated value but it works. Thomas Le 18/05/09 18:15, Thomas Eveilleau a écrit :
We debugged it with Thomas M. $traduc.langue returns "Francais". But we checkd the length and saw that the value was 52 instead of 8 (with a $traduc.langue.length())
So we made a : #foreach($char in $traduc.langue.toCharArray()) $char #end
And saw that the result was something like : {{html wiki="false"}}Francais{{/html}}
I'm still in need of a solution.
Thomas
Le 18/05/09 18:08, Vincent Massol a écrit :
Hi Thomas,
On May 18, 2009, at 5:53 PM, Thomas Eveilleau wrote:
Hello guys,
I'm developing my first application in syntax 2 for a customer. I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest build - 05/16).
Here is my problem : I have a little #if in a #foreach that works on my 1.8.2 but not on my 1.8 Snapshot and I totally don't know why.
#set($tradliste = $doc.getObjects("RimayCode.Traduction")) #foreach($traduc in $tradliste) #if($!traduc.langue == "Francais") $!traduc.langue : $!traduc.traduction<br /> #end #end
On my 1.8.2 the "foreach" returns all the objects with the good values, and the "if" is a filter to display the items with a "Francais" value in the "langue" field. On my 1.8 Snapshot the "foreach" returns all the objects with the good values, but the "if" doesn't work : not any result.
There is probably a pb, something new to do to create a test like this but I can't see what...
"langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...)
Any idea ?
This is strange. We haven't changed the velocity version or our velocity code. Are you sure you didn't change anything else? Like "Francais" to "Français" for ex, or a white space added before the F or after the "s"?
Can you print the value of $traduc.langue before the if to see what gets printed?
Thanks -Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Mon, May 18, 2009 at 18:23, Thomas Eveilleau <[email protected]> wrote:
Jean-Vincent just gave me a workaround : $traduc.getProperty("langue").getValue()
Yes forgot about com.xpn.xwiki.api.Collection.getProperty, I only looked at Object
It returns the Id in the static list instead of the associated value but it works.
Thomas
Le 18/05/09 18:15, Thomas Eveilleau a écrit :
We debugged it with Thomas M. $traduc.langue returns "Francais". But we checkd the length and saw that the value was 52 instead of 8 (with a $traduc.langue.length())
So we made a : #foreach($char in $traduc.langue.toCharArray()) $char #end
And saw that the result was something like : {{html wiki="false"}}Francais{{/html}}
I'm still in need of a solution.
Thomas
Le 18/05/09 18:08, Vincent Massol a écrit :
Hi Thomas,
On May 18, 2009, at 5:53 PM, Thomas Eveilleau wrote:
Hello guys,
I'm developing my first application in syntax 2 for a customer. I started on a 1.8.2 XE and just moved on a 1.8 Snapshot (the latest build - 05/16).
Here is my problem : I have a little #if in a #foreach that works on my 1.8.2 but not on my 1.8 Snapshot and I totally don't know why.
#set($tradliste = $doc.getObjects("RimayCode.Traduction")) #foreach($traduc in $tradliste) #if($!traduc.langue == "Francais") $!traduc.langue : $!traduc.traduction<br /> #end #end
On my 1.8.2 the "foreach" returns all the objects with the good values, and the "if" is a filter to display the items with a "Francais" value in the "langue" field. On my 1.8 Snapshot the "foreach" returns all the objects with the good values, but the "if" doesn't work : not any result.
There is probably a pb, something new to do to create a test like this but I can't see what...
"langue" is a static list with 4 options (1=Francais|2=Tibetain|3=...)
Any idea ?
This is strange. We haven't changed the velocity version or our velocity code. Are you sure you didn't change anything else? Like "Francais" to "Français" for ex, or a white space added before the F or after the "s"?
Can you print the value of $traduc.langue before the if to see what gets printed?
Thanks -Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
participants (4)
-
Sergiu Dumitriu -
Thomas Eveilleau -
Thomas Mortagne -
Vincent Massol