Re: [xwiki-users] Implement Jsontool.serialize in groovy
Hi Thomas, I instantiate the jsonbuilder as follows in the example yet returned to previous error that was not allow adding elements in my json method. Add (). I have also realized by placing the method within an array as criuado test (data.projetos [i]. Id.add ()). {{groovy}}def hql0 = , BaseObject as obj where doc.fullName = obj.name and obj.className = 'E-nova.E-novaClass';def listProjetos = services.query.hql(hql0).execute();def i = 0;def data = new groovy.json.JsonBuilder();data = [totalprojetos: listProjetos.size(),projetos: [ id: , tag: , label: , size: , color: , x: , y : ],edges:[ id: , source: , target: ]]; for(item in listProjetos){ def hql = select distinct list from BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' and obj.name ='$item' ;def tag = services.query.hql(hql).execute(); i = i + 1; data.projetos.id.add()=1; data.projetos.tag.add()=tags; data.projetos.label.add()=Label do projeto; data.projetos.size.add()=5; data.projetos.color.add()=#696969; data.projetos.x.add()=1; data.projetos.y.add()= 1;} def json = new groovy.json.JsonBuilder(data)println json.toPrettyString(){{/groovy}} Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631 From: eduardo.abri...@outlook.com To: users@xwiki.org Date: Mon, 30 Jun 2014 15:23:37 -0300 Subject: Re: [xwiki-users] Implement Jsontool.serialize in groovy I'm trying to implement a function that told me but I can not add the data online, I can only add one. How do I do that? {{groovy}}def hql0 = , BaseObject as obj where doc.fullName = obj.name and obj.className = 'E-nova.E-novaClass';def listProjetos = services.query.hql(hql0).execute();def i = 0;def data = new groovy.json.JsonBuilder();data = [totalprojetos: listProjetos.size(),projetos: [ id: , tag: , label: , size: , color: , x: , y : ],edges:[id: , source: ,target: ]]; for(item in listProjetos){ def hql = select distinct list from BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' and obj.name ='$item' ;def tag = services.query.hql(hql).execute(); i = i + 1; data.projetos.id=1; data.projetos.tag=tags; data.projetos.label=Label do projeto; data.projetos.size=5; data.projetos.color=#696969; data.projetos.x=1; data.projetos.y= 1;} def json = new groovy.json.JsonBuilder(data)println json.toPrettyString(){{/groovy}} Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631 Date: Fri, 27 Jun 2014 11:51:47 +0200 From: thomas.morta...@xwiki.com To: users@xwiki.org Subject: Re: [xwiki-users] Implement Jsontool.serialize in groovy You should probably use JsonBuilder which is the standard tool to manipulate JSON in Groovy. On Fri, Jun 27, 2014 at 10:33 AM, Clemens Klein-Robbenhaar c.robbenh...@espresto.com wrote: The velocity tools are not automatically created for groovy scripts The closest you can get is to create them manually in your script, like: def jsontool = new org.xwiki.velocity.tools.JSONTool() I feel there should be a better way to do that, but it works this way. (it is likely that using groovy.json.JsonBuilder() works, too, but I have not tried) Clemens On 06/24/2014 09:21 PM, Eduardo Abritta wrote: Hello Sirs, I need to implement the function jsontool.serialize in the code below, groovy, and I do not understand the error that is accusing, can help me solve this? {{groovy}}def hql0 = , BaseObject as obj where doc.fullName = obj.name and obj.className = 'E-nova.E-novaClass';def listProjetos = services.query.hql(hql0).execute();def json = ['totalprojetos': listProjetos.size(), 'projetos':[1000] , 'edges':[1000] ];def i = 0; for(item in listProjetos){def hql = select distinct list from BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' and obj.name ='$item' ;def tag = services.query.hql(hql).execute();i = i + 1; json.projetos.add({id: xwiki.getDocument(item).getName() })} jsontool.serialize(json); {{/groovy}} Ty. Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631 ___ 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 -- Thomas Mortagne ___ users
Re: [xwiki-users] Implement Jsontool.serialize in groovy
I'm trying to implement a function that told me but I can not add the data online, I can only add one. How do I do that? {{groovy}}def hql0 = , BaseObject as obj where doc.fullName = obj.name and obj.className = 'E-nova.E-novaClass';def listProjetos = services.query.hql(hql0).execute();def i = 0;def data = new groovy.json.JsonBuilder();data = [totalprojetos: listProjetos.size(),projetos: [ id: , tag: , label: , size: , color: , x: , y : ],edges:[id: , source: ,target: ]]; for(item in listProjetos){ def hql = select distinct list from BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' and obj.name ='$item' ;def tag = services.query.hql(hql).execute();i = i + 1;data.projetos.id=1;data.projetos.tag=tags; data.projetos.label=Label do projeto;data.projetos.size=5; data.projetos.color=#696969;data.projetos.x=1;data.projetos.y= 1;} def json = new groovy.json.JsonBuilder(data)println json.toPrettyString(){{/groovy}} Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631 Date: Fri, 27 Jun 2014 11:51:47 +0200 From: thomas.morta...@xwiki.com To: users@xwiki.org Subject: Re: [xwiki-users] Implement Jsontool.serialize in groovy You should probably use JsonBuilder which is the standard tool to manipulate JSON in Groovy. On Fri, Jun 27, 2014 at 10:33 AM, Clemens Klein-Robbenhaar c.robbenh...@espresto.com wrote: The velocity tools are not automatically created for groovy scripts The closest you can get is to create them manually in your script, like: def jsontool = new org.xwiki.velocity.tools.JSONTool() I feel there should be a better way to do that, but it works this way. (it is likely that using groovy.json.JsonBuilder() works, too, but I have not tried) Clemens On 06/24/2014 09:21 PM, Eduardo Abritta wrote: Hello Sirs, I need to implement the function jsontool.serialize in the code below, groovy, and I do not understand the error that is accusing, can help me solve this? {{groovy}}def hql0 = , BaseObject as obj where doc.fullName = obj.name and obj.className = 'E-nova.E-novaClass';def listProjetos = services.query.hql(hql0).execute();def json = ['totalprojetos': listProjetos.size(), 'projetos':[1000] , 'edges':[1000] ];def i = 0; for(item in listProjetos){def hql = select distinct list from BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' and obj.name ='$item' ;def tag = services.query.hql(hql).execute();i = i + 1; json.projetos.add({id: xwiki.getDocument(item).getName()})} jsontool.serialize(json); {{/groovy}} Ty. Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631 ___ 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 -- Thomas Mortagne ___ 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
[xwiki-users] Implement Jsontool.serialize in groovy
Hello Sirs, I need to implement the function jsontool.serialize in the code below, groovy, and I do not understand the error that is accusing, can help me solve this? {{groovy}}def hql0 = , BaseObject as obj where doc.fullName = obj.name and obj.className = 'E-nova.E-novaClass';def listProjetos = services.query.hql(hql0).execute();def json = ['totalprojetos': listProjetos.size(), 'projetos':[1000] , 'edges':[1000] ];def i = 0; for(item in listProjetos){ def hql = select distinct list from BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' and obj.name ='$item' ;def tag = services.query.hql(hql).execute();i = i + 1; json.projetos.add({id: xwiki.getDocument(item).getName()})} jsontool.serialize(json); {{/groovy}} Ty. Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631 ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Using parameter macro in the js extension
Exactly. I'm needing initialize a value in the velocity environment and use it on the javascript code. it not needs to be dinamic. I am trying to use the following code but the JS variable is returning undefined Java Script Code var param; this.param=$xcontext.macro.params.parameter; console.log(param); Velocity (Macro) $xcontext.put(param, $xcontext.macro.params.parameter) Some light? ty Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | Date: Tue, 13 May 2014 10:05:17 +0200 From: jeremie.bousq...@gmail.com To: users@xwiki.org Subject: Re: [xwiki-users] Using parameter macro in the js extension Hi, 2014-05-13 8:40 GMT+02:00 Michael Bußler michael.buss...@googlemail.com: Hi, the velocity-code is executed on the server, while js-code runs on the client side, AFTER the macro-code was executed . You could try need to pass parameters to your macro via an URL parameter or http POST. Only if value needs to be refreshed without a page refresh. If value comes from a velocity macro, it's in the context of a page, so it's enough to initialize the javascript var from velocity (which is ok as velocity is executed before) - it's not supposed to be updated server-side after the page is rendered. Of course if it needs to be dynamic you could go ajax. Well my understanding of Eduardo is that he needs to initialize a value in javascript, based on a macro parameter passed to a velocity macro. Hope this helps! Best, Michael Am 12.05.2014 19:01 schrieb Eduardo Abritta eduardo.abri...@outlook.com : Hi Sirs, I am developing a macro in velocity (wiki macro) and need to use a parameter (wiki macro parameter) defined by the user in my java script code (java script extension). I tried can several methods but it is not working. How can I do this? Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | ___ 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 ___ 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
Re: [xwiki-users] Using parameter macro in the js extension
Caleb, I did what do you say and it worked. Thank you. Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | Date: Tue, 13 May 2014 16:19:17 +0200 From: jeremie.bousq...@gmail.com To: users@xwiki.org Subject: Re: [xwiki-users] Using parameter macro in the js extension 2014-05-13 16:04 GMT+02:00 Caleb James DeLisle c...@cjdns.fr: This depends a lot on how the javascript is loaded... If you're including it using $xwiki.jsx.use() then it won't have the same context because it's a different HTTP request. If you use the macro and then do a {{velocity}} macro with an {{html}} macro and a script inside of that, the content will (should) be there. Another solution is to pass the info in a parameter, eg: $xwiki.jsx.use('My.Document', {param: $value}) and then in the jsx extension... var PARAMETER_ONE = $escapetool.javascript($request.getParameter('param')); Thanks, Caleb On 05/13/2014 03:28 PM, Eduardo Abritta wrote: Exactly. I'm needing initialize a value in the velocity environment and use it on the javascript code. it not needs to be dinamic. I am trying to use the following code but the JS variable is returning undefined Java Script Code var param; this.param=$xcontext.macro.params.parameter; console.log(param); Velocity (Macro) $xcontext.put(param, $xcontext.macro.params.parameter) Did you also check that this $param is correctly set a value in your velocity code ? The fact that param is undefined on javascript side is strange, if it didn't find anything in the velocity context, it should contain exactly the string '$xcontext.macro.params.parameter', not undefined. So it seems to me it was found in the context, but it has null value. Some light? ty Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | Date: Tue, 13 May 2014 10:05:17 +0200 From: jeremie.bousq...@gmail.com To: users@xwiki.org Subject: Re: [xwiki-users] Using parameter macro in the js extension Hi, 2014-05-13 8:40 GMT+02:00 Michael Bußler michael.buss...@googlemail.com: Hi, the velocity-code is executed on the server, while js-code runs on the client side, AFTER the macro-code was executed . You could try need to pass parameters to your macro via an URL parameter or http POST. Only if value needs to be refreshed without a page refresh. If value comes from a velocity macro, it's in the context of a page, so it's enough to initialize the javascript var from velocity (which is ok as velocity is executed before) - it's not supposed to be updated server-side after the page is rendered. Of course if it needs to be dynamic you could go ajax. Well my understanding of Eduardo is that he needs to initialize a value in javascript, based on a macro parameter passed to a velocity macro. Hope this helps! Best, Michael Am 12.05.2014 19:01 schrieb Eduardo Abritta eduardo.abri...@outlook.com : Hi Sirs, I am developing a macro in velocity (wiki macro) and need to use a parameter (wiki macro parameter) defined by the user in my java script code (java script extension). I tried can several methods but it is not working. How can I do this? Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | ___ 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 ___ 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 ___ 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 ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
[xwiki-users] Using parameter macro in the js extension
Hi Sirs, I am developing a macro in velocity (wiki macro) and need to use a parameter (wiki macro parameter) defined by the user in my java script code (java script extension). I tried can several methods but it is not working. How can I do this? Atenciosamente, Eduardo Abritta e-mail: eduardo.abri...@outlook.com | ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to copy the title field in an entry page for the title field of the next an application
I am developing a system and a module this has the option of adding a new entry, it would be equivalent to the title set by the user, after a new page is loaded and in this there is the need for the user to type the title again, so I wanted to spend it automatically to another page. Thank you. Date: Thu, 24 Apr 2014 22:25:42 +0300 From: mariusdumitru.flo...@xwiki.com To: users@xwiki.org Subject: Re: [xwiki-users] how to copy the title field in an entry page for the title field of the next an application Hi Eduardo, On Thu, Apr 24, 2014 at 3:03 PM, Eduardo Abritta eduardo.abri...@outlook.com wrote: Good Morning Sirs, I would like to know how to copy the title field in an entry page for the title field of the next an application. Can anyone help me? You need to give more details. I didn't understood what you are trying to achieve. Are you referring to an application created with App Within Minutes ( http://extensions.xwiki.org/xwiki/bin/view/Extension/App+Within+Minutes+Application ) ? Hope this helps, Marius Thank you.Eduardo Abritta ___ 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 ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to copy the title field in an entry page for the title field of the next an application
Marius, Yes, i'm using the app within minutes to build the application. What I am trying to do is handle automatically the value of the entry. For example, when I create a new entry, I need inform the page name and I want that this value go to text field of my application automatically, avoiding that the user need to retype it. How can I do this? Thank you From: eduardo.abri...@outlook.com To: users@xwiki.org; mariusdumitru.flo...@xwiki.com Date: Fri, 25 Apr 2014 14:40:36 +0300 Subject: Re: [xwiki-users] how to copy the title field in an entry page for the title field of the next an application I am developing a system and a module this has the option of adding a new entry, it would be equivalent to the title set by the user, after a new page is loaded and in this there is the need for the user to type the title again, so I wanted to spend it automatically to another page. Thank you. Date: Thu, 24 Apr 2014 22:25:42 +0300 From: mariusdumitru.flo...@xwiki.com To: users@xwiki.org Subject: Re: [xwiki-users] how to copy the title field in an entry page for the title field of the next an application Hi Eduardo, On Thu, Apr 24, 2014 at 3:03 PM, Eduardo Abritta eduardo.abri...@outlook.com wrote: Good Morning Sirs, I would like to know how to copy the title field in an entry page for the title field of the next an application. Can anyone help me? You need to give more details. I didn't understood what you are trying to achieve. Are you referring to an application created with App Within Minutes ( http://extensions.xwiki.org/xwiki/bin/view/Extension/App+Within+Minutes+Application ) ? Hope this helps, Marius Thank you.Eduardo Abritta ___ 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 ___ 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
[xwiki-users] how to copy the title field in an entry page for the title field of the next an application
Good Morning Sirs, I would like to know how to copy the title field in an entry page for the title field of the next an application. Can anyone help me? Thank you.Eduardo Abritta ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users