ユーザーがを押した後に表示/非表示にしたいコンポーネントがありますcommandButton。
こんな感じです:
<h:commandButton id="showButton" value="#{bean.wasPressed ? 'Hide' : 'Show'}">
<f:ajax listener="#{bean.toggle()}" render="explanation showButton" />
</h:commandButton>
と
<h:panelGroup id="explanation" rendered="#{bean.wasPressed}">
<h:outputText value="something" />
</h:panelGroup>
プロパティをtrueまたはfalseに適切にbean.toggle()設定するだけです。wasPressed私はを使用して<h:form prependId="false">います。
問題はrender、ボタンの属性の値です。explanation:との両方を明示的に参加させshowButtonます。
が常に存在する限りshowButton(ラベルを変更するだけです) 、プロパティがtrueexplanationの場合にのみ存在します。wasPressedそうでなければそれは言う:
malformedXML:更新中:説明が見つかりません
どうすればこの問題を解決できますか?
ソースコードで要素を非表示に戻さないようにしたいので、jQueryのtoggle(-)や、style="display: none"またはこれらを使用して要素を非表示にする方法を使用しないようにします。
JSF 2.1でも実現可能ですか?