7 Replies Latest reply on Jun 28, 2010 7:26 AM by ilya_shaikovsky

    Custom Facelets tag ignored inside a4j:repeat

    xck3001

      Hi,

       

      I have some problems using a custom Facelets tag (extending UIComponentBase) inside a a4j:repeat loop. Outside of the loop, everything works fine. Inside the loop, the tag is ignored and no content rendered inside the page.

      While debugging, I see that the tag's encodeAll() method is not triggered at all, so I think I am missing something.

       

      Does my tag have to extend some Ajax4JSF class in order to work inside the A4J loop?

       

      We use JSF2 with RF 3.3.3.Final .

       

      Thanks in advance,

       

      Matthias

        • 1. Re: Custom Facelets tag ignored inside a4j:repeat
          ilya_shaikovsky
          Does my tag have to extend some Ajax4JSF class in order to work inside the A4J loop?

          No. a4j:repeat - could be used for f: and h: and myfaces tags for example and them not depends on any a4j classes.

           

          So need to look more to your impl.

          • 2. Re: Custom Facelets tag ignored inside a4j:repeat
            xck3001

            We noted that is does not depend on any attribute/parameter that I pass inside the tag, because even without any attribute the encodeAll() is not triggered.

             

            I will try to create a very small piece of an example to simplify the examination.

            • 3. Re: Custom Facelets tag ignored inside a4j:repeat
              xck3001

              BTW, in the "real-world" page we use dozens of h:outputText inside the a4j:repeat, so this indeed works. Maybe my custom component is just something missing.

              I made an reduced example which also reproduces this error:

               

              Custom component:

               

              @FacesComponent("testComponent")
              public class TestComponent extends UIComponentBase
              {
              
                  @Override
                  public String getFamily()
                  {
                      return null;
                  }
              
                  @Override
                  public void encodeAll(FacesContext ctx) throws IOException
                  {
                      ctx.getResponseWriter().write("test");
                  }
              
              }
              

               

               

              Taglib:

               

              <tag>
                      <tag-name>test</tag-name>
                      <component>
                          <component-type>
                              testComponent
                          </component-type>
                      </component>
                  </tag>
              

               

              Facelet:

              <f:view contentType="text/html">
                      <head>
                      
                      </head>
                      <body>        
                          <a4j:repeat value="#{testBean.items}" var="item">
                              #{item} <test:test />
                              <br/>
                          </a4j:repeat>
                          Output below list:<test:test />                
                      </body>
                  </f:view>
              

               

              Managed bean, just created for using inside a4j:repeat loop:

              @ManagedBean
              public class TestBean
              {
              
                  private List<String> items;
              
                  @PostConstruct
                  public void init()
                  {
                      List<String> items = new ArrayList<String>();
                      items.add("item1");
                      items.add("item2");
                      items.add("item3");
                      this.items = items;
              
                  }
              
                  public List<String> getItems()
                  {
                      return items;
                  }
              }
              

               

               

              This will generate the following output (note that the tag outside of the a4j:repeat is rendered correctly):

               

              item1                     
              item2                     
              item3                     
              Output below list:test
              
              • 4. Re: Custom Facelets tag ignored inside a4j:repeat
                ilya_shaikovsky

                probably some problems with namespace definition or taglib declaration. In order to check follow simple steps:

                • open test page
                • call "show page HTML source" from browser menu
                • verify if there are

                     <test:test />

                     tags in generated HTML. If them present - tag was just not identified.

                • 5. Re: Custom Facelets tag ignored inside a4j:repeat
                  xck3001

                  The tag is resolved, because you can see the "test" output at the last line. Also, here is the HTML source:

                   

                            <body>
                                      item1
                                      <br />
                                      item2
                                      <br />
                  
                                      item3
                                      <br />
                                 Output below list:test                    
                            </body>
                  
                  
                  • 6. Re: Custom Facelets tag ignored inside a4j:repeat
                    xck3001

                    Can I provide any additional information about the problem?

                    • 7. Re: Custom Facelets tag ignored inside a4j:repeat
                      ilya_shaikovsky

                      sample in war with java sources would be great.