You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by do...@apache.org on 2005/10/25 18:54:47 UTC

svn commit: r328413 - in /beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags: ajax/ behaviors/ core/ core/services/ divpanel/ jsptags/ util/

Author: dolander
Date: Tue Oct 25 09:54:34 2005
New Revision: 328413

URL: http://svn.apache.org/viewcvs?rev=328413&view=rev
Log:
This checkin moves the DivPanel into the SimpleTags.  I'm doing this
to begin working on AJAX.  The DivPanel is one of he AJAX enabled tags.

At this point, this will not work because the Request Interceptor is not wired up.


Added:
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/ajax/
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/ajax/AbstractClientRequestInterceptor.java   (with props)
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivPanelBehavior.java   (with props)
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivSectionBehavior.java   (with props)
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelCRI.java   (with props)
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelState.java   (with props)
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivPanel.java   (with props)
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivSection.java   (with props)
Modified:
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBaseBehavior.java
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/Behavior.java
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/TagContext.java
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/services/BehaviorStack.java
    beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/util/ContextUtils.java

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/ajax/AbstractClientRequestInterceptor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/ajax/AbstractClientRequestInterceptor.java?rev=328413&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/ajax/AbstractClientRequestInterceptor.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/ajax/AbstractClientRequestInterceptor.java Tue Oct 25 09:54:34 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.simpletags.ajax;
+
+import org.apache.beehive.netui.pageflow.interceptor.request.RequestInterceptor;
+
+abstract public class AbstractClientRequestInterceptor extends RequestInterceptor
+{
+    protected String getCommand(String cmd, String ctxtPath)
+    {
+        // catch any runtime errors here and return.
+        try {
+            cmd = cmd.substring(ctxtPath.length() + 1);
+            int idx = cmd.lastIndexOf('.');
+            if (idx != -1) {
+                cmd = cmd.substring(0, idx);
+            }
+        }
+        catch (RuntimeException e) {
+            System.err.println("Runtime Error creating XmlRequestServlet Command:" + e.getClass().getName());
+            return null;
+        }
+        return cmd;
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/ajax/AbstractClientRequestInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivPanelBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivPanelBehavior.java?rev=328413&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivPanelBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivPanelBehavior.java Tue Oct 25 09:54:34 2005
@@ -0,0 +1,246 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.pageflow.requeststate.NameService;
+import org.apache.beehive.netui.script.ExpressionUpdateException;
+import org.apache.beehive.netui.script.IllegalExpressionException;
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.core.Behavior;
+import org.apache.beehive.netui.simpletags.core.ExpressionHandling;
+import org.apache.beehive.netui.simpletags.core.TagContext;
+import org.apache.beehive.netui.simpletags.core.services.IdScopeStack;
+import org.apache.beehive.netui.simpletags.core.services.ScriptReporter;
+import org.apache.beehive.netui.simpletags.divpanel.DivPanelState;
+import org.apache.beehive.netui.simpletags.javascript.CoreScriptFeature;
+import org.apache.beehive.netui.simpletags.rendering.AbstractHtmlState;
+import org.apache.beehive.netui.simpletags.rendering.DivTag;
+import org.apache.beehive.netui.simpletags.rendering.TagRenderingBase;
+import org.apache.beehive.netui.simpletags.util.ContextUtils;
+import org.apache.beehive.netui.util.Bundle;
+
+import javax.servlet.jsp.el.VariableResolver;
+
+public class DivPanelBehavior extends Behavior
+{
+    private String _tagId;
+    private String _firstPage;
+    private String _dataSource = null;       // The name of the tree.
+    private VariableResolver _vr;
+    private DivPanelState _state = null;
+
+    private DivTag.State _divState = new DivTag.State();
+
+    public static final String DIVPANEL_JAVASCRIPT_ATTR = "netui-div-panel";
+    public static final String DIVPANEL_FIRST_PAGE = "netui-div-panel-first";
+
+    public static final String DIVPANEL_DIV_ID = "netui_divpanel_";
+
+
+    //@todo: why?
+    //public static String getCurrentPage(ServletRequest req, String tagId)
+    //{
+    //    String reqId = DIVPANEL_DIV_ID + tagId;
+    //    return req.getParameter(reqId);
+    //}
+
+    /**
+     * Returns the name of the Tag.  This is used to
+     * identify the type of tag reporting errors.
+     * @return a constant string representing the name of the tag.
+     */
+    public String getTagName()
+    {
+        return "DivPanel";
+    }
+
+    /**
+     * Sets an expression which indentifies the DivPanelState which will store the state of the
+     * DivPanelBehavior between posts to the server.
+     * @param dataSource the tree attribute name
+     * @jsptagref.attributedescription An expression which identifies which DivPanelState object will store state between posts to the server.
+     * @jsptagref.databindable true
+     * @jsptagref.attributesyntaxvalue <i>expression</i>
+     * @netui:attribute description="Sets an expression which indentifies the DivPanelState storing the state of the
+     * DivPanelBehavior between posts."
+     */
+    public void setDataSource(String dataSource)
+    {
+        _dataSource = dataSource;
+    }
+
+    /**
+     * This method will set the variable resolver.  This required for all DataSource Behaviors in order
+     * to resolve the expression.
+     * @param vr The variable resolver used for this page...
+     */
+    public void setVariableResolver(VariableResolver vr)
+    {
+        _vr = vr;
+    }
+
+    /**
+     * Set the ID of the tag.
+     * @param tagId the tagId.
+     * @jsptagref.attributedescription Set the ID of the &lt;div> tag
+     * @jsptagref.databindable true
+     * @jsptagref.attributesyntaxvalue <i>string_or_expression</i>
+     * @netui:attribute required="true" rtexprvalue="true"
+     * description="Set the ID of the tag."
+     */
+    public void setTagId(String tagId)
+    {
+        _tagId = tagId;
+    }
+
+    /**
+     * Set the name of the first page to display.
+     * @param firstPage the name of the first page.
+     * @jsptagref.attributedescription Set the name of the first page to display.
+     * @jsptagref.databindable true
+     * @jsptagref.attributesyntaxvalue <i>string_or_expression</i>
+     * @netui:attribute rtexprvalue="true"
+     * description="Set the name of the first page to display."
+     */
+    public void setFirstPage(String firstPage)
+    {
+        _firstPage = firstPage;
+    }
+
+    //******************* Lifecycle Methods ************************************
+
+    /**
+     * This method will push the Behavior on the behavior stack.  All overrides of
+     * this method should call this method so that the stack is maintained correctly.
+     */
+    public void preRender()
+    {
+        // if there was a dataSource defined we need to get it based upon the expression
+        // if the variable comes back null, we then create a DivPanelState and set it back
+        // to the property referred to by the expression.
+
+        if (_dataSource != null) {
+            ExpressionHandling _expr;
+            _expr = new ExpressionHandling(this, _vr);
+            try {
+                _state = getState(_expr);
+            }
+            catch (IllegalExpressionException iee) {
+                String s = Bundle.getString("TreeRootError", new Object[]{_dataSource, iee.getMessage()});
+                registerTagError(s, null);
+                return;
+            }
+            if (hasErrors())
+                return;
+
+            // if we got here and the state is null then create a new divPanel, and push it back on
+            // the expression
+            if (_state == null) {
+                try {
+                    _state = new DivPanelState();
+                    String datasource = "{" + _dataSource + "}";
+                    _expr.updateExpression(datasource, _state);
+                }
+                catch (ExpressionUpdateException e) {
+                    String s = Bundle.getString("Tags_UnableToWriteTree", new Object[]{_dataSource, e.getMessage()});
+                    registerTagError(s, null);
+                    return;
+                }
+
+                if (hasErrors())
+                    return;
+
+                // name the divPanel so we can post state back to this state object.
+                NameService ns = ContextUtils.getNameService();
+                ns.nameObject("DivPanelBehavior", _state);
+                ns.put(_state);
+            }
+        }
+
+    }
+
+    /**
+     * This method will render the start tag for the markup generated by the behavior.
+     * @param appender The <code>Appender</code> to write the markup into.
+     */
+    public void renderStart(Appender appender)
+    {
+        if (hasErrors()) {
+            reportErrors(appender);
+            return;
+        }
+
+        TagContext tagCtxt = ContextUtils.getTagContext();
+
+        // verify hat we are in a container with run at client on...
+        ScriptReporter sr = tagCtxt.getScriptReporter();
+        if (!sr.isFeatureWritten(CoreScriptFeature.DYNAMIC_INIT)) {
+            String s = Bundle.getString("Tags_DivPanelHtmlRunAtClient", null);
+            registerTagError(s, null);
+            reportErrors(appender);
+            return;
+        }
+        sr.writeFeature(CoreScriptFeature.DIVPANEL_INIT, true, false, null);
+
+        // figure out if there is a page to render
+        String page = _firstPage;
+        if (_state != null) {
+            String fp = _state.getFirstPage();
+            if (fp != null)
+                page = fp;
+        }
+
+        if (hasErrors()) {
+            reportErrors(appender);
+            return;
+        }
+
+        IdScopeStack idStack = tagCtxt.getIdScopeStack();
+        _divState.id = idStack.getIdForTagId(_tagId);
+        _divState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, DIVPANEL_JAVASCRIPT_ATTR, "true");
+        if (page != null)
+            _divState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, DIVPANEL_FIRST_PAGE, page);
+        if (_state != null)
+            _divState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, "netui:divName", _state.getObjectName());
+
+        TagRenderingBase divRenderer = TagRenderingBase.Factory.getRendering(TagRenderingBase.DIV_TAG);
+        divRenderer.doStartTag(appender, _divState);
+    }
+
+    /**
+     * This method will render teh end tag for the markup generted by the behavior.
+     * @param appender The <code>Appender</code> to write the markup into.
+     */
+    public void renderEnd(Appender appender)
+    {
+        if (hasErrors())
+            return;
+
+        TagRenderingBase divRenderer = TagRenderingBase.Factory.getRendering(TagRenderingBase.DIV_TAG);
+        divRenderer.doEndTag(appender);
+    }
+
+    /**
+     * This method will pop the Behavior off of the Behavior stack.  It should always be called when
+     * the method is overriden.
+     */
+    public void postRender()
+    {
+    }
+
+    /**
+     */
+    private DivPanelState getState(ExpressionHandling expr)
+    {
+        String datasource = "{" + _dataSource + "}";
+        Object state = expr.evaluateExpression(datasource, "dataSource");
+        if (state == null || hasErrors()) {
+            return null;
+        }
+
+        if (!(state instanceof DivPanelState)) {
+            String s = Bundle.getString("Tags_DivPanelInvalidAttribute", _dataSource);
+            registerTagError(s, null);
+            return null;
+        }
+        return (DivPanelState) state;
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivPanelBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivSectionBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivSectionBehavior.java?rev=328413&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivSectionBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivSectionBehavior.java Tue Oct 25 09:54:34 2005
@@ -0,0 +1,109 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.core.Behavior;
+import org.apache.beehive.netui.simpletags.core.TagContext;
+import org.apache.beehive.netui.simpletags.core.services.BehaviorStack;
+import org.apache.beehive.netui.simpletags.rendering.DivTag;
+import org.apache.beehive.netui.simpletags.rendering.TagRenderingBase;
+import org.apache.beehive.netui.simpletags.util.ContextUtils;
+
+public class DivSectionBehavior extends Behavior
+{
+    private DivTag.State _state = new DivTag.State();
+    private boolean _visible = true;
+    private String _bodyContent;
+
+    /**
+     * Returns the name of the Tag.  This is used to
+     * identify the type of tag reporting errors.
+     * @return a constant string representing the name of the tag.
+     */
+    public String getTagName() {
+        return "DivSection";
+    }
+
+    /**
+     * Sets the visible state of the tag.
+     * @param visible <code>Boolean</code> value representing the visible state.
+     *
+     * @jsptagref.attributedescription
+     * Boolean. Determines if the section is visible.
+     *
+     * @jsptagref.databindable false
+     *
+     * @jsptagref.attributesyntaxvalue <i>boolean_literal_visible</i>
+     *
+     * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+     * description="Determines if the section is visible."
+     */
+    public void setVisible(boolean visible) {
+        _visible = visible;
+    }
+
+    public void setBodyContent(String bodyContent) {
+        _bodyContent = bodyContent;
+    }
+
+    //******************* Lifecycle Methods ************************************
+
+    /**
+     * This method will push the Behavior on the behavior stack.  All overrides of
+     * this method should call this method so that the stack is maintained correctly.
+     */
+    public void preRender()
+    {
+        TagContext tagCtxt = ContextUtils.getTagContext();
+        BehaviorStack stack = tagCtxt.getBehaviorStack();
+        Behavior parent = stack.getParent(null);
+        if (!(parent instanceof DivPanelBehavior)) {
+            // @todo: this can also be a repeater
+            // @todo: this would be an error
+        }
+        String id = _state.id;
+        _state.id = getIdForTagId(id);
+    }
+
+    /**
+     * This method will render the start tag for the markup generated by the behavior.
+     * @param appender The <code>Appender</code> to write the markup into.
+     */
+    public void renderStart(Appender appender)
+    {
+        if (!_visible)
+            return;
+
+        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.DIV_TAG);
+        br.doStartTag(appender, _state);
+   }
+
+    /**
+     * This method will render teh end tag for the markup generted by the behavior.
+     * @param appender The <code>Appender</code> to write the markup into.
+     */
+    public void renderEnd(Appender appender)
+    {
+        if (!_visible)
+            return;
+
+        if (hasErrors()) {
+            reportErrors(appender);
+            return;
+        }
+
+        if (_bodyContent != null)
+            appender.append(_bodyContent);
+
+        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.DIV_TAG);
+        br.doEndTag(appender);
+        return;
+    }
+
+    /**
+     * This method will pop the Behavior off of the Behavior stack.  It should always be called when
+     * the method is overriden.
+     */
+    public void postRender()
+    {
+   }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/DivSectionBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBaseBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBaseBehavior.java?rev=328413&r1=328412&r2=328413&view=diff
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBaseBehavior.java (original)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBaseBehavior.java Tue Oct 25 09:54:34 2005
@@ -399,23 +399,6 @@
     }
 
     /**
-     * This method will generate a real id based upon the passed in tagId.  The generated
-     * id will be constucted by searching upward for all the script containers that have a
-     * scope id set.  These will form a fully qualified id.
-     * @param tagId The base tagId set on a tag
-     * @return an id value formed by considering all of the scope id's found in the tag hierarchy.
-     */
-    final protected String getIdForTagId(String tagId)
-    {
-        if (tagId == null)
-            return null;
-
-        TagContext tagCtxt = ContextUtils.getTagContext();
-        IdScopeStack idScope = tagCtxt.getIdScopeMgr();
-        return idScope.getIdForTagId(tagId);
-    }
-
-    /**
      * Assumptions:
      * <ul>
      * <li>The state.name must be fully formed or the "real name" of the form.</li>

Modified: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java?rev=328413&r1=328412&r2=328413&view=diff
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java (original)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java Tue Oct 25 09:54:34 2005
@@ -125,7 +125,7 @@
     private void pushIdScope(TagContext tagCtxt)
     {
         if (_idScope != null) {
-            IdScopeStack scopeStack = tagCtxt.getIdScopeMgr();
+            IdScopeStack scopeStack = tagCtxt.getIdScopeStack();
             scopeStack.push(_idScope);
         }
     }
@@ -138,7 +138,7 @@
     private void popIdScope(TagContext tagCtxt)
     {
         if (_idScope != null) {
-            IdScopeStack scopeStack = tagCtxt.getIdScopeMgr();
+            IdScopeStack scopeStack = tagCtxt.getIdScopeStack();
             String idScope = scopeStack.pop();
             assert(idScope.equals(_idScope)) : "Mismatch between Id Scopes during pop, found '" +
                     idScope + "', expected: '" + _idScope + "'";

Modified: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/Behavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/Behavior.java?rev=328413&r1=328412&r2=328413&view=diff
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/Behavior.java (original)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/Behavior.java Tue Oct 25 09:54:34 2005
@@ -6,6 +6,7 @@
 import org.apache.beehive.netui.simpletags.appender.Appender;
 import org.apache.beehive.netui.simpletags.core.services.BehaviorStack;
 import org.apache.beehive.netui.simpletags.core.services.ErrorReporter;
+import org.apache.beehive.netui.simpletags.core.services.IdScopeStack;
 import org.apache.beehive.netui.simpletags.naming.INameInterceptor;
 import org.apache.beehive.netui.simpletags.util.ContextUtils;
 import org.apache.beehive.netui.util.Bundle;
@@ -24,8 +25,6 @@
      */
     public abstract String getTagName();
 
-    //public abstract void setAttribute(String name, String value, String facet);
-
     /**
      * This will report an error from a tag.  The error will
      * contain a message.  If error reporting is turned off,
@@ -130,6 +129,23 @@
             appender.append(err);
         }
     }
+    
+    /**
+     * This method will generate a real id based upon the passed in tagId.  The generated
+     * id will be constucted by searching upward for all the script containers that have a
+     * scope id set.  These will form a fully qualified id.
+     * @param tagId The base tagId set on a tag
+     * @return an id value formed by considering all of the scope id's found in the tag hierarchy.
+     */
+    final protected String getIdForTagId(String tagId)
+    {
+        if (tagId == null)
+            return null;
+
+        TagContext tagCtxt = ContextUtils.getTagContext();
+        IdScopeStack idScope = tagCtxt.getIdScopeStack();
+        return idScope.getIdForTagId(tagId);
+    }
 
     /**
      * This method walks all of the naming chains and allows them to rewrite the <code>name</code> parameter.
@@ -199,11 +215,6 @@
     {
         return null;
     }
-
-    //protected String getInlineError()
-    //{
-    //    return _eh.getInlineError(getTagName());
-    //}
 
     /**
      * This method will return an ErrorHandling instance.

Modified: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/TagContext.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/TagContext.java?rev=328413&r1=328412&r2=328413&view=diff
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/TagContext.java (original)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/TagContext.java Tue Oct 25 09:54:34 2005
@@ -81,7 +81,7 @@
     }
 
     //******************************* Id Scoping Support ********************************//
-    public IdScopeStack getIdScopeMgr()
+    public IdScopeStack getIdScopeStack()
     {
         if (_idScopeStack == null)
             _idScopeStack = new IdScopeStack();

Modified: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/services/BehaviorStack.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/services/BehaviorStack.java?rev=328413&r1=328412&r2=328413&view=diff
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/services/BehaviorStack.java (original)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/services/BehaviorStack.java Tue Oct 25 09:54:34 2005
@@ -63,6 +63,28 @@
     }
 
     /**
+     * Return the parent of the element that is passed in.
+     * @param start The element to find the parent for, if this is null, then we will find we return
+     * the parent of the last element returned by peek().
+     * @return The Behavior that is the parent of <code>start</code>
+     */
+    public Behavior getParent(Behavior start)
+    {
+        if (_tagStack == null || _tagStack.size() == 0)
+            return null;
+
+        Object s = (start != null) ? start : _tagStack.get(_tagStack.size() - 1);
+        int idx = _tagStack.size() - 1;
+        while (idx >= 0) {
+            if (_tagStack.get(idx) == s)
+                break;
+            idx--;
+        }
+        idx--;
+        return (idx >= 0) ?(Behavior) _tagStack.get(idx) : null;
+    }
+
+    /**
      * This method will return an ancestor on the stack that is an instanceof
      * the passed in class.  The ancestor to start the search from is passed to
      * this.  Only the parents of <code>start</code> will be checked.
@@ -72,10 +94,10 @@
      */
     public Behavior findAncestorWithClass(Behavior start, Class cls)
     {
-        int adjust = (start != null) ? 1 : 0;
         if (_tagStack == null || _tagStack.size() == 0)
             return null;
 
+        int adjust = (start != null) ? 1 : 0;
         Object s = (start != null) ? start : _tagStack.get(_tagStack.size() - 1);
         int idx = _tagStack.size() - 1;
         while (idx >= 0) {

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelCRI.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelCRI.java?rev=328413&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelCRI.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelCRI.java Tue Oct 25 09:54:34 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.simpletags.divpanel;
+
+import org.apache.beehive.netui.pageflow.interceptor.InterceptorChain;
+import org.apache.beehive.netui.pageflow.interceptor.InterceptorException;
+import org.apache.beehive.netui.pageflow.interceptor.request.RequestInterceptorContext;
+import org.apache.beehive.netui.pageflow.requeststate.INameable;
+import org.apache.beehive.netui.pageflow.requeststate.NameService;
+import org.apache.beehive.netui.simpletags.ajax.AbstractClientRequestInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class DivPanelCRI extends AbstractClientRequestInterceptor
+{
+    private static final String SWITCH_PAGE = "switchPage";
+
+    public void preRequest(RequestInterceptorContext ctxt, InterceptorChain chain)
+    {
+        HttpServletRequest request = ctxt.getRequest();
+
+        // Create the command by striping off the context path and the extension
+        String uri = request.getRequestURI();
+        String ctxtPath = request.getContextPath();
+
+        String cmd = getCommand(uri, ctxtPath);
+
+
+        // check to see if we handle this command
+        if (SWITCH_PAGE.equals(cmd)) {
+            handlePageSwitch(request);
+        }
+
+    }
+
+    private void handlePageSwitch(HttpServletRequest req)
+    {
+        String dp = req.getParameter("divPanel");
+        String fp = req.getParameter("firstPage");
+        //System.err.println("DivPanelBehavior Command: switch, DivPanelBehavior:" + dp + " Node:" + fp);
+
+        NameService ns = NameService.instance(req.getSession());
+        assert(ns != null);
+
+        // get the tree from the name service
+        INameable n = ns.get(dp);
+        if (n == null) {
+            System.err.println("DivPanelBehavior '" + dp + "' was not found in the NameService");
+            return;
+        }
+        if (!(n instanceof DivPanelState)) {
+            System.err.println("Named dp was not an instance of a DivPanelState");
+            return;
+        }
+
+        DivPanelState state = (DivPanelState) n;
+        state.setFirstPage(fp);
+    }
+
+    public void postRequest(RequestInterceptorContext context, InterceptorChain chain) throws InterceptorException
+    {
+        chain.continueChain();
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelCRI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelState.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelState.java?rev=328413&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelState.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelState.java Tue Oct 25 09:54:34 2005
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.simpletags.divpanel;
+
+import org.apache.beehive.netui.pageflow.requeststate.INameable;
+
+import java.io.Serializable;
+
+public class DivPanelState implements INameable, Serializable
+{
+    private String _name;
+    private String _firstPage;
+
+    /**
+     * Set the ObjectName of the INameable object.  This should only
+     * be set once.  If it is called a second time an IllegalStateException
+     * should be thrown
+     * @param name the Object's name.
+     * @throws IllegalStateException if this method is called more than once for an object
+     */
+    public void setObjectName(String name)
+    {
+        _name = name;
+    }
+
+    /**
+     * Returns the ObjectName of the INameable object.
+     * @return the ObjectName.
+     */
+    public String getObjectName()
+    {
+        return _name;
+    }
+
+    public String getFirstPage()
+    {
+        return _firstPage;
+    }
+
+    public void setFirstPage(String firstPage)
+    {
+        _firstPage = firstPage;
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/divpanel/DivPanelState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivPanel.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivPanel.java?rev=328413&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivPanel.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivPanel.java Tue Oct 25 09:54:34 2005
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.simpletags.jsptags;
+
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.appender.ResponseAppender;
+import org.apache.beehive.netui.simpletags.behaviors.DivPanelBehavior;
+
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.JspFragment;
+import java.io.IOException;
+
+/**
+ * A DivPanelBehavior creates an HTML &lt;div> tag that may contain additional &lt;div> tags.  There will only
+ * be a single div that is visible at a time.
+ * @jsptagref.tagdescription Creates an HTML &lt;div> tag that may contain additional &lt;div> tags.  Only a single section will be visible at a time.
+ * @netui:tag name="divPanel"
+ * description="A divPanel is an placeholder which may contain multiple sections.  Only a single section will be visible at a time."
+ */
+public class DivPanel extends AbstractSimpleTag
+{
+    public DivPanel() {
+        _behavior = new DivPanelBehavior();
+    }
+    /**
+     * Sets an expression which indentifies the DivPanelState which will store the state of the
+     * DivPanelBehavior between posts to the server.
+     * @param dataSource the tree attribute name
+     * @jsptagref.attributedescription An expression which identifies which DivPanelState object will store state between posts to the server.
+     * @jsptagref.databindable true
+     * @jsptagref.attributesyntaxvalue <i>expression</i>
+     * @netui:attribute description="Sets an expression which indentifies the DivPanelState storing the state of the
+     * DivPanelBehavior between posts."
+     */
+    public void setDataSource(String dataSource)
+    {
+        ((DivPanelBehavior) _behavior).setDataSource(dataSource);
+    }
+
+    /**
+     * Set the ID of the tag.
+     * @param tagId the tagId.
+     * @jsptagref.attributedescription Set the ID of the &lt;div> tag
+     * @jsptagref.databindable true
+     * @jsptagref.attributesyntaxvalue <i>string_or_expression</i>
+     * @netui:attribute required="true" rtexprvalue="true"
+     * description="Set the ID of the tag."
+     */
+    public void setTagId(String tagId)
+    {
+        ((DivPanelBehavior) _behavior).setTagId(tagId);
+    }
+
+    /**
+     * Set the name of the first page to display.
+     * @param firstPage the name of the first page.
+     * @jsptagref.attributedescription Set the name of the first page to display.
+     * @jsptagref.databindable true
+     * @jsptagref.attributesyntaxvalue <i>string_or_expression</i>
+     * @netui:attribute rtexprvalue="true"
+     * description="Set the name of the first page to display."
+     */
+    public void setFirstPage(String firstPage)
+    {
+        ((DivPanelBehavior) _behavior).setFirstPage(firstPage);
+    }
+
+    /**
+     * Causes the content of the section to be rendered into a buffer.
+     * @throws javax.servlet.jsp.JspException if there are errors.
+     */
+    public void doTag()
+            throws JspException, IOException
+    {
+        _behavior.start();
+
+        // it is always required to set the variable resolver on a datasource.
+        ((DivPanelBehavior) _behavior).setVariableResolver(getPageContext().getVariableResolver());
+
+        ServletResponse response = getPageContext().getResponse();
+        Appender appender = new ResponseAppender(response);
+        _behavior.preRender();
+        _behavior.renderStart(appender);
+
+        JspFragment frag = getJspBody();
+        if (frag != null) {
+            frag.invoke(response.getWriter());
+        }
+
+        _behavior.renderEnd(appender);
+        _behavior.postRender();
+        _behavior.terminate();
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivSection.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivSection.java?rev=328413&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivSection.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivSection.java Tue Oct 25 09:54:34 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.simpletags.jsptags;
+
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.appender.ResponseAppender;
+import org.apache.beehive.netui.simpletags.behaviors.AnchorBehavior;
+import org.apache.beehive.netui.simpletags.behaviors.DivSectionBehavior;
+
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+
+/**
+ * @netui:tag name="divSection" body-content="scriptless" dynamic-attributes="true"
+ *          description="Use this tag to mark out content to replace a netui-template:includeSection within a template file."
+ */
+public class DivSection extends AbstractSimpleTag
+{
+    public DivSection() {
+        _behavior = new DivSectionBehavior();
+    }
+
+    /**
+     * Sets the visible state of the tag.
+     * @param visible <code>Boolean</code> value representing the visible state.
+     *
+     * @jsptagref.attributedescription
+     * Boolean. Determines if the section is visible.
+     * 
+     * @jsptagref.databindable false
+     * 
+     * @jsptagref.attributesyntaxvalue <i>boolean_literal_visible</i>
+     *
+     * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+     * description="Determines if the section is visible."
+     */
+    public void setVisible(boolean visible) {
+        ((DivSectionBehavior) _behavior).setVisible(visible);
+    }
+
+    /**
+     * Causes the content of the section to be rendered into a buffer.
+     * @throws JspException if there are errors.
+     */
+    public void doTag() throws JspException, IOException
+    {
+        _behavior.start();
+        String value = getBufferBody(true);
+        ((DivSectionBehavior) _behavior).setBodyContent(value);
+
+        Appender appender = new ResponseAppender(getPageContext().getResponse());
+        ((AnchorBehavior) _behavior).setText(value);
+        _behavior.preRender();
+        _behavior.renderStart(appender);
+        _behavior.renderEnd(appender);
+        _behavior.postRender();
+        _behavior.terminate();
+    }
+
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/DivSection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/util/ContextUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/util/ContextUtils.java?rev=328413&r1=328412&r2=328413&view=diff
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/util/ContextUtils.java (original)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/util/ContextUtils.java Tue Oct 25 09:54:34 2005
@@ -2,6 +2,7 @@
 
 import org.apache.beehive.netui.simpletags.core.TagContext;
 import org.apache.beehive.netui.pageflow.PageFlowContext;
+import org.apache.beehive.netui.pageflow.requeststate.NameService;
 
 public class ContextUtils
 {
@@ -19,5 +20,15 @@
         TagContext tagCtxt = (TagContext) pfCtxt.get(TAG_CONTEXT_NAME,TagContext.ACTIVATOR);
         assert(tagCtxt != null) : "the TagContext returned as null";
         return tagCtxt;
+    }
+
+    /**
+     * Return the name service
+     * @return
+     */
+    public static NameService getNameService() {
+        PageFlowContext pfCtxt = PageFlowContext.getContext();
+        assert(pfCtxt != null) : "the PageFlowContext returned as null";
+        return NameService.instance(pfCtxt.getRequest().getSession());
     }
 }