-
1. Re: transfer a value from javascript to a backingbean java
amostech May 23, 2016 4:19 PM (in response to voicul)I have no specific information regarding richfaces itself but I am guessing this should be similar regardless of which template library you use.
For example in primefaces you would have a component called <p:remoteCommand which allowed you to bind a javascript function to a backing bean method.
Anyway.
Let's say you are doing this in a non-ajax manner. Meaning that your parameters are going to be sent through a POST or GET request to your backing bean.
Then I would just create a button in the screen:
<h:commandButton id="hdnBtn" actionListener="#{personBean.method}" style="display: none;" />
Note the display: none; css. So when your page loads you change the value of this field and trigger it's click manually. Like this:
onclick="jQuery('#form:hdnBtn').click();"
If you don't like this approach, please refer to this stackoverflow entry where you will find other suggestions.
Hope this helps.
Best,
Arthur.