简体   繁体   English

可选的Primefaces数据列表

[英]Selectable Primefaces DataList

I am try to select one item of the primefaces datalist. 我尝试选择素数数据列表中的一项。 I am following primefaces web site as tutarial. 我将primefaces网站视为土产。 http://www.primefaces.org/showcase/ui/datagrid.jsf (DataList has the same behavior as datagirid) http://www.primefaces.org/showcase/ui/datagrid.jsf(DataList与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 ? 知道如何在列表中选择一个项目吗?

Your commandLink doesn't have any behaviour. 您的commandLink没有任何行为。 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 . 你必须要加一些动作/ ActionListener的或者客户端回调(例如: http://www.primefaces.org/showcase/ui/datagrid.jsf这是某种oncomplete属性) commandLink

Edit: 编辑:

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

And method in bean: 在bean中的方法:

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

if you want to make selectable dataList. 如果要使可选择的dataList。 you should surrounded items with <p:column></p:column> tags. 您应该用<p:column></p:column>标记包围项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM