How to make a grid of JSF composite component?

后端 未结 2 1242
感动是毒
感动是毒 2020-11-22 15:27

I have lot\'s of outputLabel and inputText pairs in panelGrids


  
          


        
2条回答
  •  [愿得一人]
    2020-11-22 16:00

    There should have been a switch in panelGrid to render composite components separately. I have a solution for this. You can have separate composite components instead of clubbing them together. In each composite component you can use ui:fragments to demarcate the components you want to separately fall under different columns. Following is extract from my inputText.xhtml:

    
    
    
        
        
        
        
        
        
    
    
    
    
    
        
            
            
            
        
        
            
            
        
    
    
    
    

    Now this will not going to align in the form which is inside the panelGrid:

    
    
    
    
    

    So i have extended the GroupRenderer's encodeRecursive method, to add after label and a before field:

    // inside my extended renderer
    protected void encodeRecursive(FacesContext context, UIComponent component)
                throws IOException {
    
            // Render our children recursively
            if (component instanceof ComponentRef
                    && component.getId().equals("field")) {
                context.getResponseWriter().startElement("td", component);
            }
    
            super.encodeRecursive(context, component);
            if (component instanceof ComponentRef
                    && component.getId().equals("label")) {
                context.getResponseWriter().endElement("td");
            }
        }
    

提交回复
热议问题