メソッド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.jsf
User にレンダリングされます。
ページには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
されます。true
false
myBean
request
範囲内です。それは新しい要求であるため、myBoolean
新たに割り当てられたtrue
値であると信じざるを得ません。
どうすればこれを克服できますか?secondMethod
つまり、 が呼び出されたときに、myBoolean
だった場合false
、それも含まれている必要がfalse
ありsecondMethod
ます。そして、なぜそれはmyBoolean
常に残っているのtrue
ですか?