Re: T5: Buttons, JS popup, Ajax/Zone and ActionLink
The alternative to hiding a link on the page (if you want a better separation of logic) is to pass a JSonObject with your data directly to the JavaScript method. This way if you need to you can easily pass additional data to the client for processing. So at the top of your class @Import(library = "foo/your-file.js") Example: void afterRender() { Link youUrl = resources.createEventLink("yourAction"); JSONObject spec = new JSONObject(); spec.put("yourUrl", yourUrl.toURI()); . javascriptSupport.addInitializerCall("yourJs", spec); } Javascript: Tapestry.Initializer.yourJs = function(spec) { ... } On Fri, Jan 14, 2011 at 10:45 AM, Adam Zimowski wrote: > Thanks Thiago! I'll take a look at these examples. > > @Michael - how clever !! This may be just the shortcut I needed. > > Adam > > On Fri, Jan 14, 2011 at 10:40 AM, Michael Taylor > wrote: >> My first thought would be to include the action link in the page somewhere, >> but set its style to "display: none". >> Then your JavaScript can do something like >> >> document.location.href = document.getElementById('myActionLink').href; >> >> In the past I've done something similar to trigger a zone update from inside >> a JavaScript function. >> >> >> Cheers, >> >> Mike T >> >> On Fri, Jan 14, 2011 at 11:27 AM, Adam Zimowski wrote: >> >>> Hi >>> >>> I have a feeling like this is so simple and I'm missing something >>> really obvious. I have a question on the recommended approach for a >>> specific scenario: >>> >>> An HTML button showing a JS popup rendered via Ajax. Here is specific >>> example: >>> >>> >>> http://www.chdist.com/industrial-safety-supplies/personal-protective-equipment/d-106931-106931-153343 >>> >>> This is a struts app which I'm converting to Tapestry. On go-live, >>> other than URLs, it must look exactly like current production so I >>> have to preserve the look-and-feel as well as the behavior. >>> >>> My question is, how should I approach this? Currently, the price >>> button invokes a JS call. So how can I call actionlink URL from a >>> JavaScript? >>> >>> Adam >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >> > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Buttons, JS popup, Ajax/Zone and ActionLink
Thanks Thiago! I'll take a look at these examples. @Michael - how clever !! This may be just the shortcut I needed. Adam On Fri, Jan 14, 2011 at 10:40 AM, Michael Taylor wrote: > My first thought would be to include the action link in the page somewhere, > but set its style to "display: none". > Then your JavaScript can do something like > > document.location.href = document.getElementById('myActionLink').href; > > In the past I've done something similar to trigger a zone update from inside > a JavaScript function. > > > Cheers, > > Mike T > > On Fri, Jan 14, 2011 at 11:27 AM, Adam Zimowski wrote: > >> Hi >> >> I have a feeling like this is so simple and I'm missing something >> really obvious. I have a question on the recommended approach for a >> specific scenario: >> >> An HTML button showing a JS popup rendered via Ajax. Here is specific >> example: >> >> >> http://www.chdist.com/industrial-safety-supplies/personal-protective-equipment/d-106931-106931-153343 >> >> This is a struts app which I'm converting to Tapestry. On go-live, >> other than URLs, it must look exactly like current production so I >> have to preserve the look-and-feel as well as the behavior. >> >> My question is, how should I approach this? Currently, the price >> button invokes a JS call. So how can I call actionlink URL from a >> JavaScript? >> >> Adam >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Buttons, JS popup, Ajax/Zone and ActionLink
My first thought would be to include the action link in the page somewhere, but set its style to "display: none". Then your JavaScript can do something like document.location.href = document.getElementById('myActionLink').href; In the past I've done something similar to trigger a zone update from inside a JavaScript function. Cheers, Mike T On Fri, Jan 14, 2011 at 11:27 AM, Adam Zimowski wrote: > Hi > > I have a feeling like this is so simple and I'm missing something > really obvious. I have a question on the recommended approach for a > specific scenario: > > An HTML button showing a JS popup rendered via Ajax. Here is specific > example: > > > http://www.chdist.com/industrial-safety-supplies/personal-protective-equipment/d-106931-106931-153343 > > This is a struts app which I'm converting to Tapestry. On go-live, > other than URLs, it must look exactly like current production so I > have to preserve the look-and-feel as well as the behavior. > > My question is, how should I approach this? Currently, the price > button invokes a JS call. So how can I call actionlink URL from a > JavaScript? > > Adam > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
Re: T5: Buttons, JS popup, Ajax/Zone and ActionLink
On Fri, 14 Jan 2011 14:27:12 -0200, Adam Zimowski wrote: Hi Hi! My question is, how should I approach this? Currently, the price button invokes a JS call. So how can I call actionlink URL from a JavaScript? Every event (ActionLink triggers events) has an URL. To get it, create a ComponentResources field and add the @Inject annotation to it, then use its Link createEventLink(String eventType, Object... context) method. It returns a Link. Use its toAbsoluteURI() to get the URL itself then pass it to your JavaScript, must probably by using RenderSupport.addScript() (you'll need to @Inject it too). This page has some RenderSupport examples: http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained. Tapestry JumpStart (http://jumpstart.doublenegative.com.au/) should have some examples too. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5: Buttons, JS popup, Ajax/Zone and ActionLink
Hi I have a feeling like this is so simple and I'm missing something really obvious. I have a question on the recommended approach for a specific scenario: An HTML button showing a JS popup rendered via Ajax. Here is specific example: http://www.chdist.com/industrial-safety-supplies/personal-protective-equipment/d-106931-106931-153343 This is a struts app which I'm converting to Tapestry. On go-live, other than URLs, it must look exactly like current production so I have to preserve the look-and-feel as well as the behavior. My question is, how should I approach this? Currently, the price button invokes a JS call. So how can I call actionlink URL from a JavaScript? Adam - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org