empire-db-jakarta-faces/src/main/java/org/apache/empire/jakarta/components/TabPageTag.java [40:165]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class TabPageTag extends UIOutput implements NamingContainer
{
    // Logger
    private static final Logger log = LoggerFactory.getLogger(TabPageTag.class);
    
    public static final String  LABEL_FACET_NAME = "label";
    
    protected final TagEncodingHelper helper = TagEncodingHelperFactory.create(this, TagStyleClass.TAB_PAGE.get());

    private TabViewMode mode;
    
    @Override
    public String getFamily()
    {
        return UINamingContainer.COMPONENT_FAMILY; 
    }
    
    @Override
    public void setParent(UIComponent parent)
    {
        super.setParent(parent);
        // TabViewTag
        UIComponent tabView = parent;
        if (parent instanceof UIPanel)
            tabView = parent.getParent();
        if ((tabView instanceof TabViewTag) && !helper.hasComponentId())
        {   // We're inside a tabView
            String tabViewId = tabView.getId();
            if (tabViewId.startsWith(TagEncodingHelper.FACES_ID_PREFIX))
                tabViewId="tab";
            // Set tabId
            String tabId = StringUtils.concat(tabViewId, "_", String.valueOf(parent.getChildCount()-1));
            super.setId(tabId);
        }
    }
        
    @Override
    public void encodeBegin(FacesContext context)
        throws IOException
    {
        // call base
        super.encodeBegin(context);
        
        // TabViewMode 
        this.mode = detectTabViewMode();
        
        // render components
        ResponseWriter writer = context.getResponseWriter();
        if (mode.PAGE_WRAP_TAG!=null)
        {   // render page wrap tag
            writer.startElement(mode.PAGE_WRAP_TAG, this);
            writer.writeAttribute(InputControl.HTML_ATTR_ID, getClientId(), null);
        }
        // TabPage
        writer.startElement(mode.PAGE_TAG, this);
        if (mode.PAGE_WRAP_TAG==null)
        {   // no wrapper tag
            writer.writeAttribute(InputControl.HTML_ATTR_ID, getClientId(), null);
        }
        writer.writeAttribute(InputControl.HTML_ATTR_CLASS, this.helper.getSimpleStyleClass(), null);
    }

    @Override
    public boolean getRendersChildren()
    {
        return super.getRendersChildren();
    }
    
    @Override
    public void encodeChildren(FacesContext context)
        throws IOException
    {
        super.encodeChildren(context);
    }

    @Override
    public void encodeEnd(FacesContext context)
        throws IOException
    {
        // call base
        super.encodeEnd(context);
        // close tags
        ResponseWriter writer = context.getResponseWriter();
        writer.endElement(mode.PAGE_TAG);
        // wrapper tag?
        if (mode.PAGE_WRAP_TAG!=null)
            writer.endElement(mode.PAGE_WRAP_TAG);
    }

    public String getTabLabel()
    {
        /* 
         * for backwards compatibilty use "title" as label when label is null and no facet is defined
         */
        String label = helper.getTagAttributeString("label");
        if (label==null && getFacet(LABEL_FACET_NAME)==null) {
            label = helper.getTagAttributeString("title");
            if (label!=null)
                log.info("TabPage \"{}\": attribute \"title\" was provided instead of \"label\". This is deprecated and may be removed in the future!", label);
        }
        // the label 
        return label;
    }

    public String getTabTitle()
    {
        String label = helper.getTagAttributeString("label");
        if (label==null && getFacet(LABEL_FACET_NAME)==null)
            return null;
        // the title
        return helper.getTagAttributeString("title");
    }
    
    protected TabViewMode detectTabViewMode()
    {
        // walk upwards the parent component tree and return the first record component found (if any)
        UIComponent parent = this;
        while ((parent = parent.getParent()) != null)
        {
            if (parent instanceof TabViewTag)
            {   // found
                return ((TabViewTag) parent).getViewMode();
            }
        }
        log.warn("TabViewTag not found! Unable to detect TabViewMode.");
        return TabViewMode.GRID;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabPageTag.java [40:165]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class TabPageTag extends UIOutput implements NamingContainer
{
    // Logger
    private static final Logger log = LoggerFactory.getLogger(TabPageTag.class);
    
    public static final String  LABEL_FACET_NAME = "label";
    
    protected final TagEncodingHelper helper = TagEncodingHelperFactory.create(this, TagStyleClass.TAB_PAGE.get());

    private TabViewMode mode;
    
    @Override
    public String getFamily()
    {
        return UINamingContainer.COMPONENT_FAMILY; 
    }
    
    @Override
    public void setParent(UIComponent parent)
    {
        super.setParent(parent);
        // TabViewTag
        UIComponent tabView = parent;
        if (parent instanceof UIPanel)
            tabView = parent.getParent();
        if ((tabView instanceof TabViewTag) && !helper.hasComponentId())
        {   // We're inside a tabView
            String tabViewId = tabView.getId();
            if (tabViewId.startsWith(TagEncodingHelper.FACES_ID_PREFIX))
                tabViewId="tab";
            // Set tabId
            String tabId = StringUtils.concat(tabViewId, "_", String.valueOf(parent.getChildCount()-1));
            super.setId(tabId);
        }
    }
        
    @Override
    public void encodeBegin(FacesContext context)
        throws IOException
    {
        // call base
        super.encodeBegin(context);
        
        // TabViewMode 
        this.mode = detectTabViewMode();
        
        // render components
        ResponseWriter writer = context.getResponseWriter();
        if (mode.PAGE_WRAP_TAG!=null)
        {   // render page wrap tag
            writer.startElement(mode.PAGE_WRAP_TAG, this);
            writer.writeAttribute(InputControl.HTML_ATTR_ID, getClientId(), null);
        }
        // TabPage
        writer.startElement(mode.PAGE_TAG, this);
        if (mode.PAGE_WRAP_TAG==null)
        {   // no wrapper tag
            writer.writeAttribute(InputControl.HTML_ATTR_ID, getClientId(), null);
        }
        writer.writeAttribute(InputControl.HTML_ATTR_CLASS, this.helper.getSimpleStyleClass(), null);
    }

    @Override
    public boolean getRendersChildren()
    {
        return super.getRendersChildren();
    }
    
    @Override
    public void encodeChildren(FacesContext context)
        throws IOException
    {
        super.encodeChildren(context);
    }

    @Override
    public void encodeEnd(FacesContext context)
        throws IOException
    {
        // call base
        super.encodeEnd(context);
        // close tags
        ResponseWriter writer = context.getResponseWriter();
        writer.endElement(mode.PAGE_TAG);
        // wrapper tag?
        if (mode.PAGE_WRAP_TAG!=null)
            writer.endElement(mode.PAGE_WRAP_TAG);
    }

    public String getTabLabel()
    {
        /* 
         * for backwards compatibilty use "title" as label when label is null and no facet is defined
         */
        String label = helper.getTagAttributeString("label");
        if (label==null && getFacet(LABEL_FACET_NAME)==null) {
            label = helper.getTagAttributeString("title");
            if (label!=null)
                log.info("TabPage \"{}\": attribute \"title\" was provided instead of \"label\". This is deprecated and may be removed in the future!", label);
        }
        // the label 
        return label;
    }

    public String getTabTitle()
    {
        String label = helper.getTagAttributeString("label");
        if (label==null && getFacet(LABEL_FACET_NAME)==null)
            return null;
        // the title
        return helper.getTagAttributeString("title");
    }
    
    protected TabViewMode detectTabViewMode()
    {
        // walk upwards the parent component tree and return the first record component found (if any)
        UIComponent parent = this;
        while ((parent = parent.getParent()) != null)
        {
            if (parent instanceof TabViewTag)
            {   // found
                return ((TabViewTag) parent).getViewMode();
            }
        }
        log.warn("TabViewTag not found! Unable to detect TabViewMode.");
        return TabViewMode.GRID;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



