• Post Reply Bookmark Topic Watch Topic
  • New Topic

isPostBack in jsf ?  RSS feed

 
ankur trapasiya
Ranch Hand
Posts: 160
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello...

I am using JSF and i have some code which should be run only once when the page is loaded first time so is there any mechanism like isPostBack() in jsf like asp.net ???

please reply as fast as possible because my work is stopped due to that..


Thanks in adv...
 
Guy deLyonesse
Ranch Hand
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.

In JSF 1.2, I do it something like this:



Just a bit of friendly advice... There's no need to insist that people "reply as fast as possible" because we all respond when we can. When you say that it makes people feel like you're pushing them.
 
ankur trapasiya
Ranch Hand
Posts: 160
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly , Thank you for reply and secondly sorry for making you feel bad....

Here condition is always met and each time it goes into the code. so there is no effect like post back
 
Keith Jonas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case this is helpful to someone else (since this reply is 5 years later).
You could have tried something like this:

public void initView() {
if(FacesContext.getCurrentInstance().isPostback()) {
return;
} else {
refreshView();
}
}

Where initView is called from the xhtml tag:
<f:metadata>
<f:event type="preRenderView"
listener="#{myControllerBean.initView}" />
</f:metadata>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!