Question

I am in the process of redesigning a project and I've come across what I think is a bug but Im confused as to where the bug is originating from.

Basically all I am trying to do is pass a URL parameter to the backing bean. Nothing magic and there are loads of different ways of achieving this. The following are the ones I use regularly;

  1. I can change the bean from @Named to @ManagedBean and then use the @ManagedProperty
  2. I can access the param using FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap() and then get the desired param from the Map
  3. Or I can use: <f:metadata><f:viewParam name="id" value="#{backingBean.id}"/></f:metadata>

When I'm using JSF 2.1 with Glassfish 3+ all three of these work perfectly. The problem is that my current project is using JSF 2.2 and Glassfish 4 and none of these work! No matter what I do the parameter is never set and always just ends up as null.

I'm not sure how to track this down further. The obvious changes from the last project are that I am using Glassfish 4 instead of 3, JavaEE 7 instead of 6, and JSF 2.2 instead of 2.1. I don't get any errors or exceptions that I can post.

Is there anything else I can test or any alternative solutions I can try. Failing that is anybody aware of any reported bugs or changes that might cause this. Lastly can anybody reproduce this error?

Was it helpful?

Solution

The problem relates to the namespace!

If you declare the old namespace everything will work fine;

xmlns:f="http://java.sun.com/jsf/core"

If you declare the new namespace it won't work;

xmlns://xmlns.jcp.org/jsf/core

Be careful as netbeans will automatically populate your namespaces. I really hope this saves somebody some time!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top