1

I am upgrading a project from JSF1.2/Facelets1.1 to JSF2.1 with built in facelets. The following no longer works and I don't know why. Both ui:fragments apparently evaluate to true, and both the link version and the plain text version are rendered:

<ui:fragment rendered="#{rootcauseid ne rc.id}">
    <a href="#{request.contextPath}/viewrootcause.jsf?rootcausenum=#{rc.id}">Root Cause #{rcRowCounter + 1}</a>
</ui:fragment>
<ui:fragment rendered="#{rootcauseid eq rc.id}">
    <h:outputText value="Root Cause #{rcRowCounter + 1}"/>
</ui:fragment>

The following does work, so I have a valid workaround.

<h:panelGroup rendered="#{rootcauseid ne rc.id}">
    <a href="#{request.contextPath}/viewrootcause.jsf?rootcausenum=#{rc.id}">Root Cause #{rcRowCounter + 1}</a>
</h:panelGroup>
<h:outputText value="Root Cause #{rcRowCounter + 1}"
    rendered="#{rootcauseid eq rc.id}"/>

But why doesn't the ui:fragment version work? What has changed about Facelets and JSF that would make a difference? Is "ui:fragment rendered='...'" no longer a valid idiom?

McDowell
  • 107,573
  • 31
  • 204
  • 267
Pixel
  • 374
  • 5
  • 15
  • It should work fine to my knowledge. Try to debug calculation of rendered. How do you declare namespace for ui prefix? – mrembisz Oct 15 '11 at 18:35
  • The UI prefix is defined as: xmlns:ui="http://java.sun.com/jsf/facelets" – Pixel Oct 15 '11 at 18:56

1 Answers1

-1

According to the specification, ui:fragment has only id and binding attributes.

  • 2
    This is not true. This was a documentary bug. It was always been in Facelets, but only fixed in the tag documentation since JSF 2.1. See also http://stackoverflow.com/questions/3713468/alternative-to-uifragment-in-jsf/3714063#3714063 The concrete problem is caused by a change in the lifecycle of the `` tag in JSF 2.1 as opposed to Facelets 1.x and 2.0. – BalusC Oct 26 '11 at 14:53
  • BalusC, great information. If you have any more information on the lifecycle changes in and post that as an answer, I'll happily "accept" that response. – Pixel Nov 03 '11 at 18:55