Sun GlassFish Enterprise Server v3 Prelude Add-On Component Development Guide

Creating JavaServer Faces Pages for Your Tabs

A JavaServer Faces page for a tab uses the JSFTemplating 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");
        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 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 JSFTemplating 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 redirect. The redirect handler has the same effect for a tab that the url attribute has for a node. It invokes 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");