Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Ajax & Myfaces problem - pages reloads with commandButton.

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 ]
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic