As described here: Calling Managed Bean Method From JavaScript it is possible to call a mangaged beans function through a hidden JSF button from javascript. However, I need to parse js variables as the jsf buttons action argument. Is this even possible?
Pseudocode for better understanding:
<h:commandButton id="mybtn" action="#{mybean.method(javascript_var:argument}" style="display: none;" />
/...
<script>
var argument = "this argument is passed to the mybean.method(argument)"
document.getElementById("mybtn").click();
</script>
One (maybe) possible way would be to integrate a hidden jsf inputtext dummy element into my submit form, setting its value through js and sending that to the same managed bean, in the same request and fiddeling the argument into the method server sided. But is their a better 'state of the art'-solution?