Pallavi
Pallavi

Reputation: 79

How to clear p:pickList target list on close of p:dialog

I have a p:pickList within a p:dialog.

<p:dialog id="registerDialog" widgetVar="registerServiceDlg" modal="true" 
    minimizable="false" draggable="false" position="300,40" 
    style="background:#E0E0E0;" closable="true"  maximizable="false" 
    resizable="false"  visible="#{not empty facesContext.maximumSeverity}">

    <p:ajax event="close" update="registerDialog" />
    <h:outputLabel value="User" styleClass="label"/>
    <p:pickList id="contactBean" value="#{contactBean.contacts}" var="contact" 
        itemLabel="#{contact}" itemValue="#{contact}" style="margin-left:20px;" 
        required="true" requiredMessage="one user is needed"/>
</p:dialog>

On close of the dialog, I want to clear p:pickList target list. How can I achieve this? The bean is in session scope and I want to retain it in session scope itself.

Upvotes: 0

Views: 1120

Answers (1)

gokhansari
gokhansari

Reputation: 2439

Bind your target list again on your @PostConstruct method;

contacts.setTarget(new ArrayList<String>());

Good Luck!

Upvotes: 1

Related Questions