Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

isPostBack in jsf ?

 
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>
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!