Reputation: 2188
I am encountering a strange problem with <p:pickList>
. When I open a dialog having this pickList and clear all items from target list using the RemoveAll button and submit using <p:commandButton>
the old items in the target list still appear. I have given the attribute required=true
for the pickList. The strange behaviour is when I submit it, a tooltip appears saying that the field is mandatory.
So if the items are clearing and required
attribute is working fine, why are the old items reappearing? What is the solution for this?
<p:pickList id="selectedId" value="#{someDialog.selectedItem}"
var="item" itemValue="#{item}" required="true"
converter="pickListConverter" requiredMessage="#{msg.required_message}"
styleClass="#{component.valid ? '': 'ui-state-error'}">
</p:pickList>
EDIT: Backing Bean - I am posting only the relevant method. SomeDialog.java
private DualListModel<Item> selectedItem = new DualListModel<Item>();
//Its getters and setters
public final void afterSave(final ParamObject pObject) {
pObject.getRelevantData().clear();
pObject.getRelevantData().addAll(selectedItem.getTarget());
}
ParamObject .java
private List<Item> relevantData = new ArrayList<Item>();
//Setters and Getters
Upvotes: 0
Views: 1090
Reputation: 2768
As @Xtreme Biker mentioned its in your backing bean.
When first time you submit list, you set it in backing bean. Second time you open dialog, it is already there. Even if you press RemoveAll, it removes only in your browser, it doesn't work with backing bean. And your submit will not work, because you have required=true.
So you can choose one of this options:
I hope it will help as I am new in here too.
Upvotes: 2