0

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

tvrtko
  • 31
  • 4
  • I just edited the question by strikethrough over question I found an answer to: I created new JSF project with this setup and ran it on WebSphere Liberty profile. It works as a charm. I am looking for cause in real environment, and that is WebSphere Portal 9, with WAS 8.5.5 using portal bridge to expose those xhtmls as portlets. So I am looking for probable causes this normal behavior stops working – tvrtko Dec 18 '18 at 12:01
  • Your new version is JSF 2.0???? That is 10 years old. 2.3 is the current version!!! – Kukeltje Dec 18 '18 at 12:38
  • @Kukeltje yes indeed. It is WebSphere Portal 9 running on WebSphere Application Server 8.5. According to https://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/rovr_specs.html I am stuck with JSF 2.0. Also, I need Portlet bridge which according to http://myfaces.apache.org/portlet-bridge/index.html is also stuck at 2.0. – tvrtko Dec 18 '18 at 13:52

1 Answers1

0

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:

  • <c:if test="true">... -> <h:panelGroup rendered="true">...
  • <c:choose><c:when test="true">...<c:otherwise>...
    ->
    <h:panelGroup rendered="true">...<h:panelGroup rendered="false">...
  • <c:set> -> <ui:param>
  • <c:forEach> -> <ui:repeat>

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+.

stiemannkj1
  • 4,418
  • 3
  • 25
  • 45
  • thanks for the analysis. I'll accept this answer as I also think this is portlet bridge bug and it is obvious it is not going to be fixed. I have replaced all jstl tags with jsf tag equivalents, which opened new questions. but that is not part of this question. For example: https://stackoverflow.com/questions/54180277/fajax-render-referencing-iterated-component – tvrtko Jan 14 '19 at 11:36