My objective is to get the screen width, height, etc., into a session bean in JSF. According to the examples I've found, the way to do this is add a param to a commandButton with a value that is javascript. The value is then transferred to the assignTo bean variable. The noEscape attribute is supposed to make it so that the value is passed instead of the variable name.
This almost works. What's happening is that the literal variable name, e.g. "screen.height" winds up in the bean instead of a number, e.g. 600. I tried changing it so that it calls a script function but that didn't help. (Note, I put the params inside a commandButton because the examples showed it that way and this button is a convenient place and it's needed for the app anyway).
I have the following code
<h:commandButton value="Log In" action="#{loginBean.login}" styleClass="buttons">
<a4j:param name="w" value="getWidth()" assignTo="#{browser.screenWidth}" noEscape="true" />
<a4j:param name="h" value="screen.height" assignTo="#{browser.screenHeight}" noEscape="true" />
<a4j:param name="a" value="navigator.userAgent" assignTo="#{browser.userAgent}" noEscape="true" />
</h:commandButton>
where
<script>
function getWidth() {
return screen.width;
}
</script>
Again, the specific problem is that I'm getting the variable names into the bean, not the variable values. Any help would be much appreciated.