プライムフェイスを使用して、いくつかのタブでページを作成しようとしています。ただし、タブ間を移動しているときに、選択した値の一部が失われます。最後のタブには 2 つの selectBooleanCheckboxes と 2 つの selectOneRadios が含まれており、selectoneradio グリッドの 1 つがチェックボックスの値に従ってレンダリングされます。ユーザーがこれら 4 つのコンポーネントの中から選択し、タブのラジオ ボタンとチェック ボックスの間を移動すると、選択した値が失われます。bean部分に @viewScoped を使用しています。たとえば、ユーザーが 4 番目のタブを表示していて、3 番目のタブから何かを変更したい場合です。ユーザーが 3 番目のタブに移動し、チェックボックスまたはラジオ ボタンを変更すると、新しい値と以前の値がリセットされます。フォームが再びアップロードされていると思います。値が失われるのはなぜですか?これに対する解決策はありますか? コンバーターのようなものが必要ですか?
私の .xhtml は次のとおりです。
<h:form id="form">
<p:tabView id="tabPanel" dynamic="true" activeIndex="#{myBean.activeIndex}" cache="false">
<!-- FIRST TAB -->
<p:tab id="person" title="Person">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="name" />
<p:inputText value="???USERINFO???" label="Name" />
<p:commandButton value="NEXT" action="#{myBean.nextTab}" update=":form:tabPanel" />
</h:panelGrid>
</p:tab>
<!-- SECOND TAB -->
<p:tab id="adres" title="Address">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="Phone" />
<p:inputMask id="phone" value="???USERINFO???" mask="1999999999" required="true" requiredMessage="ERROR AT PHONE NUMBER"/>
<p:commandButton value="NEXT" action="#{myBean.nextTab}" update=":form:tabPanel" />
</h:panelGrid>
</p:tab>
<!-- THIRD TAB -->
<p:tab id="contact" title="Contact">
<h:panelGrid columns="2" cellpadding="10">
<h:panelGrid columns="3" style="margin-bottom:5px" cellpadding="5">
<h:outputText value="My Question: " />
<p:selectBooleanCheckbox value="#{myBean.myCheckBox}" />
<h:outputText value="Yes" />
<h:outputText value="My Second Question:" />
<p:selectBooleanCheckbox value="#{myBean.myCheckBox2}" />
<h:outputText value="No" />
</h:panelGrid>
<h:panelGrid id="panelGrid" columns="3" style="margin-bottom:10px" cellpadding="10">
<p:outputLabel value="My question"/>
<h:outputLabel for="radio"/>
<h:selectOneRadio id="radio" value="#{myBean.radioButton}" required="true" requiredMessage="ERROR">
<f:selectItem itemLabel="Yes" itemValue="Yes"/>
<f:selectItem itemLabel="No" itemValue="No"/>
<f:ajax execute="@this" render="idInfo"/>
</h:selectOneRadio>
</h:panelGrid>
<h:panelGroup id="idInfo">
<h:panelGrid columns="3" rendered="#{myBean.radioButton == 'No'}">
<h:outputText value="Chooses: " />
<h:selectOneRadio id="selectOneRadio" value="#{myBean.type}" layout="pageDirection">
<f:selectItem itemLabel="Choice 1" itemValue="choice1"/>
<f:selectItem itemLabel="Choice 2" itemValue="choice2"/>
<f:selectItem itemLabel="Choice 3" itemValue="choice3"/>
</h:selectOneRadio>
</h:panelGrid>
</h:panelGroup>
</h:panelGrid>
</p:tab>
</p:tabView>
</h:form>