2 Replies Latest reply on Feb 20, 2009 3:57 AM by stephen.friedrich

    a4j breaks JSTL?!

    stephen.friedrich

      I have a very strange case where my facelets template behaves differently in an ajax and in a non-ajax request.

      This works fine with non-ajax postback:

      <c:set var="labelClass" value=""/>
      <c:if test="#{elUtil.hasErrorMessage(rich:clientId(inputId))}">
       <c:set var="labelClass" value="error"/>
      </c:if>
      <h:outputLabel styleClass="#{labelClass}" .../>


      However it fails when executed as part of a ajax request: The hasErrorMessage() method is called correctly and returns the correct result, but in the HTML that is sent to the client the label never has the "error" style class.

      If instead I use
      <h:outputLabel styleClass="#{elUtil.hasErrorMessage(rich:clientId(inputId)) ? 'error' : ''}" .../>

      then everything works for both ajax and non-ajax requests.

      What the heck is going on here?

      I have a solution for the immediate problem, but in general this issue makes me feel queasy. Can't I rely on a4j playing nice?

        • 1. Re: a4j breaks JSTL?!
          nbelaevski

          Hello,

          This:

          <h:form>
          
           <style type="text/css">
           .error {
           color: red;
           }
           </style>
          
           <rich:messages />
          
           <c:set var="labelClass" value=""/>
           <c:if test="#{facesContext.maximumSeverity != null}">
           <c:set var="labelClass" value="error"/>
           </c:if>
          
           <a4j:outputPanel id="panel">
           <h:outputLabel value="Label" for="input" styleClass="#{labelClass}" />
           <h:inputText value="" id="input" required="true" />
           </a4j:outputPanel>
          
           <a4j:commandLink reRender="panel" value="reRender" />
           <h:commandLink value="Submit" />
           </h:form>
          doesn't work me at all, either by h:commandLink or a4j:commandLink. #{labelClass} expression uses the value of variable it had when it's been first created. So probably the problem is not in RF.


          • 2. Re: a4j breaks JSTL?!
            stephen.friedrich

            Thanks, you are right. With that example I can't reproduce the problem either.

            After some more reading, I understand that the problem is that c:if only gets evaluated when the tree is built (at which point there still is no faces message).

            I'll try and dig some more.