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-boun...@xwiki.org [users-boun...@xwiki.org] On Behalf Of Rodriguez Fernandez, Ricardo Julio Sent: 12 February 2012 11:49 To: users@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-boun...@xwiki.org [users-boun...@xwiki.org] On Behalf Of Vincent Massol [vinc...@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.fernan...@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}}" 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. > > -- > Ricardo Rodríguez > Research Management and Promotion Technician > Health Research Institute of Santiago de Compostela (IDIS) > http://www.idisantiago.es > > 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 > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list users@xwiki.org 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 users@xwiki.org 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 users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users