简体   繁体   中英

Primefaces datatable multiple checkbox not working

Recently, I've been working on a project that uses Primefaces UI. One of the requirements is to have a data table where a user can select multiple rows. I've implemented something similar to: http://www.primefaces.org/showcase-labs/ui/datatableRowSelectionRadioCheckbox.jsf , but it didn't work.

At first, I thought there was something wrong with my code but when I copied the examples from primefaces it also did not work. So I was wondering if there was something wrong with my tech stack: JavaEE6, Glassfish 3.1.2.2, mojarra(javax.faces) 2.1.16, primefaces 3.4.2.

As for sample code, I copied exactly from the link given above.

Note that single selection also don't work.

I was able to solved this problem by:

1.) Created a new project from scratch and test if my stack really works. As Arjan Tijms said, even if you add a dependency to the latest version of mojarra it'll be ignored. Try deploying the new app in Glassfish and you will notice the following line:

[#|2012-12-31T11:19:15.958+0800|INFO|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=39;_ThreadName=Thread-2;|Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context '/web-demo-0.0.1-SNAPSHOT'|#]

2.) My bean is SessionScoped so it is Serializable, but I forgot to marked my injected ResourceBundle and FacesContext as transient. (My main problem).

3.) For the primefaces selection with popup dialog example, make sure that the action button targets the dialog element id for update.

4.) Make sure to run maven clean on eclipse projects, as well as the project dependencies you have. For example I have a web-commons where I defined the dependency to mojarra, although I keep cleaning the main project, I didn't notice that the commons dependency adds the mojarra jar to the final ear.

And that's all and my project is now working properly :-) Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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