简体   繁体   English

数据表中的primefaces selectonemenu和f:selectonemenu

[英]primefaces selectonemenu and f:selectonemenu in datatable

I am using primefaces 3.5 I have ap:selectonemenu in one of the column in datatable. 我正在使用primefaces 3.5,我在数据表的某一列中有ap:selectonemenu。 and also I have a submit button on another column of same datatable. 而且我在同一数据表的另一列上有一个提交按钮。 When I do a submit the row will get removed. 当我提交时,该行将被删除。 Here when I am selecting 'Other' then do a submit action and updating the form, the p:selectonemenu items in other rows is getting 'other' as first value. 在这里,当我选择“其他”然后执行提交操作并更新表单时,其他行中的p:selectonemenu项将“其他”作为第一个值。 What is way to set 'other' to last value everytime 每次将“其他”设置为最后值的方法是什么

 <p:column headerText="Buyer Response" style="white-space:pre-line;">
                            <p:selectOneMenu value="#{buyerInProcessBean.subject}"
                                id="buyerResponseId" >
                                <f:selectItems 
                                    value="#{buyerInProcessBean.subjectMap[trans.decisionrule.ruleId]}"
                                    var="subject" itemLabel="#{subject}" itemValue="#{subject}"></f:selectItems>
                                <f:selectItem itemLabel="Other" itemValue="Other" ></f:selectItem>
                            </p:selectOneMenu>
                        </p:column>

Since you have 既然你有

<p:selectOneMenu value="#{buyerInProcessBean.subject}">

The subject is shared between all rows, of course, other select menus will have the same value as the one selected (other in your case). 该主题在所有行之间共享,当然,其他选择菜单的值将与所选菜单的值相同(在您的情况下为其他)。 For that, I suggest a simple fix, you have to move the subject attribute to the objects you are iterating on. 为此,我建议一个简单的修复方法,您必须将subject属性移动到要迭代的对象上。

Another fix, is to set the subject attribute to "Other" once your method executed on submit is finished. 另一个解决方法是,一旦在提交时执行的方法完成,就将subject属性设置为“ Other”。 But with this, even the changed selectmenu will lose "Other" as value. 但是这样一来,即使更改的选择菜单也将失去“其他”作为值。

So in conclusion, you have to change your logic, so that subject won't be shared between rows 因此,总而言之,您必须更改逻辑,以使行之间不会共享主题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM