4 Replies Latest reply on Sep 4, 2008 11:35 AM by Gianfranco Zola

    HtmlAjaxSupport

    Gianfranco Zola Newbie

      Hi!

      I try to create some components dynamically.

      I create a HtmlSelectOneListbox component, and I want to add a HtmlAjaxSupport facet to it.

      HtmlSelectOneListbox box = new HtmlSelectOneListbox();
      box.setId("combo1");
      
      HtmlAjaxSupport onchange = new HtmlAjaxSupport();
      onchange.setAjaxSingle(true);
      onchange.setEvent("onchange");
      onchange.setReRender("input2, combo2");
      
      box.getFacets().put("a4jsupport", onchange);
      
      parent.getChildren().add(box);
      


      So everything seems to work, the ComboBox has a ValueChangeListener also set, wich fires on value change as expected. The only thing not happening is that the input2 and combo2 items are not rerendered.

      Can you give me a hint why this is not working?

      I tried also to add the HtmlAjaxSupport component to the child components of the ComboBox, but it gave the same result. ( box.getChildren().add(onchange); )

      Thanks in advance.

      Gizola

        • 1. Re: HtmlAjaxSupport
          Nick Belaevski Master

          Gizola,

          Your code is working fine for me. Try adding a4j:log and see if there are any errors/warnings.

          • 2. Re: HtmlAjaxSupport
            Gianfranco Zola Newbie

            Hi!

            Thaks for reply.

            I added a4j:log, but I see no errors in the log.
            But what I see is that in the response my components to rerender are not mentioned:

            <meta name="Ajax-Update-Ids" content="aform:input1_message,aform:input2_message" />
            


            These are only the rich:message components on the form, but the aform:input2 and aform:combo2 are missing from this list wich are added to the HtmlAjaxSupport component's rerender property.

            I used 3.2.1-SNAPSHOT and also tried with 3.2.2-CR3, same result with both.

            This is my actual code:

            ((UIInput) component).addValueChangeListener(newGenericValueChangeListener());
            ((UIInput) component).getAttributes().put("valuechangelistener", attr_type + ";" + value);
            
            HtmlAjaxSupport onchange = new HtmlAjaxSupport();
            onchange.setAjaxSingle(true);
            onchange.setEvent("onchange");
            onchange.setReRender("aform:input2"); // here I use the "value" variable wich contains in this case:
            "aform:input2,aform:combo2" , but not working with a constant like above either.
            ((UIInput) component).getFacets().put("a4jsupport", onchange);
            


            The component variable is UIComponent type, and all objects are created dynamically in the constructor of the bean from an XML file, and then added to the viewroot.

            Regards,

            Gizola

            • 3. Re: HtmlAjaxSupport
              Gianfranco Zola Newbie

              Hi!

              I made a lot of experiments, and I got the following results:


              HtmlAjaxSupport
              - Event property is working flawlessly, I tried it with onchange, and onmouseover, both event was fired, also seen in the a4j:log

              - Oncomplete property is working, I managed to call javascript (like alert('x');)

              - ReRender property is NOT working, the components are never rerendered given in this property

              So somehow a part of the HtmlAjaxSupport component is working, and part of it does not.

              I do not have a clue, why.

              Regards,

              Gizola

              • 4. Re: HtmlAjaxSupport
                Gianfranco Zola Newbie

                Hi!

                Ok, finally I got it work, and found the problem:

                HtmlSelectOneListbox box = new HtmlSelectOneListbox();
                box.setId("combo1");
                
                HtmlAjaxSupport onchange = new HtmlAjaxSupport();
                onchange.setAjaxSingle(true);
                onchange.setEvent("onchange");
                onchange.setId("a4jsupport");
                onchange.setReRender("input2, combo2");
                
                box.getFacets().put("a4jsupport", onchange);
                
                parent.getChildren().add(box);
                


                The solution was to set the HtmlAjaxSupport's Id to that string, wich string you provide for the facet name.
                So the reRender property is also working...

                So this is good info I think for all !!

                Regards,

                Gizola