Re: JSF forced page refresh




BlackIce wrote:
Danno wrote:
BlackIce wrote:
Danno wrote:
BlackIce wrote:
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();
}
}
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.

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.

.



Relevant Pages

  • Problem bei Nutzung des Sun Java Application Server
    ... ersten Entity Bean "Account". ... Ein echter Stopper ist die Nicht-Umsetzung Keys zu Objekten: AccountPK ... Next by Date: ...
    (de.comp.lang.java)
  • EJB question - OO related (I think)
    ... In it they are showing how to find beans and create new beans. ... an account bean and in order to have an account bean, ... of these aggregate functions. ...
    (comp.lang.java.programmer)
  • myjavaserver
    ... I've an account on myjavaserver and I'start to send my work. ... My problem is that in a page I use a bean, but tomcat can't find the class. ...
    (comp.lang.java.programmer)
  • Re: EJB question - OO related (I think)
    ... In it they are showing how to find beans and create new beans. ... an account bean and in order to have an account bean, ... of these aggregate functions. ...
    (comp.lang.java.programmer)
  • Re: C# language question
    ... upon initial creation of an Account -- like the 3 you mentioned. ... public Account(string city, string state, string country) ... >public void foo() ...
    (microsoft.public.dotnet.languages.csharp)