001: package com.opensymphony.webwork.components;
002:
003: import com.opensymphony.xwork.util.OgnlValueStack;
004:
005: import javax.servlet.http.HttpServletRequest;
006: import javax.servlet.http.HttpServletResponse;
007: import java.util.ArrayList;
008: import java.util.List;
009:
010: /**
011: * <!-- START SNIPPET: javadoc -->
012: * The tabbedpanel widget is primarily an AJAX component, where each tab can either be local content or remote
013: * content (refreshed each time the user selects that tab).</p>
014: * <!-- END SNIPPET: javadoc -->
015: *
016: * <p/> <b>Examples</b>
017: * <p/>
018: * <!-- START SNIPPET: exdesc -->
019: * The following is an example of a tabbedpanel and panel tag utilizing local and remote content.<p/>
020: * <!-- END SNIPPET: exdesc -->
021: * <pre>
022: * <!-- START SNIPPET: example -->
023: * <ww:tabbedPanel id="test2" theme="simple" >
024: * <ww:panel id="left" tabName="left" theme="ajax">
025: * This is the left pane<br/>
026: * <ww:form >
027: * <ww:textfield name="tt" label="Test Text" /> <br/>
028: * <ww:textfield name="tt2" label="Test Text2" />
029: * </ww:form>
030: * </ww:panel>
031: * <ww:panel remote="true" href="/AjaxTest.action" id="ryh1" theme="ajax" tabName="remote one" />
032: * <ww:panel id="middle" tabName="middle" theme="ajax">
033: * middle tab<br/>
034: * <ww:form >
035: * <ww:textfield name="tt" label="Test Text44" /> <br/>
036: * <ww:textfield name="tt2" label="Test Text442" />
037: * </ww:form>
038: * </ww:panel>
039: * <ww:panel remote="true" href="/AjaxTest.action" id="ryh21" theme="ajax" tabName="remote right" />
040: * </ww:tabbedPanel>
041: * <!-- END SNIPPET: example -->
042: * </pre>
043: *
044: * <p/> <b>Additional Configuration</b>
045: *
046: * <!-- START SNIPPET: exdesc2 -->
047: * If you are looking for the "nifty" rounded corner look, there is additional configuration. This assumes
048: * that the background color of the tabs is white. If you are using a different color, please modify the
049: * parameter in the Rounded() method.<p/>
050: * <!-- END SNIPPET: exdesc2 -->
051: *
052: * <pre>
053: * <!-- START SNIPPET: example2 -->
054: * <link rel="stylesheet" type="text/css" href="<ww:url value="/webwork/tabs.css"/>">
055: * <link rel="stylesheet" type="text/css" href="<ww:url value="/webwork/niftycorners/niftyCorners.css"/>">
056: * <link rel="stylesheet" type="text/css" href="<ww:url value="/webwork/niftycorners/niftyPrint.css"/>" media="print">
057: * <script type="text/javascript" src="<ww:url value="/webwork/niftycorners/nifty.js"/>"></script>
058: * <script type="text/javascript">
059: * dojo.event.connect(window, "onload", function() {
060: * if (!NiftyCheck())
061: * return;
062: * Rounded("li.tab_selected", "top", "white", "transparent", "border #ffffffS");
063: * Rounded("li.tab_unselected", "top", "white", "transparent", "border #ffffffS");
064: * // "white" needs to be replaced with the background color
065: * });
066: * </script>
067: * <!-- END SNIPPET: example2 -->
068: * </pre>
069: *
070: * <b>Important:</b> Be sure to setup the page containing this tag to be Configured for AJAX
071: *
072: * @author Ian Roughley
073: * @author Rene Gielen
074: * @version $Revision: 2468 $
075: * @since 2.2
076: *
077: * @see Panel
078: *
079: * @ww.tag name="tabbedPanel" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.TabbedPanelTag"
080: * description="Render a tabbedPanel widget."
081: */
082: public class TabbedPanel extends ClosingUIBean {
083: public static final String TEMPLATE = "tabbedpanel";
084: public static final String TEMPLATE_CLOSE = "tabbedpanel-close";
085: final private static String COMPONENT_NAME = TabbedPanel.class
086: .getName();
087:
088: protected List tabs = new ArrayList();
089:
090: public TabbedPanel(OgnlValueStack stack,
091: HttpServletRequest request, HttpServletResponse response) {
092: super (stack, request, response);
093: }
094:
095: /**
096: * Add a new panel to be rendered.
097: *
098: * @param pane a new panel to be rendered
099: */
100: public void addTab(Panel pane) {
101: tabs.add(pane);
102: }
103:
104: /**
105: * Get the list of panel tabs for this tab panel.
106: *
107: * @return the list of panel tabs for this tab panel
108: */
109: public List getTabs() {
110: return tabs;
111: }
112:
113: public String getTopicName() {
114: return "topic_tab_" + id + "_selected";
115: }
116:
117: protected void evaluateExtraParams() {
118: super .evaluateExtraParams();
119:
120: addParameter("topicName", "topic_tab_" + id + "_selected");
121: addParameter("tabs", tabs);
122:
123: }
124:
125: public String getDefaultOpenTemplate() {
126: return TEMPLATE;
127: }
128:
129: protected String getDefaultTemplate() {
130: return TEMPLATE_CLOSE;
131: }
132:
133: public String getComponentName() {
134: return COMPONENT_NAME;
135: }
136:
137: /**
138: * The id to assign to the component.
139: * @ww.tagattribute required="true" type="String"
140: */
141: public void setId(String id) {
142: // This is required to override tld generation attributes to required=true
143: super.setId(id);
144: }
145: }
|