aspose file tools*
The moose likes JSF and the fly likes Ajax & Myfaces problem - pages reloads with commandButton. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Ajax & Myfaces problem - pages reloads with commandButton." Watch "Ajax & Myfaces problem - pages reloads with commandButton." New topic
Author

Ajax & Myfaces problem - pages reloads with commandButton.

A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
I have a JSP page with simple MyFaces components like an inputText, a div and a commandButton. What I want is whatever the user types in the textbox should get into the innerHtml of the div element on click of the button. I am trying to use Ajax for this. I am using Strategy 3 from here
So I have a separate Servlet and the response is returned to the JSP.
When I test, I see that the response is captured by JSP page and the div element gets the data into it.... but just for a second or so. After that the page appears to reload and the div resets.

On further research, I found out that the page reload happens whenever I click on a commandButton in a JSF page, even if there is no Ajax call or action or onclick call. I cannot understand this specific behaviour of commandButton. The Ajax call works perfectly when I use onkeypress event on the textbox.

Can someone please advise what I must to do make the commandButton work with my Ajax call. Why is the page reloading when I click JSF commandButton component?

Thanks in advance.
[ November 24, 2006: Message edited by: A. Dusi ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax & Myfaces problem - pages reloads with commandButton.