0

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.

czetsuya
  • 4,773
  • 13
  • 53
  • 99
  • At least there's nothing wrong with the stack. Do note that GlassFish implements JSF, so if you have added it yourself then it indeed won't work. Your stack is basically GlassFish 3.1.2.2 + PrimeFaces 3.4.2. – Arjan Tijms Dec 30 '12 at 13:23
  • Sorry, JSF 2.1 is not included in my final ear project. I replaced it with mojarra. So to solved the problem, you mean I should removed the dependency to mojarra? I'll try that. – czetsuya Dec 30 '12 at 13:30
  • Unfortunately, it's not possible to replace JSF 2.1 by Mojarra. The 'problem' is that Mojarra IS JSF 2.1. GlassFish already provides JSF (and it happens to be Mojarra). If there's nothing in your EAR (only the single PrimeFaces lib), then it's okay. – Arjan Tijms Dec 30 '12 at 13:38
  • @ArjanTijms, after removing the dependency to mojarra and only primefaces jar remains, the selection still won't work. And after further testing, the single selection also don't work. – czetsuya Dec 30 '12 at 13:40
  • It depends on what you mean by "removing the dependency to Mojarra". If you mean removing the Mojarra jars from GlassFish, then this is obviously not good. If you mean removing references in your code to Mojarra, then it again depends on what you mean by that. Since PrimeFaces works on top of a JSF implementation, and Mojarra is your JSF implementation, you can't really remove dependencies on JSF and have only PrimeFaces dependencies left. If you had somehow used Mojarra private packages, then sure, remove them. But at the moment I don't see the connection with the issue. – Arjan Tijms Dec 30 '12 at 13:44
  • @ArjanTijms, to clarify things out. No I didn't touched Glassfish's jars, I only removed my project dependency with mojarra. So it'll only use the dependency tree of primefaces (I thought I could override, what's inside glassfish :-?). Anyway, even after doing that, selection still won't work and there's no single log to explain the problem neither in glassfish log or firebug. – czetsuya Dec 30 '12 at 13:53

1 Answers1

0

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.

czetsuya
  • 4,773
  • 13
  • 53
  • 99