4 Replies Latest reply on Sep 13, 2010 2:50 AM by nimo22

    possible bug in jsf 2.0.2

    nimo22

      I found a strange thing in jsf 2:

       

       

      THIS WORKS:

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:ui="http://java.sun.com/jsf/facelets">

       

      <h:head>
           <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      </h:head>


      <h:body>

       

      <h:form>
            <h:commandButton value="make" action="#{bean.make}">
                    <f:ajax render=":grid"/>
             </h:commandButton>
      </h:form>

       


      <h:panelGrid id="grid">
               <h:outputText value="#{bean.makeValue}" />
      </h:panelGrid>

       

      </h:body>

      </html>

       

       

       

      THIS DOES NOT WORK:

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets">

       

      <h:head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      </h:head>


      <h:body>

       

      <h:form>
           <h:commandButton value="make" action="#{bean.make}">
                   <f:ajax render=":grid"/>
            </h:commandButton>
      </h:form>

       

      <!-- this is the only difference -  in this version, I am using a div instead of a jsf-component (h:panelGrid)-->
      <div id="grid">
              <h:outputText value="#{bean.makeValue}" />
      </div>

       

      </h:body>

       

      </html>

       

      I get this error:

       

      <f:ajax> contains an unknown id ':grid' - cannot locate it in the context of the component myCommand.

       

       

      I looked at my component tree provided from the error-page and find my id which is purly called "grid".

      So the id "grid" still exists. But f:ajax cannot find it.

       

      The strange thing is,

      when substituting <div id="grid"></div> with <h:panelGrid id="grid"></h:panelGrid> then it is working - f:ajax can find "grid" and makes a update.

       

      So my question:

       

      Does f:ajax works only with jsf-components? Is this a bug? I use jsf-version "jsf-api-2.0.2-FCS.jar.

        • 1. Re: possible bug in jsf 2.0.2
          nbelaevski

          Hi Nimo,

           

          HTML elements cannot be updated by AJAX, only JSF components. BTW, that doesn't work with RF 3.x:

           

           

                  <h:form>
                       <h:commandButton value="ajax">
                            <a4j:support event="onclick" reRender="grid" disableDefault="true" />
                       </h:commandButton>
                  </h:form>
          <div id="grid">
          #{forum5Bean.currentTime}
          </div>
                  <h:form>
                   <h:commandButton value="ajax">
                   <a4j:support event="onclick" reRender="grid" disableDefault="true" />
                   </h:commandButton>
                  </h:form>
           
           <div id="grid">
           #{forum5Bean.currentTime}
           </div>
          
          • 2. Re: possible bug in jsf 2.0.2
            nimo22

            {quote}HTML elements cannot be updated by AJAX{quote}

             

            So JSF 2.0 AJAX-Tags can NOT update HTML elements. Why this limitation? Well, I can use a a h:panelGrid as a (jsf) wrapper-tag.

             

            You know, with rf 3-4, I can update html-tags.

            • 3. Re: possible bug in jsf 2.0.2
              nbelaevski

              I can't update plain HTML elements in RF 3.x Can you please post the code or try the one I've posted?

              • 4. Re: possible bug in jsf 2.0.2
                nimo22

                Yes, you are right. RF 3.x can't update HTML-Elements.

                 

                I have overseen, that I formerly used the seams s:div-tag. (Actually, I use JSF 2, Weld and soon rf 4:)

                 

                thanks.