0

我在单击命令按钮时添加行动态。其中我有两个文本字段和一个下拉列表,最后一列已保存。我能够保存已经在数据库中的旧数据,但无法保存新添加的行。当我单击保存 commandLink 时,实际上控制没有到达 bean。

<div>
                                <div class="float_right">
                                    <p:commandButton styleClass="add_uom"
                                        value="#{msg['uom.add.new.uom']}" process="@this"
                                        actionListener="#{uomBean.addRow}" immediate="true"
                                        update=":uomFormId:languageDetail">
                                    </p:commandButton>
                                </div>

                                <div class="clear">&nbsp;</div>

                                <div>

                                    <h:panelGroup id="languageDetail">
                                        <table width="100%" cellspacing="1" cellpadding="1"
                                            border="0" class="role_detail_section">
                                            <thead>
                                                <tr>
                                                    <ui:repeat var="language" value="#{uomBean.languageList}">
                                                        <th>#{language.languageCode}</th>
                                                    </ui:repeat>
                                                    <th>#{msg['uom.measuremnet.type.heading']}</th>
                                                    <th>#{msg['uom.save']}</th>
                                                    <th>#{msg['uom.activate.deactivate.heading']}</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <ui:repeat var="uom" value="#{uomBean.uomDTOList}">
                                                    <tr>
                                                        <ui:repeat var="uomCountry" value="#{uom.uomList}">
                                                            <td><h:inputText styleClass="values"
                                                                    value="#{uomCountry.languageValue}" /></td>
                                                        </ui:repeat>
                                                        <td><h:selectOneMenu
                                                                value="#{uom.measureTypeId}"
                                                                required="true"
                                                                requiredMessage="#{msg['uom.measurement.error.msg']}">
                                                                <f:selectItem itemLabel="Select" itemValue="0" />
                                                                <f:selectItems value="#{uomBean.measureList}"
                                                                    var="uomtDTO"
                                                                    itemLabel="#{uomtDTO.measurmentTypeValue}"
                                                                    itemValue="#{uomtDTO.measurmentTypeId}" />
                                                            </h:selectOneMenu></td>
                                                        <td>
                                                            <p:commandLink value="Saving.." action="#{uomBean.testUOM()}"  ></p:commandLink>
                                                            </td>
                                                        </td>
                                                    </tr>
                                                </ui:repeat>
                                            </tbody>
                                        </table>
                                    </h:panelGroup>
                                    <h:messages globalOnly="true" />
                                </div>
                            </div>

UOMDTO 是

private Country country;
private Language language;
private String uomDisplayName;
private String uomDescription;
private List<UOMDetailDTO> uomList;
private Integer measureTypeId;

和 UOMDetailDTO 是

private String languageName;
private String languageCode;
private String languageValue;
4

1 回答 1

0

很高兴看到uomBean.

我只能猜测,但如果uomBean是请求范围,则新行在您单击保存时已“丢失”,因此无法保存。如果uomBean是视图或会话范围,那么我猜你以某种方式重置/重新加载你的uomDTOList,松开新行并得到与请求范围相同的问题。

于 2013-11-13T08:18:07.550 回答