[xwiki-devs] Javascript var to Velocity Var
Hi guys! Here is a quick question that I hope gets a quick answer.=) I have a Java Script var and a velocity var and what I want to do on the macro.vm file is: VelocityVar = JavaScriptVar Anyone know if this is possible being one on server side and the other on client side? And if possible how? Thanks! -- View this message in context: http://n2.nabble.com/Javascript-var-to-Velocity-Var-tp676366p676366.html Sent from the XWiki- Dev mailing list archive at Nabble.com.
MikSan wrote:
Hi guys! Here is a quick question that I hope gets a quick answer.=) I have a Java Script var and a velocity var and what I want to do on the macro.vm file is:
VelocityVar = JavaScriptVar
Anyone know if this is possible being one on server side and the other on client side? And if possible how?
Not directly, as velocity is executed on the server long before the javascript starts to execute on the client. You can send an xmlhttprequest back to the server, or use a form to post data. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Hi Sergiu Can you give me and example using xmlhttprequest ? My idea is to execute a java function in my plugin only when i click in a submit button Thanks Bruno Sergiu Dumitriu-2 wrote:
MikSan wrote:
Hi guys! Here is a quick question that I hope gets a quick answer.=) I have a Java Script var and a velocity var and what I want to do on the macro.vm file is:
VelocityVar = JavaScriptVar
Anyone know if this is possible being one on server side and the other on client side? And if possible how?
Not directly, as velocity is executed on the server long before the javascript starts to execute on the client. You can send an xmlhttprequest back to the server, or use a form to post data. -- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- View this message in context: http://n2.nabble.com/Javascript-var-to-Velocity-Var-tp676366p724000.html Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi, You can have a look at templates/watch.vm which is called from templates/menuview.vm by an ajax request. JV. On Thu, Aug 14, 2008 at 2:40 PM, bruno <[email protected]> wrote:
Hi Sergiu
Can you give me and example using xmlhttprequest ? My idea is to execute a java function in my plugin only when i click in a submit button
Thanks Bruno
Sergiu Dumitriu-2 wrote:
MikSan wrote:
Hi guys! Here is a quick question that I hope gets a quick answer.=) I have a Java Script var and a velocity var and what I want to do on the macro.vm file is:
VelocityVar = JavaScriptVar
Anyone know if this is possible being one on server side and the other on client side? And if possible how?
Not directly, as velocity is executed on the server long before the javascript starts to execute on the client. You can send an xmlhttprequest back to the server, or use a form to post data. -- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- View this message in context: http://n2.nabble.com/Javascript-var-to-Velocity-Var-tp676366p724000.html Sent from the XWiki- Dev mailing list archive at Nabble.com.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Jean-Vincent Drean
MikSan wrote:
Hi guys! Here is a quick question that I hope gets a quick answer.=) I have a Java Script var and a velocity var and what I want to do on the macro.vm file is:
VelocityVar = JavaScriptVar
Anyone know if this is possible being one on server side and the other on client side? And if possible how?
Thanks!
Thanks Sergiu but I have no idea how to do what you said :D #macro(queryByName $queryName $visualType $command) #set($name = $queryName + $visualType) $name #set($onClickFun = "popup('" + $name+ "');") $onClickFun #if($xwiki.wikiheavan.checkNull($name) == 1) $context.getRequest().getHttpServletRequest().getSession().setAttribute($name,1) #end #set($thisPage = $context.getRequest().getHttpServletRequest().getSession().getAttribute($name)) $xwiki.wikiheavan.queryByName($queryName,$thisPage,$visualType,$command) <button type="submit" onClick=$onClickFun name=$name > $name </button> <script language="javascript" type="text/javascript"> function popup(a){ var b = new String(a); myJsVariable = "${name}"; alert(a); alert(myJsVariable); $xwiki.wikiheavan.addpage(a) window.location.reload() } </script> #end Can you give me an example or add some clues on my code so I can figure it out. Thanks -- View this message in context: http://n2.nabble.com/Javascript-var-to-Velocity-Var-tp676366p676595.html Sent from the XWiki- Dev mailing list archive at Nabble.com.
participants (4)
-
bruno -
Jean-Vincent Drean -
MikSan -
Sergiu Dumitriu