开发者

JSF not rendered when the url has a parameter

My problem is that when I for example do this

<h:outputLink value="changeinfo.jsf">
开发者_Go百科                Change name
                <f:param name="change" value="name"/>
</h:outputLink>

then the requested url is

http://localhost:45054/WMC/user/changeinfo.jsf?change=name

My url pattern for the faces servlet look like this

<servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
 </servlet-mapping>

Now on the changeinfo page

<f:verbatim rendered="#{'bean.param'} == 'name'"> 
NAME 
<h:form id="form1"> 
... 
</h:form>
</f:verbatim>

Then on the generated html page I only see the word NAME and not the form. Why is this?


You can't put JSF components inside a f:verbatim, only plain vanilla HTML. Use h:panelGroup instead.

Also, get rid of those quotes around the bean property identifier in EL. It would otherwise be treated as a plain vanilla string. You should also put the string comparison inside the EL expression.

Summarized:

<h:panelGroup rendered="#{bean.param == 'name'}">
    ...
</h:panelGroup>

As an extra hint: you can just access request parameters by #{param}. If you don't need it further in the managed bean, then you can also just do so:

<h:panelGroup rendered="#{param.change == 'name'}">
    ...
</h:panelGroup>


Have you seen this: How to create a GET request with parameters, using JSF and navigation-rules?

The problem is not the extension, but that JSF doesn't support this approach out of the box. If you have to code the McDowell solution or change web framework using for example Seam.

BTW, JSF 2 will support this style of navigation. Take a look at: fluent-navigation-jsf-2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜