|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.faces.component.UIComponent javax.faces.component.UIComponentBase javax.faces.component.UINamingContainer com.sun.rave.web.ui.component.TabSetBase
The TabSet renders a set of Tab children. It keeps track of the currently selected child Tab as well as applying any specified ActionListener.
The TabSet can currently be used in one of two ways: via a component binding to a TabSet and group of child Tab components (defined in a backing bean); or by specifying the TabSet and child Tabs directly in your JSP.
Examples of both are shown in the Examples section below. It is anticipated that the component binding method will be more common as this allows a single set of Tabs to be easily shared among many pages. In either case, the initial selection for the TabSet component can be specified using the "selected" property. Note that if an ActionListener is applied to the TabSet component, it adds the specified ActionListener to each of its child Tab components action listener lists.
None at this time
None at this time
Example 1: Define the TabSet via a component binding
One way a TabSet component can be specified is via a JSF component binding to an instance
defined in a backing bean. The contents of the JSP in this case will simply be something
like:
<ui:tabSet binding="#{TabSetBean.sportsTabSet}" />
The code in the corresponding backing bean instance would look something like:
import java.util.List;
import java.lang.Class;
import javax.faces.FactoryFinder;
import javax.faces.el.MethodBinding;
import javax.faces.event.ActionEvent;
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
import com.sun.rave.web.ui.component.Tab;
import com.sun.rave.web.ui.component.TabSet;
public class TabSetBean {
private TabSet sportsTabSet = null;
// Creates a new instance of TabSetBean //
public TabSetBean() {
sportsTabSet = new TabSet();
List kids = sportsTabSet.getChildren();
Tab level1Tab = new Tab("Baseball");
level1Tab.setId("Baseball");
Tab level2Tab = addTab(level1Tab,
"National");
addTab(level2Tab, "Mets");
addTab(level2Tab, "Pirates");
addTab(level2Tab, "Cubs");
level2Tab = addTab(level1Tab,
"American");
addTab(level2Tab, "Yankees");
addTab(level2Tab, "Tigers");
addTab(level2Tab, "Mariners");
level2Tab = addTab(level1Tab, "AAA");
addTab(level2Tab, "Spinners");
addTab(level2Tab, "Renegades");
addTab(level2Tab, "Clippers");
kids.add(level1Tab);
level1Tab = new Tab("Football");
level1Tab.setId("Football");
level2Tab = addTab(level1Tab, "NFC");
addTab(level2Tab, "Giants");
addTab(level2Tab, "Bears");
addTab(level2Tab, "Falcons");
level2Tab = addTab(level1Tab, "AFC");
addTab(level2Tab, "Jets");
addTab(level2Tab, "Patriots");
addTab(level2Tab, "Colts");
level2Tab = addTab(level1Tab,
"College");
addTab(level2Tab, "Wolverines");
addTab(level2Tab, "Hurricanes");
addTab(level2Tab, "Buckeyes");
kids.add(level1Tab);
Class[] args = new Class[] { ActionEvent.class
};
MethodBinding binding =
createBinding("#{TabSetBean.tabClicked}", args);
sportsTabSet.setActionListener(binding);
sportsTabSet.setSelected("Jets");
}
private MethodBinding createBinding(String expr, Class[] args) {
ApplicationFactory factory =
(ApplicationFactory)
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
Application app = factory.getApplication();
return app.createMethodBinding(expr, args);
}
private Tab addTab(Tab parent, String newTabLabel) {
Tab tab = new Tab(newTabLabel);
tab.setId(newTabLabel);
parent.getChildren().add(tab);
return tab;
}
public void tabClicked(ActionEvent event) {
String clickedTabId = event.getComponent().getId():
String selectedTabId = sportsTabSet.getSelected();
// ... do sometehing based upon the clicked or
selected tab id ...
}
public TabSet getSportsTabSet() {
return sportsTabSet;
}
public void setSportsTabSet(TabSet tabs) {
sportsTabSet = tabs;
}
}
Example 2: Define the TabSet in your JSP
A tabSet can also be defined directly in your JSP. The following example defines a set of tabs with
three level one tabs (labelled "One", "Two" and "Three"). Each
level one tab also has two level two tab childeren (labelled "XxxA" and
"XxxB" where X is the top level tab number. The initially selected Tab for this
TabSet will be "TwoA".
<ui:tabSet selected="TwoA">
<ui:tab id="One" text="One">
<ui:tab id="OneA" text="One
A" />
<ui:tab id="OneB" text="One
B" />
</ui:tab>
<ui:tab id="Two" text="Two">
<ui:tab id="TwoA" text="Two
A" />
<ui:tab id="TwoB" text="Two
B" />
</ui:tab>
<ui:tab id="Three" text="Three">
<ui:tab id="ThreeA"
text="Three A" />
<ui:tab id="ThreeB"
text="Three B" />
</ui:tab>
</ui:tabSet>
Auto-generated component class. Do NOT modify; all changes will be lost!
Field Summary |
Fields inherited from class javax.faces.component.UINamingContainer |
COMPONENT_FAMILY, COMPONENT_TYPE |
Fields inherited from interface javax.faces.component.NamingContainer |
SEPARATOR_CHAR |
Constructor Summary | |
TabSetBase()
Construct a new TabSetBase . |
Method Summary | |
javax.faces.el.MethodBinding |
getActionListener()
Use the actionListener attribute to cause the hyperlink to fire an event. |
java.lang.String |
getFamily()
Return the family for this component. |
java.lang.String |
getSelected()
The id of the selected tab |
java.lang.String |
getStyle()
CSS style(s) to be applied when this component is rendered. |
java.lang.String |
getStyleClass()
CSS style class(es) to be applied when this component is rendered. |
boolean |
isLite()
Render a style of tabs that isn't so visually "heavy". |
boolean |
isMini()
Specify "true" if this TabSet should have the mini style |
boolean |
isVisible()
Use the visible attribute to indicate whether the component should be viewable by the user in the rendered HTML page. |
void |
restoreState(javax.faces.context.FacesContext _context,
java.lang.Object _state)
Restore the state of this component. |
java.lang.Object |
saveState(javax.faces.context.FacesContext _context)
Save the state of this component. |
void |
setActionListener(javax.faces.el.MethodBinding actionListener)
Use the actionListener attribute to cause the hyperlink to fire an event. |
void |
setLite(boolean lite)
Render a style of tabs that isn't so visually "heavy". |
void |
setMini(boolean mini)
Specify "true" if this TabSet should have the mini style |
void |
setSelected(java.lang.String selected)
The id of the selected tab |
void |
setStyle(java.lang.String style)
CSS style(s) to be applied when this component is rendered. |
void |
setStyleClass(java.lang.String styleClass)
CSS style class(es) to be applied when this component is rendered. |
void |
setVisible(boolean visible)
Use the visible attribute to indicate whether the component should be viewable by the user in the rendered HTML page. |
Methods inherited from class javax.faces.component.UIComponentBase |
addFacesListener, broadcast, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TabSetBase()
Construct a new TabSetBase
.
Method Detail |
public java.lang.String getFamily()
Return the family for this component.
public javax.faces.el.MethodBinding getActionListener()
Use the actionListener attribute to cause the hyperlink to fire an event. The value must be an EL expression and it must evaluate to the name of a public method that takes an ActionEvent parameter and returns void.
public void setActionListener(javax.faces.el.MethodBinding actionListener)
Use the actionListener attribute to cause the hyperlink to fire an event. The value must be an EL expression and it must evaluate to the name of a public method that takes an ActionEvent parameter and returns void.
getActionListener()
public boolean isLite()
Render a style of tabs that isn't so visually "heavy". This property must be used in conjunction with the "mini" property set to true in order to work.
public void setLite(boolean lite)
Render a style of tabs that isn't so visually "heavy". This property must be used in conjunction with the "mini" property set to true in order to work.
isLite()
public boolean isMini()
Specify "true" if this TabSet should have the mini style
public void setMini(boolean mini)
Specify "true" if this TabSet should have the mini style
isMini()
public java.lang.String getSelected()
The id of the selected tab
public void setSelected(java.lang.String selected)
The id of the selected tab
getSelected()
public java.lang.String getStyle()
CSS style(s) to be applied when this component is rendered.
public void setStyle(java.lang.String style)
CSS style(s) to be applied when this component is rendered.
getStyle()
public java.lang.String getStyleClass()
CSS style class(es) to be applied when this component is rendered.
public void setStyleClass(java.lang.String styleClass)
CSS style class(es) to be applied when this component is rendered.
getStyleClass()
public boolean isVisible()
Use the visible attribute to indicate whether the component should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default, visible is set to true, so HTML for the component HTML is included and visible to the user. If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.
public void setVisible(boolean visible)
Use the visible attribute to indicate whether the component should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default, visible is set to true, so HTML for the component HTML is included and visible to the user. If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.
isVisible()
public void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
Restore the state of this component.
public java.lang.Object saveState(javax.faces.context.FacesContext _context)
Save the state of this component.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |