0

IceFaces 3.2.0 には問題が多すぎるため、Primefaces 3.4.2 を検討しています。パネルに含まれる車両のデータグリッドがあります。追加ボタンがあり、各車両パネルには削除ボタンがあります。

追加は正常に機能します。毎回新しい車両パネルを追加します。問題は、車両を削除すると、パネルは削除されますが、値は残ります。たとえば、年が 2008、2010、2012 の 3 台の車両があり、最初の車両を削除すると、年が 2010 と 2012 の 2 つのパネルが残っていると思われるでしょう。代わりに、2008 と表示されます。バッキング Bean は正しく動作しており、画面を手動で更新すると正しい値が表示されます。ケースを提示したので、コードは次のとおりです。

<p:dataGrid id="vehicleGrid" var="currentVehicle" value="#{vehicleInfoBean.getVehicleList()}" columns="#{vehicleInfoBean.getVehicleList().size()}" styleClass="vehicleInfoPanel" rowIndexVar="rowIdx">
    <p:panel header="VEHICLE ##{rowIdx+1}:" style="width:100%" styleClass="textEntryInputTable">
        <h:panelGrid columns="1" style="width:100%" styleClass="vehicleInfoPanel">
                <ui:include src="../components/vehicleinfo/vehiclecomponents.xhtml">
                    <ui:param name="currentVehicle" value="#{currentVehicle}" />
                    <ui:param name="labelOnly" value="false" />
                </ui:include>
            <div class="deleteButton">
                <p:commandButton value="Remove" label="Delete Vehicle" action="#{vehicleInfoBean.deleteVehicle}" update=":vehicleInfoForm:vehicleGrid" process="@this">
                    <f:setPropertyActionListener value="#{currentVehicle}" target="#{vehicleInfoBean.currentVehicle}" />
                </p:commandButton>
            </div>
        </h:panelGrid>
    </p:panel>
 </p:dataGrid>

何か案は?@form を含むあらゆる種類の更新値を試しましたが、すべて同じです。以前に dataGrid を使用したことはありませんが、ice:panelSeries が持つ反復機能が必要です。

更新: インクルードのコードは次のとおりです。

<h:panelGrid columns="2">
    <p:inputText id="vinInput" styleClass="stdFieldControl" value="#{currentVehicle.vin}" label=""
                 required="true" requiredMessage="VIN is required" >
        <p:ajax update="@this vinMsg"/>
    </p:inputText>
    <p:message id="vinMsg" for="vinInput" errorClass="ui-state-error-text"/>
    <p:outputLabel value="-----OR-----"/>
</h:panelGrid>

2013 年 1 月 14 日 - コードの更新

<p:dataGrid id="vehicleGrid" var="currentVehicle" value="#{vehicleInfoBean.getVehicleList()}" columns="#{vehicleInfoBean.getVehicleList().size()}" styleClass="vehicleInfoPanel" rowIndexVar="rowIdx">
    <p:panel header="VEHICLE ##{rowIdx+1}:" style="width:100%" styleClass="textEntryInputTable">
        <h:panelGrid columns="1" style="width:100%" styleClass="vehicleInfoPanel">
            <p:inputText id="vinInput" styleClass="stdFieldControl" value="#{currentVehicle.vin}" label="" required="#{empty param['vehicleGrid:0:btnDelete'] and empty param['btnAdd']}" requiredMessage="VIN is required" >
            </p:inputText>
            <p:message id="vinMsg" for="vinInput" errorClass="ui-state-error-text"/>
            <p:outputLabel value="-----OR-----"/>
            <h:inputText id="yearInput" styleClass="stdFieldControl" value="#{currentVehicle.year}" label=""
                                             required="#{empty param['vehicleGrid:0:btnDelete']}" requiredMessage="Year is required">
            </h:inputText>
            <p:message id="yearMsg" for="yearInput"
                                           errorClass="ui-state-error-text"/>
            <div class="deleteButton">
                <p:commandButton id="btnDelete" value="Remove" label="Delete Vehicle" action="#{vehicleInfoBean.deleteVehicle}" update="@form">
                    <f:setPropertyActionListener value="#{currentVehicle}" target="#{vehicleInfoBean.currentVehicle}" />
                </p:commandButton>
            </div>
        </h:panelGrid>
    </p:panel>
</p:dataGrid>

追加コードは次のようになります。

<div class="addButton" style="padding-left: 2.17%; float: left; clear: both">
    <p:commandButton id="btnAdd" value="AddVehicle" label="Add Vehicle" actionListener="#{vehicleInfoBean.addVehicle}" update="vehicleGrid"/>
</div>

ボタンにチェックを入れる代わりに、ボタンを参照するコンポーネントの必須属性を設定することにしました。このコードは、イテレータ インデックスをハードコーディングすると機能します。たとえば、required="#{empty param['vehicleGrid:0:btnDelete']}". このコードは、panelGrid の最初の削除ボタンを指しています。必要なのは、これへのインデックスを動的に派生させることです-required="#{empty param['vehicleGrid: #{rowIdx} :btnDelete']}". 追加ボタンはイテレータに存在しないため簡単でした。panelGrid の rowId を動的に参照できる方法で param をコーディングするにはどうすればよいですか? RowId は紛らわしいように見えますが、これは各車両パネルが前のパネルの横に表示されるようにコーディングされています。この場合の行は、列と考えることができます。誰にもアイデアはありますか?

4

0 に答える 0