GeeCON Prague 2014*
The moose likes JSF and the fly likes JSF Page should not refresh on click of JSF button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "JSF Page should not refresh on click of JSF button" Watch "JSF Page should not refresh on click of JSF button" New topic
Author

JSF Page should not refresh on click of JSF button

Md Ibrahim
Greenhorn

Joined: Mar 24, 2010
Posts: 14

Hi all,

we all know that any action performed on JSF usually refreshes whole page.
In the below code

<h:commandButton value="OK" action="#{BackingBean.callmethod}"/>

On click of this JSF page command button, whole page gets refreshed, since the button is by default a submit type button.

But if we use <h:commandButton value="OK" type ="reset" action="#{BackingBean.callmethod}"/>
then page wont get refreshed but the problem is Backing bean values will not be submitted.

And i know we can do this by AJAX and many more advance technologies, but my requirement is with out AJAX

Please do reply how to submit a JSF page with out page refresh and also populating corresponding backing bean values.


BY,
Ibrahim


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61305
    
  66

Please take the time to choose the correct forum for your posts. This forum is for questions on Servlets. For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bart Kummel
author
Ranch Hand

Joined: Nov 30, 2007
Posts: 81
Hi Ibrahim,

Using a "reset" type button is certainly not the way to prevent the page from being reloaded. The fact that the whole page gets reloaded is not a limitation of JSF but of HTML and HTTP. It is due to the fact that HTML forms were designed to be submitted as a whole after which a new page was to be displayed.

In recent years, more and more web applications found solutions to not reload the page when data is submitted. The techniques used for this are now known as AJAX. There is no other way to submit data to a server without reloading the page. (Unless you are using non-HTML technologies like Flash, Silverlight or Java applets...)

So if you want to submit data without reloading the page, you should rethink your "no AJAX" requirement. If the reason for this is that you don't want to write JavaScript, I have good news for you: you don't have to. By using JSF components that are "AJAX enabled", you get non-reloading pages without much effort and without writing JavaScript. A good example of a set of JSF components that do the hard AJAX work for you is the Apache MyFaces Trinidad project.

My book, Apache MyFaces 1.2 Web Application Development, has a lot of information about building JSF pages with AJAX functionality, without having to do the hard work yourself. That is one of the largest benefits of using JSF: it creates an abstraction layer, so that you don't have to bother about HTML, JavaScript or CSS.

Best regards,
Bart Kummel


SCJP 1.4 | SCJD 1.6 | Visit my website | Author of the book Apache MyFaces 1.2 Web Application Development
 
GeeCON Prague 2014
 
subject: JSF Page should not refresh on click of JSF button