001: package com.opensymphony.webwork.components;
002:
003: import com.opensymphony.xwork.util.OgnlValueStack;
004: import org.apache.commons.logging.Log;
005: import org.apache.commons.logging.LogFactory;
006:
007: import javax.servlet.http.HttpServletRequest;
008: import javax.servlet.http.HttpServletResponse;
009: import java.io.Writer;
010:
011: /**
012: * <!-- START SNIPPET: javadoc -->
013: * Render a panel for tabbedPanel.</p>
014: * <!-- END SNIPPET: javadoc -->
015: *
016: * <p/> <b>Examples</b>
017: * See the example in {@link TabbedPanel}.
018: * <p/>
019: *
020: * @author Ian Roughley
021: * @author Patrick Lightbody
022: * @author Rene Gielen
023: * @version $Revision: 2468 $
024: * @since 2.2
025: *
026: * @see TabbedPanel
027: *
028: * @ww.tag name="panel" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.PanelTag"
029: * description="Render a panel for tabbedPanel"
030: */
031: public class Panel extends Div {
032: private static final Log LOG = LogFactory.getLog(Panel.class);
033:
034: public static final String TEMPLATE = "tab";
035: public static final String TEMPLATE_CLOSE = "tab-close";
036: public static final String COMPONENT_NAME = Panel.class.getName();
037:
038: protected String tabName;
039: protected String subscribeTopicName;
040: protected String remote;
041:
042: public Panel(OgnlValueStack stack, HttpServletRequest request,
043: HttpServletResponse response) {
044: super (stack, request, response);
045: }
046:
047: public String getDefaultOpenTemplate() {
048: return TEMPLATE;
049: }
050:
051: protected String getDefaultTemplate() {
052: return TEMPLATE_CLOSE;
053: }
054:
055: public boolean end(Writer writer, String body) {
056: TabbedPanel tabbedPanel = ((TabbedPanel) findAncestor(TabbedPanel.class));
057: subscribeTopicName = tabbedPanel.getTopicName();
058: tabbedPanel.addTab(this );
059:
060: return super .end(writer, body);
061: }
062:
063: public void evaluateExtraParams() {
064: super .evaluateExtraParams();
065:
066: if (tabName != null) {
067: addParameter("tabName", findString(tabName));
068: }
069:
070: if (subscribeTopicName != null) {
071: addParameter("subscribeTopicName", subscribeTopicName);
072: }
073:
074: if (remote != null && "true".equalsIgnoreCase(remote)) {
075: addParameter("remote", "true");
076: } else {
077: addParameter("remote", "false");
078: }
079: }
080:
081: public String getTabName() {
082: return findString(tabName);
083: }
084:
085: public String getComponentName() {
086: return COMPONENT_NAME;
087: }
088:
089: /**
090: * The text of the tab to display in the header tab list
091: * @ww.tagattribute required="true"
092: */
093: public void setTabName(String tabName) {
094: this .tabName = tabName;
095: }
096:
097: /**
098: * Set subscribeTopicName attribute
099: * @ww.tagattribute required="false"
100: */
101: public void setSubscribeTopicName(String subscribeTopicName) {
102: this .subscribeTopicName = subscribeTopicName;
103: }
104:
105: /**
106: * determines whether this is a remote panel (ajax) or a local panel (content loaded into visible/hidden containers)
107: * @ww.tagattribute required="false" type="Boolean" default="false"
108: */
109: public void setRemote(String remote) {
110: this.remote = remote;
111: }
112: }
|