jsfjstlmyfaceswebsphere-portalibm-rad

c:if as part of composite:insertChildren


I am trying to migrate one app to new app server and JSF seems to start behaving differently due to different JSF implementation. It is MyFaces 2.0 now, that I am having problem with. This worked on older server:

there is composite component <abc:form> that includes <composite:insertChildren> tag.

when using this component in xhtml like this:

<abc:form>
    <c:if test="true">
        this text will not be visible. But it should be.
    </c:if>
</abc:form>

this <c:if... part is children. However nothing is rendered. As if c:if resolved to false, or no testing occurs.

I am aware that this case can be resolved by utilizing <h:outputText> instead of <c:if>, but I have a lot of code where <c:if> is included in more complex children. This example is just a simplification that describes my pain.

So, is it legal to have jstl tags that are includeable as children to components? I assume JSP/JSF lifecycles are to blame here.


edit: As visible in comment below, this is a combination of JSF and portlet (WebSphere Portal 9 on WAS 8.5.5). I am still not sure whether portal (and portal bridge) or pure JSF is to be blamed here. Therefore I created demo project that manifests my problem. If there is any kind soul that can use this code to try deploying it to his/hers own portal, it would be much appreciated. It was created in Rational Application Developer, by creating new portlet project with one JSF portlet inside. Then I added composite component to WebContent/resources, and modified default portlet view (xhtml).

Exported projects from RAD


Solution

  • I tested your code locally in a simple Tomcat webapp and c:if worked as expected as a child of your composite component. From your comments, you indicated that you are using the MyFaces Portlet Bridge for JSF 2.0. That version of the bridge is 3.0.0-alpha. Since things worked correctly in a webapp (even with MyFaces Core 2.0.0) and the portlet bridge version is still alpha, it seems extremely likely that there is a bug in the bridge (maybe PORTLETBRIDGE-179 ?). Since MyFaces bridge is no longer maintained, I'm doubtful that the bridge will ever be fixed.

    I'd recommend that you work around this issue by replacing JSTL tags with JSF HTML tags that essentially render the same markup:

    See also: JSTL in JSF2 Facelets... makes sense?

    One other, more difficult solution would be to implement your composite component as a simple custom Java component or full custom Java component instead.

    If there is any kind soul that can use this code to try deploying it to his/hers own portal, it would be much appreciated.

    I could not reproduce this issue in Liferay 7.0 + JSF 2.2 + Liferay Faces Bridge 4.1.2. c:if worked fine as a child of your composite component. Full disclosure, I am a Liferay Faces Bridge developer. Unfortunately, I don't think Liferay Faces Bridge will solve your issue since we only support Mojarra (not MyFaces) and JSF 2.1+.