________________________________________
From: users-bounces(a)xwiki.org [users-bounces(a)xwiki.org] On Behalf Of Sergiu Dumitriu
[sergiu(a)xwiki.com]
Sent: 12 February 2012 20:38
To: XWiki Users
Subject: Re: [xwiki-users] Groovy script to XWiki 2.0 Syntax - constructing URLs
On 02/12/2012 06:00 AM, Ricardo.Julio.Rodriguez.Fernandez(a)sergas.es wrote:
Please, see below.
--
Ricardo Rodríguez
Research Management and Promotion Technician
Health Research Institute of Santiago de Compostela (IDIS)
http://www.idisantiago.es
________________________________________
From: users-bounces(a)xwiki.org [users-bounces(a)xwiki.org] On Behalf Of Rodriguez Fernandez,
Ricardo Julio
Sent: 12 February 2012 11:49
To: users(a)xwiki.org
Subject: Re: [xwiki-users] Groovy script to XWiki 2.0 Syntax - constructing URLs
Thanks! See below.
--
Ricardo Rodríguez
Research Management and Promotion Technician
Health Research Institute of Santiago de Compostela (IDIS)
http://www.idisantiago.es
________________________________________
From: users-bounces(a)xwiki.org [users-bounces(a)xwiki.org] On Behalf Of Vincent Massol
[vincent(a)massol.net]
Sent: 12 February 2012 11:34
To: XWiki Users
Cc: Lista Garcia, Isabel
Subject: Re: [xwiki-users] Groovy script to XWiki 2.0 Syntax - constructing URLs
On Feb 12, 2012, at 11:10 AM,<Ricardo.Julio.Rodriguez.Fernandez(a)sergas.es> wrote:
Good morning!
I'm trying to move a simple script from XWiki 1.0 Syntax to 2.0 one. It includes this
lines with which I can easily use SQL to retrieve pages and present a list of URLs to
reach those pages:
db2 = Sql.newInstance("jdbc:mysql://hostname/schema", "ROuser",
"readonly", "com.mysql.jdbc.Driver")
List areas = db2.rows('select...
println areas.collect{"<a
href='../XWiki/${it.XWD_NAME}'>${it.XWD_TITLE}</a>"}.join("<br>")
> This will generate HTML so you'll need to
wrap it in the {{html}} macro.
>
> {{groovy}}
> …
> println "{{html}}<your html here<{{/html}}"
> {{/groovy}}
>> I've already tried this to now avail.
For instance, these alternatives failed giving a Failed to execute the [groovy] macro
error message; all of them pointed to the first character of the nested html macro as
the>>> reason for the failure:
>>
>> println {{html}}areas.collect{"<a
href='../XWiki/${it.XWD_NAME}'>${it.XWD_TITLE}</a>"}.join("<br>"){{/html}}
>> println "{{html}}areas.collect{"<a
href='../XWiki/${it.XWD_NAME}'>${it.XWD_TITLE}</a>"}.join("<br>"){{/html}}"
>>
>> BTW: still Running XWiki Enterprise 2.4.30451 here... must this html nested macro
be supported in this release?
>>
>> Thanks!!!
More on this issue: this is, for sure, a clear error message for anybody mastering
Groovy...
Caused by: javax.script.ScriptException: startup failed:
Script167.groovy: 4: Ambiguous expression could be either a parameterless closure
expression or an isolated open code block;
solution: Add an explicit closure parameter list, e.g. {it -> ...}, or force it to
be treated as an open block by giving it a label, e.g. L:{...} @ line 4, column 2.
{{html}}
^
Please, how this must be applied to the way Vicent is proposing to nest the XWiki html
macro?
println "{{html}}<your html here>{{/html}}"
>>>> The problem is with nested quotes
IMHO.
>>>>
>>>> Try something simpler:
>>>>
>>>> println "{{html}}"
>>>> println the rest of your code
>>>> println "{{/html}}"
Done! Thank you very much!
Could it be useful to make some note about this behavior in XWiki Platform > XWiki
Syntaxes page?