可选择的Primefaces数据列表



我正在尝试选择素数数据列表中的一项。我关注Primefaces网站作为监护。http://www.primefaces.org/showcase/ui/datagrid.jsf(DataList 与 datagirid 具有相同的行为)

这是我的代码。

我的豆子 :

@Component
@Scope("session")

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


//Setter getters
}

我的页面 :

<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>

该页面显示正确的值,如列表所示。 但是,当我尝试选择一个项目时。 它不起作用。

知道我可以在列表中选择一个项目吗?

您的commandLink没有任何行为。您必须添加一些 action/actionListener 或客户端回调(例如:http://www.primefaces.org/showcase/ui/datagrid.jsf 它是某个 oncomplete 属性)到 commandLink

编辑:

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

和豆子中的方法:

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

如果要使数据列表可选。 您应该用<p:column></p:column>标签包围项目。

最新更新