5 Replies Latest reply on Aug 6, 2009 5:50 AM by Nick Belaevski

    applets and ajax do not mix?

    Mike Hanafey Newbie

      I have applets on a page that also does AJAX updates. Even though the AJAX update does not involve the part of the page with the applet, on every AJAX update the applet is destroyed and recreated.

      Is there a way to leave the applet alone in the face of AJAX updates?

        • 1. Re: applets and ajax do not mix?
          Ilya Shaikovsky Master

          reREnder not the part of the page with applet but just concrete components.

          • 2. Re: applets and ajax do not mix?
            Mike Hanafey Newbie

            Seeming silly question with a straight forward simple answer, but reality is a bit more twisted and devious.

            The issue was traced to <h:panelGroup> where the layout attribute is not specified (or specified as something other than "block"). In the test case below the panelGroup element is not rendered as a "div" because of the "layout" attribute. As a consequence each time the "cba2" AJAX request occurs the applet is destroyed and restarted.

            If the single change is made where the panelGroup is layout="block" the applet is *NOT* destroyed and restarted.

            The issue has impact beyond applets. With panelGroup JSF elements rendered as html span elements on AJAX updates a scrolling page ends up always reverting to the top of the display. It is almost like a non-AJAX update. Very strange, but I'm sure there is a good explanation...

            <?xml version="1.0" encoding="UTF-8"?>
            <!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"
             <link rel="stylesheet" type="text/css" href="../CSS/common.css"/>
            <ui:composition template="/templates/main.xhtml">
            <ui:define name="title">LT:TestingErrors</ui:define>
            <ui:define name="body">
             <div class="C-pageHeading">Error Handler Testing</div>
             <h:panelGroup id="pg" layout="not-block">
             <h:form id="f">
             <legend>Failing Actions</legend>
             <a4j:commandButton id="cba2" value="Ajax user error no traceback" reRender="f"
             <h:panelGroup id="foobar">
             width="100%" height="200" codebase="/MAVEN"
             <param name="baseUrl" value="/lt/WS"/>
             <param name="map" value="IBM2Plus"/>
             <param name="marker" value="CSU454(GST)"/>
             <param name="delta" value="10.0"/>

            • 3. Re: applets and ajax do not mix?
              Nick Belaevski Master


              Yes, FF shows exactly such behavior. It doesn't like non-inline elements inside inline (see W3C specs for more) - many symptoms were collected by community - slowdowns, unwanted scrolls, broken DOM structure... Just do no do that.

              • 4. Re: applets and ajax do not mix?
                Mike Hanafey Newbie

                It seems like a mistake that by default panelGroup is not block level, especially when it is used so often for conditional rendering.

                Could RichFaces provide a conditional rendering component when the condition would only need to be specified once, with one of two different blocks getting rendered based on true or false. Or even a switch case structure like rich tree nodes. This would eliminate non-structured looking views with:

                <h:panelGroup rendered="#{some EL expresssion}">
                <h:panelGroup rendered="#{not some EL expresssion}">

                • 5. Re: applets and ajax do not mix?
                  Nick Belaevski Master

                  You can easily create such component using Facelets.