Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

JSF forced page refresh

Thread view: 
BlackIce - 14 Jun 2006 17:17 GMT
I am trying to force a JSF page to refresh all of its components so
that they will all be empty instead of the original values.  I am
trying to come from another page using a JSF hyperlink to reach the
destination page, and when the destination page is reached it should be
cleared of all previous values.  Any help would be appreciated.
Thanks
Danno - 14 Jun 2006 19:08 GMT
> I am trying to force a JSF page to refresh all of its components so
> that they will all be empty instead of the original values.  I am
> trying to come from another page using a JSF hyperlink to reach the
> destination page, and when the destination page is reached it should be
> cleared of all previous values.  Any help would be appreciated.
> Thanks

Create a "creator bean" that clear itsself when you are done submitting

public class AccountBean  {
   private Account account;

   public AccountBean() {
         account = new Account();
   }
   //setters and getters

   public void submit() {
             //persist to DB
             account = new Account();
    }
}
BlackIce - 14 Jun 2006 19:31 GMT
> > I am trying to force a JSF page to refresh all of its components so
> > that they will all be empty instead of the original values.  I am
[quoted text clipped - 18 lines]
>      }
> }
But how is that going to force the page to create a new view with no
values?
Danno - 15 Jun 2006 15:33 GMT
> > > I am trying to force a JSF page to refresh all of its components so
> > > that they will all be empty instead of the original values.  I am
[quoted text clipped - 20 lines]
> But how is that going to force the page to create a new view with no
> values?

It reflects the backend bean.  So there will be no values after you
submit....
Take a look at the submit method I sent.
BlackIce - 15 Jun 2006 19:33 GMT
> > > > I am trying to force a JSF page to refresh all of its components so
> > > > that they will all be empty instead of the original values.  I am
[quoted text clipped - 24 lines]
> submit....
> Take a look at the submit method I sent.

A little more detail and explanation would be helpful.  Thanks.
Danno - 16 Jun 2006 20:02 GMT
> > > > > I am trying to force a JSF page to refresh all of its components so
> > > > > that they will all be empty instead of the original values.  I am
[quoted text clipped - 26 lines]
>
> A little more detail and explanation would be helpful.  Thanks.

public class AccountBean  {
   private Account account;

   public AccountBean() {
         account = new Account();
   }
   //setters and getters

   public void submit() {
             //persist to DB
             account = new Account();   //create a new account after
submit
    }
}

Well, taking a look at this bean notice the account = new Account()
line in the submit method.  That means that after an account is created
via the submit method the bean will hold a blank new account which will
hold no information whatsoever.   When you visit the page all the
information will be blank.   Another strategy  is to remove that
line...

public class AccountBean  {
   private Account account;

   public AccountBean() {
         account = new Account();
   }
   //setters and getters

   public void submit() {
             //persist to DB
             //account = new Account();   //this line is removed
    }
}

and just make sure that the AccountBean is of request scope and you
will get the same functionality.
BlackIce - 27 Jun 2006 14:52 GMT
Thank you for your help Danno but i was able to find an alternate way
of solving the problem.  If I load the component tree into a list
becasue they are all attached to a form, I can go through the list of
child elements on the form (which are the elements i want to clear) and
clear each one.  I did it this way and it works, but i had to use a
submit button for it to work though.  This is fine and has no ill
affects from doing so as opposed to the traditional reset button.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.