This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Difference in behaviour between javascript click() and user click on a button using JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Difference in behaviour between javascript click() and user click on a button using JSF" Watch "Difference in behaviour between javascript click() and user click on a button using JSF" New topic
Author

Difference in behaviour between javascript click() and user click on a button using JSF

Matthew Farwell
Greenhorn

Joined: Mar 13, 2010
Posts: 1
I have a form which, when the button gets clicked by a user, redirects to another page, but when I simulate the click with javascript, the redirect fails. Tha ajax calls are exactly the same (except for the javax.faces.ViewState, but have different results.

The form looks something like:


The javascript function:

When I enter 3 into the text input box and click Go, the page is redirected as expected to the target returned by #{form.go}.

When I enter 3 into the text input box and press enter, #{form.go} is called correctly but the page is NOT redirected.

In both cases form.go is called correctly and returns the correct value for the redirection. Could anyone tell me why the javascript click() does not work, and if I'm doing something completely wrong, please tell me how to do it right.

I can't use submit() because that doesn't work in JSF, and I can't use h:commandButton because I do other stuff before and after the submit: display a 'please be patient' indicator, using



I'm using Firefox 3.5 if that makes a difference.

Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Difference in behaviour between javascript click() and user click on a button using JSF
 
Similar Threads
JSF 2.0 GlassFish 3.0.1 problem
rich:hotKey worked when using jQuery?
Can't get RequestDispatcher forward() method or response.sendRedirect() to work
JSF form: using ENTER as TABULATOR key
h:commandLink and onsubmit