I have to write a JSF application using navigation rules. I have a few ManagedBeans that are mostly requestScoped. When a user clicks on a commandLink or commandButton, I want to pass a Parameter (for example the id of the current Bean) so the Bean can fill its modell with the data using this passed id to find the data in the used database. For this reason, I used following sollution:
...
<navigation-rule>
<display-name>mainpage.xhtml</display-name>
<from-view-id>/mainpage.xhtml</from-view-id>
<navigation-case>
<from-action>#{postBean.findById(post.id)}</from-action>
<from-outcome>single</from-outcome>
<to-view-id>/postpage.xhtml</to-view-id>
<redirect include-view-params="true">
<view-param>
<name>id</name>
<value>#{postBean.post.id}</value>
</view-param>
</redirect>
</navigation-case>
</navigation-rule>
...
This works and the view-param is seen in the URL but Eclipse always shows the error:
cvc-complex-type.2.4.a: Invalid Content was found starting with element 'view-param'. One of '{"http://xmlns.jcp.org/xml/ns/javaee":redirect-param}' is expected.
Do I have to use something else, does eclipse luna jee not recognize the view-param tag, how can I remove this error?
(The faces config is version 2.2, I do not use a framework like primefaces or richfaces)
It is a known issue "redirect-param are ignored #3403" with Mojarra implementation 2.2. You have to use view-param instead of redirect-param to get it work. It is fixed in 2.3.