JSF 2.0: empty statement does not work with parameter

In the file aPage.xhtml, I have the following lines:

<ui:include rendered="#{not empty param.target}" src="#{param.target}.html" />
<ui:include rendered="#{empty param.target}" src="About.html" />

With the lines above, I expected that when I go to http://localhost:8080/beta/aPage.xhtml, the page About.htmlwill be included because param.target- null. However, GlassFish threw me the following exception:

java.io.FileNotFoundException: http://localhost:8080/beta/.html

Somehow, param.targetit was not considered null.

In addition, I tried using operators ==and !=as follows:

<ui:include rendered="#{param.target != null}" src="#{param.target}.html" />
<ui:include rendered="#{param.target == null}" src="About.html" />

Interestingly, this time, on the GlassFish console, I did not see any exceptions. However, in the browser, the error page still appears with an exception java.io.FileNotFoundException.

I would be very grateful if you could tell me why this happened and what I have to do to avoid this.

UPDATE:

Joop Eggen , , :

<ui:param name="noTarget"  value="About.html" />
<ui:param name="hasTarget" value="#{param.target}.html" />
<ui:include src="#{empty param.target? noTarget : hasTarget}" />

+5
2

src , , ?

<ui:include src="#{empty param.target? 'About' : param.target}.html" />
+4

ui:include rendered... <h:panelGroup

<h:panelGroup rendered="#{not empty param.target}">
   <ui:include  src="#{param.target}.html" />
</h:panelGroup>
<h:panelGroup rendered="#{empty param.target}" >
    <ui:include src="About.html" />
</h:panelGroup>

Edit

, , EL src ,

EL src <ui:include> ,

+3

All Articles