Question

I have a code:

<h:panelGroup>
 <p:panel>
    <p:commandButton value="Go" style="background:#25A6E1;color:#fff;font-family:'Helvetica Neue',sans-serif;font-size:10px;border-radius:4px;"
        actionListener="#{customCalender.searchUserofList}" update="picklist">
            <f:attribute name="trigram" value="#{customCalender.listTrig}"/>
            <f:attribute name="firstName" value="#{customCalender.listFname}"/>
            <f:attribute name="lastName" value="#{customCalender.listLname}"/>
            <f:attribute name="teamName" value="#{customCalender.selectedTeam}"/>   
    </p:commandButton>
 </p:panel>
</h:panelGroup>
<h:panelGroup id="picklist" rendered="#{not empty customCalender.searchList}">
    <p:pickList value="#{customCalender.searchList}" var="user" itemLabel="#{user}" itemValue="#{user}"/>
</h:panelGroup>

and the searchList generates on button click in the method searchUserofList().

I declared searchList as:

private DualListModel searchList;

public DualListModel<String> getSearchList() {
    return searchList;
}

public void setSearchList(DualListModel<String> searchList) {
    this.searchList = searchList;
}

and its being defined in method searchUserofList method like:

List<EmpBean> list = new ArrayList<EmpBean>();
    list = getSearchResult("people",trigram,firstName,lastName,teamName);
    Iterator<EmpBean> iterator = list.iterator();
    List<String> userList = new ArrayList<String>();
    List<String> userTarget = new ArrayList<String>();
    while(iterator.hasNext()){

        String userName = iterator.next().getStrUserid();
        System.out.println("Name :: "+userName);
        userList.add(userName);
    }
    searchList = new DualListModel<String>(userList, userTarget);

But when button clicked it gets the list but the picklist with the values are not shown. How can I make that correct to show the picklist?Please suggest.

Was it helpful?

Solution

You can't update dynamically a component that is not rendered, you should move your rendered attribute so your component always exists.

<h:panelGroup id="picklist">
    <p:pickList rendered="#{not empty customCalender.searchList}" value="#{customCalender.searchList}" var="user" itemLabel="#{user}" itemValue="#{user}"/>
</h:panelGroup>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top