Ssv
Ssv

Reputation: 1059

primefaces selectonemenu and f:selectonemenu in datatable

I am using primefaces 3.5 I have a p:selectonemenu in one of the column in datatable. 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. 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>

Upvotes: 1

Views: 4956

Answers (1)

Laabidi Raissi
Laabidi Raissi

Reputation: 3333

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.

Another fix, is to set the subject attribute to "Other" once your method executed on submit is finished. 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

Upvotes: 0

Related Questions