メソッドPhaseListenerを呼び出しています。initialize
public class myBean implements Serializable
{
private boolean myBoolean = "true";
public void initialize()
{
if(someCondition)
{
this.setMyBoolean(true);
}
else
{
this.setMyBoolean(false); // Lets assume myBoolean gets set to false here
}
}
}
このメソッドの実行後、index.jsfUser にレンダリングされます。
ページにはindex.xhtml、以下のコードがあります..
<h:commandLink action="#{myBean.secondMethod}" value="someLink">
</h:commandLink>
public String secondMethod()
{
log.debug("Value of myBoolean variable is: " +this.isMyBoolean());
return null;
}
ユーザーが をクリックするとsomeLink、上記のコードはではなくとして出力myBooleanされます。truefalse
myBeanrequest範囲内です。それは新しい要求であるため、myBoolean新たに割り当てられたtrue値であると信じざるを得ません。
どうすればこれを克服できますか?secondMethodつまり、 が呼び出されたときに、myBooleanだった場合false、それも含まれている必要がfalseありsecondMethodます。そして、なぜそれはmyBoolean常に残っているのtrueですか?