Oracle GlassFish Server 3.0.1 Add-On Component Development Guide

Adding Tabs to a Page

You can add a tab to an existing tab set, or you can create a tab set for your own page. One way to add a tab or tab set is to use an integration point of type org.glassfish.admingui:serverInstTab, which adds a tab to the tab set on the main GlassFish Server page of the Administration Console. You can also create sub-tabs. Once again, the parentId element specifies where to place the tab or tab set.


Example 3–4 Example Tab Integration Point

In the example, the following integration-point element adds a new tab on the main GlassFish Server page of the Administration Console:

        <integration-point 
            id="sampleTab"
            parentId="serverInstTabs"
            type="org.glassfish.admingui:serverInstTab" 
            priority="500" 
            content="sampleTab.jsf"
        />

This example specifies the following values:


Example 3–5 Example Tab Set Integration Points

The following integration-point elements add a new tab with two sub-tabs, also on the main GlassFish Server page of the Administration Console:

        <integration-point 
            id="sampleTabWithSubTab"
            parentId="serverInstTabs"
            type="org.glassfish.admingui:serverInstTab" 
            priority="300" 
            content="sampleTabWithSubTab.jsf"
        />
        
        <integration-point 
            id="sampleSubTab1" 
            parentId="sampleTabWithSubTab"
            type="org.glassfish.admingui:serverInstTab" 
            priority="300" 
            content="sampleSubTab1.jsf"
        />
        <integration-point 
            id="sampleSubTab2" 
            parentId="sampleTabWithSubTab"
            type="org.glassfish.admingui:serverInstTab" 
            priority="400" 
            content="sampleSubTab2.jsf"
        />

These examples specify the following values:

Creating JavaServer Faces Pages for Your Tabs

A JavaServer Faces page for a tab uses the tag sun:tab. This tag provides all the capabilities of the Project Woodstock tag webuijsf:tab.


Example 3–6 Example JavaServer Faces Page for a Tab

In the example, the sampleTab.jsf file has the following content:

<sun:tab id="sampleTab" immediate="true" text="Sample First Tab">
    <!command
        setSessionAttribute(key="serverInstTabs" value="sampleTab");
        gf.redirect(page="#{request.contextPath}/page/tabPage.jsf?name=Sample%20First%20Tab");
    />
</sun:tab>


Note –

In the actual file there are no line breaks in the gf.redirect value.


In your own JavaServer Faces pages, specify the attributes of this tag as follows:

id

A unique identifier for the tab, in this case sampleTab.

immediate

If set to true, event handling for this component should be handled immediately (in the Apply Request Values phase) rather than waiting until the Invoke Application phase.

text

The tab name that appears in the tab set.

The JSF page displays tab content differently from the way the page for a node displays node content. It invokes two handlers for the command event: setSessionAttribute and gf.redirect. The gf.redirect handler has the same effect for a tab that the url attribute has for a node. It navigates to a simple JavaServer Faces page called tabPage.jsf, in the src/main/resources/page/ directory, passing the text “Sample First Tab” to the page in a name parameter.

The sampleSubTab1.jsf and sampleSubTab2.jsf files are almost identical to sampleTab.jsf. The most important difference is that each sets the session attribute serverInstTabs to the base name of the JavaServer Faces file that corresponds to that tab:

setSessionAttribute(key="serverInstTabs" value="sampleTab");
setSessionAttribute(key="serverInstTabs" value="sampleSubTab1");
setSessionAttribute(key="serverInstTabs" value="sampleSubTab2");