This content has been marked as final.
Show 2 replies
-
1. Re: Pass JavaScript method outcome to server?
stu2 May 11, 2007 9:16 AM (in response to eirirlar)"eirirlar" wrote:
Hi,
I'm working with the richfaces gmap component. I need to send some data to the server that is the outcome of some JavaScript method call, along with calling an action method.
I would like this to be as easy as the following:<h:commandButton action="#{bean.method(par1,par2,par3)}"/>
where parX is a JavaScript method outcome. EL doesn't work this way so I have to figure out something.
I was thinking of using a JavaScript "onclick" event on the commandButton that triggers some JavaScript code that somehow exposes parX to EL.
Another thought was as "onclick" that calls a Seam @Remote-method with the correct JavaScript parameters.
Or maybe create a custom component.
Any thoughts on what would be the best and cleanest solution?
Remember that EL for the button executes at render time, so I don't think your first option would work conceptually. A simple option is to just put a plain old hidden field in your form, and have the javascript method set that prior to submit. You can pick the value up in the beam as an @RequestParameter -
2. Re: Pass JavaScript method outcome to server?
eirirlar Jun 16, 2007 6:18 AM (in response to eirirlar)Another thought was as "onclick" that calls a Seam @Remote-method with the correct JavaScript parameters.
This is what I ended up doing in the end. I had a look at ajax4jsf's jsFunction solution as well, but seam's remoting seems cleaner and simpler.