0
  <h:panelGrid columns="3" >
               <p:inputText styleClass="textbox" id="search" style="margin-top:30px;width: 340px !important;" value="#{testBean.name}"/>
               <p:watermark for="search" value="searchText" />
               <p:commandButton value="search" process="@form" styleClass="btn-primary" style="margin-top:18px;" action="#{testBean.search}" update="aaa"/>
  </h:panelGrid>


    <p:pickList id="aaa" value="#{testBean.searchList}" var="contact" 
                itemLabel="#{contact.firstName}" itemValue="#{contact}" rendered="true"  >
           <!--     <p:ajax event="transfer" listener="#{contactManagedBean.onTransfer}" />-->  
    </p:pickList>

and action method is

public DualListModel<ContactBean> search(){

            String searchString= getSearch();

                contacts= manageConatctDelegate.search(searchString);

                List<ContactBean> contactTarget= new ArrayList<ContactBean>();
                contactsSource.add(contacts.get(0));
                contactList = new DualListModel<ContactBean>(contactsSource,contactTarget);                         

        return contactList;
    }

I am working on the pick list example. I have an input box where I can search name. I have a method to search a string which will retrieve contact object. After calling search method I am updating list. I have checked the list and list is getting contact. But still pick list is blank on page.

4

1 回答 1

0

What you wanted to do by returning DualListModel<ContactBean>? It can't be done in that way. Your method should be void and you should set searchList property of bean to your contactList. In fact you should have:

private DualListModel<ContactBean> searchList;

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

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

and in your search method you should set this property:

searchList = new DualListModel<ContactBean>(contactsSource,contactTarget);
于 2013-03-06T08:12:52.793 回答