• Post Reply Bookmark Topic Watch Topic
  • New Topic

Ajax & Myfaces problem - pages reloads with commandButton.  RSS feed

A. Dusi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!