Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing data between javascript and jsf

Max Qua
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I would like to implement the following using jsf 1.2:
- press a button
- run a javascript which collects some info related to the client browser (for instance)
- run an action on the server processing that info
- the navigation will be made according to the info

I tried using an hidden field in the following way but without success:

In the java script I put a string in the inputHidden field "form:hidden"...
Java script:

In the .jsp page I put the hidden element just under the h:form ...

In the .jsp page I also put the commandButton for every row af a complex table...

MyBean contains the setter and getter functions for the hidden element...

What happens when I press the button is the following:
- the javascript function is called and hiddenelem != null ( I suppose the hidden field is successfully updated)
- the MyBean setHidden is called but the string h is null (why??)
- the action is called but it returns fail and the navigation is not the expected one

I wonder why this code is not able to pass an hidden field from javascript to an action.
Is there something I missed conceptually?


  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic