|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.click.control.AbstractControl
org.apache.click.control.AbstractContainer
org.apache.click.control.Panel
org.apache.click.extras.panel.TabbedPanel
public class TabbedPanel
Provides a tabbed panel with multiple sub-panels in 'tabs'.
This panel comes with a default template that will render the panels in CSS customizable table tags. A listenersetTabListener(ActionListener) may be attached
(similar to the control listeners) that will be called on tab switch.
This could be useful to load (or reload) model related information for which
ever panel is selected by the user.
The classpath TabbedPanel.htm template is illustrated below:
<div id='$this.id'> <table class="tp_tab"> <tr class="tp_tab"> #foreach ($panel in $this.panels) #if ($panel.id == $this.activePanel.id) <td class="tp_tab_on"> $panel.label </td> <td class="tp_tab_space"></td> #else <td class="tp_tab_off"> <a href="$this.link.getHref($panel.name)" id="$panel.id" class="tp_tab_link">$panel.label</a> </td> <td class="tp_tab_space"></td> #end #end </tr> </table> <table class="tp_content"> <tr class="tp_content"> <td class="tp_content"> $this.activePanel </td> </tr> </table> </div>Also, as shown above, there are a number of CSS attributes that allow some customization of the output. These CSS attributes are defined in the auto deployed TabbedPanel.css. The TabbedPanel CSS attributes are:
table.tp_tab { border-collapse: collapse; } tr.tp_tab { } td.tp_tab_on { background: #336699; color: #ffffff; border-left: 1px solid #336699; border-top: 1px solid #336699; border-right: 1px solid #336699; padding: 5px; } td.tp_tab_off { background: #cccccc; color: #000000; border-left: 1px solid #336699; border-top: 1px solid #336699; border-right: 1px solid #336699; padding: 5px; } table.tp_content { border: 1px solid #336699; } tr.tp_content { } td.tp_content { background: #efefef; }
<html> <head> $headElements </head> <body> $panel $jsElements </body> </html>
| Field Summary | |
|---|---|
protected Panel |
activePanel
The currently active panel. |
protected ActionLink |
tabLink
The tab switch action link. |
| Fields inherited from class org.apache.click.control.Panel |
|---|
active, disabled, id, label, model, panels, template |
| Fields inherited from class org.apache.click.control.AbstractContainer |
|---|
controlMap, controls |
| Fields inherited from class org.apache.click.control.AbstractControl |
|---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
| Fields inherited from interface org.apache.click.Control |
|---|
CONTROL_MESSAGES |
| Constructor Summary | |
|---|---|
TabbedPanel()
Create a TabbedPanel with no name or template defined. |
|
TabbedPanel(String name)
Create a TabbedPanel with the given name. |
|
TabbedPanel(String name,
String template)
Create a Panel with the given name and template path. |
|
TabbedPanel(String name,
String template,
String id)
Create a TabbedPanel with the given name, id attribute and template path. |
|
| Method Summary | |
|---|---|
Panel |
getActivePanel()
Return the currently active panel. |
List<Element> |
getHeadElements()
Return the TabbedPanel HTML HEAD elements for the following resource: click/TabbedPanel.css Additionally all controls HEAD elements are
also returned. |
Object |
getState()
Return the TabbedPanel state. |
ActionLink |
getTabLink()
Return the tab switching action link. |
String |
getWidth()
Return the tabbed panel content table HTML width attribute if defined. |
protected void |
initActivePanel()
Sets the active panel based on one of the following: If tabPanelIndex request parameter is present, this value will be used to specify the active panel. |
Control |
insert(Control control,
int index)
Add the control to the panel. |
void |
onInit()
Initialize the child controls contained in the panel. |
boolean |
onProcess()
Process the request and invoke the onProcess() method of any child controls. |
void |
onRender()
Perform any pre rendering logic and invoke the onRender() method of any child controls. |
void |
removeState(Context context)
Remove the TabbedPanel state from the session for the given request context. |
Control |
replace(Control currentControl,
Control newControl)
Replace the current control with the new control. |
void |
restoreState(Context context)
Restore the TabbedPanel state from the session for the given request context. |
void |
saveState(Context context)
Save the TabbedPanel state to the session for the given request context. |
void |
setActionListener(ActionListener actionListener)
This method will delegate to setTabListener(org.apache.click.ActionListener). |
void |
setActivePanel(Panel panel)
Set the currently active panel to the given panel. |
void |
setListener(Object listener,
String listenerMethod)
This method will delegate to setTabListener(java.lang.Object, java.lang.String). |
void |
setName(String name)
|
void |
setState(Object state)
Set the TabbedPanel state. |
void |
setTabListener(ActionListener actionListener)
Set the tab switch listener. |
void |
setTabListener(Object listener,
String listenerMethod)
|
void |
setWidth(String width)
Set the tabbed panel content table HTML width attribute if defined. |
| Methods inherited from class org.apache.click.control.Panel |
|---|
addControl, addModel, createTemplateModel, getId, getLabel, getModel, getPanels, getTemplate, isActive, isDisabled, remove, removeControl, render, setActive, setDisabled, setId, setLabel, setTemplate |
| Methods inherited from class org.apache.click.control.AbstractContainer |
|---|
add, contains, getControl, getControlMap, getControls, getControlSizeEst, hasControls, onDestroy, renderChildren, renderContent, renderTagEnd, toString |
| Methods inherited from class org.apache.click.control.AbstractControl |
|---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, removeBehavior, removeStyleClass, renderTagBegin, setAttribute, setParent, setStyle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.click.Control |
|---|
getBehaviors, getContext, getMessages, getName, getParent, hasBehaviors, isAjaxTarget, onDeploy, setParent |
| Field Detail |
|---|
protected Panel activePanel
protected ActionLink tabLink
| Constructor Detail |
|---|
public TabbedPanel(String name)
name - the name of the panel
public TabbedPanel(String name,
String template)
name - the name of the paneltemplate - the Velocity template
public TabbedPanel(String name,
String template,
String id)
name - the name of the paneltemplate - the Velocity template pathid - the id HTML attribute valuepublic TabbedPanel()
| Method Detail |
|---|
public Control insert(Control control,
int index)
insert in interface Containerinsert in class Panelcontrol - the control to add to the container
IllegalArgumentException - if the control is null, if the name
of the control is not defined or the container already contains a
control with the same nameAbstractContainer.add(org.apache.click.Control)
public Control replace(Control currentControl,
Control newControl)
replace in interface Containerreplace in class PanelcurrentControl - the current control container in the panelnewControl - the control to replace the current control
IllegalArgumentException - if the currentControl or newControl is
null
IllegalStateException - if the currentControl is not contained in
the panelpublic Panel getActivePanel()
public void setActivePanel(Panel panel)
active
property will be set to true, while the previous active panel will be
deactivated.
panel - the panel to set as the current active panelpublic List<Element> getHeadElements()
controls HEAD elements are
also returned.
getHeadElements in interface ControlgetHeadElements in class AbstractControlControl.getHeadElements()
public void setListener(Object listener,
String listenerMethod)
setTabListener(java.lang.Object, java.lang.String).
setListener in interface ControlsetListener in class AbstractControllistener - the listener object with the named method to invokelistenerMethod - the name of the method to invokepublic void setName(String name)
setName in interface ControlsetName in class AbstractControlname - of the control
IllegalArgumentException - if the name is nullControl.setName(String)
public void setTabListener(Object listener,
String listenerMethod)
listener - the listener object with the named method to invokelistenerMethod - the name of the method to invokesetTabListener(ActionListener)public void setActionListener(ActionListener actionListener)
setTabListener(org.apache.click.ActionListener).
setActionListener in class AbstractControlactionListener - the control's action listenerpublic Object getState()
activePanel's nametabLink parameters
getState in interface Statefulpublic void setState(Object state)
setState in interface Statefulstate - the tabbedPanel state to setpublic void setTabListener(ActionListener actionListener)
public boolean onClick() { System.out.println("onClick called"); return true; }
actionListener - the control's action listenerpublic ActionLink getTabLink()
public String getWidth()
public void setWidth(String width)
width - the tabbed panel content table HTML width attributepublic void onInit()
onInit in interface ControlonInit in class PanelControl.onInit()public boolean onProcess()
onProcess in interface ControlonProcess in class PanelControl.onProcess()public void onRender()
onRender in interface ControlonRender in class PanelControl.onRender()public void removeState(Context context)
context - the request contextsaveState(org.apache.click.Context),
restoreState(org.apache.click.Context)public void restoreState(Context context)
setState(java.lang.Object) to set the
panel's restored state.
context - the request contextsaveState(org.apache.click.Context),
removeState(org.apache.click.Context)public void saveState(Context context)
getState() to retrieve the panel's
state to save.
context - the request contextrestoreState(org.apache.click.Context),
removeState(org.apache.click.Context)protected void initActivePanel()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||