________________________________________ From: [email protected] [[email protected]] On Behalf Of Vincent Massol [[email protected]] Sent: 13 February 2012 00:11 To: XWiki Users Subject: Re: [xwiki-users] Groovy script to XWiki 2.0 Syntax - constructing URLs
On Feb 12, 2012, at 11:33 PM, <[email protected]> <[email protected]> wrote: > ________________________________________ > From: [email protected] [[email protected]] On Behalf Of Sergiu > Dumitriu [[email protected]] > 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, [email protected] 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: [email protected] [[email protected]] On Behalf Of >> Rodriguez Fernandez, Ricardo Julio >> Sent: 12 February 2012 11:49 >> To: [email protected] >> 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: [email protected] [[email protected]] On Behalf Of Vincent >> Massol [[email protected]] >> 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,<[email protected]> >> 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? > > http://platform.xwiki.org/xwiki/bin/view/Main/XWikiSyntax#HMacros >>>>>>> Note about what? There's no special behavior here. >>>>>>> >>>>>>> In groovy if you wish to use GStrings you need to use ${}…. >>>>>>> >>>>>>> For example: println "${myvar}" >>>>>>> >>>>>>> Thanks >>>>>>> -Vincent About the solution provided by Sergiu about how to nest a html macro within a Groovy one in XWiki 2.0 Syntax. Even though there is no special behavior here, I think it could be useful for few skilled people like me to find it there. Perhaps just providing an example. Thanks! > Thanks! > >> Thanks!!! >> >>>> >>>> Hope it helps, >>>> -Vincent >> >>> As I'm having problems to include both Velocity (for instance, to control >>> the information panel visibility) and Groovy scripts in the same page when >>> using 1.0 syntax, I'm trying to move it to 2.0. But using the same lines >>> results in that exact text being displayed in the page, but not the URL >>> showed in 1.0 syntax. >>> >>> Please, could you tell me how could I get the same results with XWiki 2.0 >>> syntax? Thanks!!! >>> >>> I know there are a lot of different methods to get the same results within >>> XWiki, but using SQL in this case is useful to me now as kind of probe of >>> concept showing how easily could we link to "external" datasources by using >>> XWiki. >>> > > -- > Sergiu Dumitriu > http://purl.org/net/sergiu/ _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é privada e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia desta mensaxe non está autorizada. Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o copia de este mensaje no está autorizada. See more languages: http://www.sergas.es/aviso_confidencialidad.htm _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
