0
votes

I am try to select one item of the primefaces datalist. I am following primefaces web site as tutarial. http://www.primefaces.org/showcase/ui/datagrid.jsf (DataList has the same behavior as datagirid)

Here is my codes.

My bean :

@Component
@Scope("session")


public class HomeBean {

    @Value("Aranacak kelime giriniz.")
    private String keyword;
    private List<Customer> customers;
    private Customer selectedCustomer;





//Setter getters
}

My page :

<p:dataList value="#{homeBean.customers}" var="customer"  >
           <f:attribute name="filter" value="true" />                    

                    <p:commandLink>               

                    #{customer.customerName}                     
                    <f:setPropertyActionListener value="#{customer}"  
                            target="#{homeBean.selectedCustomer}" >                   

                            </f:setPropertyActionListener>                                        
                       </p:commandLink>         


                </p:dataList>

the page shows proper values as list have. however, when i try to select one item. it does not work.

Any idea haw can i select a item in the list ?

2

2 Answers

0
votes

Your commandLink doesn't have any behaviour. You have to add some action/actionListener or client side callback (in example: http://www.primefaces.org/showcase/ui/datagrid.jsf it was some oncomplete attribute) to commandLink.

Edit:

<p:commandButton action="#{yourBean.someAction}" ajax="false">

And method in bean:

public String someAction()  {
       ...
   return "outcomeForAnotherPage";
}
0
votes

if you want to make selectable dataList. you should surrounded items with <p:column></p:column> tags.