0

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?

4

1 回答 1

4

问题与命名空间有关!

如果您声明名称空间,一切都会正常工作

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

如果您声明的命名空间,它将不起作用;

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

请小心,因为 netbeans 会自动填充您的命名空间。我真的希望这可以节省一些时间!

于 2013-07-19T08:34:07.473 回答