a4j:jsFunction and a4j:actionParam, problem passing js value to managedBean
fantaisie Dec 2, 2010 12:47 PMhi all.
I am facing a problem, of passing js values to jsf managed bean.
the situation is:
I want to call a actionlistener in managed bean from js, which can be done with primefaces remote command or richfaces jsFunction, but I also need a value from js(acutally a direction result from google maps api) in the actionlistener. so I have to somehow assign this js value to an attribute in the managed bean before the js call the actionlistner. with Richfaces and jsf 1.2 I can do like this:
<a4j:jsFunction name="test">
<a4j:actionparam name="param" assignTo="#{testBean.jsVal}" actionListener="#{testBean.listener}"></a4j:actionparam>
</a4j:jsFunction>
<a4j:commandButton value="test" onclick="test('valueToAssign')"></a4j:commandButton>
but as I move to JSF2(as Richfaces 4 is currently in develop, there is not <a4j:actionParam > in the latest milestone release. so I have to think about something to replace).
while I know I can do it by assign the value to a inputHidden in the page and then do submit, the problem is I can not submit the form(or refresh the page), and there is no commandButton or link to execute.
Or I will do this all in js and use mutiple inputHidden and submit when everything finish..which means I have to change much code..
I don't know if I have made myself clear because I am really lost right now....
any suggestion guys?
thx.