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/19 17:31:56 UTC
svn commit: r326581 [7/9] - in /beehive/trunk/netui: ant/
src/bootstrap/org/apache/beehive/netui/tools/tld/xdoclet/ src/jar-assembly/
src/pageflow/org/apache/beehive/netui/pageflow/ src/simple-tags/
src/simple-tags/org/ src/simple-tags/org/apache/ src/...
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ImageAnchor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ImageAnchor.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ImageAnchor.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ImageAnchor.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,339 @@
+/*
+ * 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.ImageAnchorBehavior;
+import org.apache.beehive.netui.simpletags.html.IHtmlAccessable;
+
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+
+/**
+ * Generates a URL-encoded hyperlink to a specified URI with an image
+ * enclosed as the body. ImageAnchor provides support for image rollovers.
+ *
+ * An imageAnchor must have one of five attributes to correctly create the hyperlink:
+ * <ul>
+ * <li>action - an action invoked by clicking the hyperlink.</li>
+ * <li>href - a URL to go to</li>
+ * <li>linkName - an internal place in the page to move to</li>
+ * <li>clientAction - the action to run on the client</li>
+ * <li>tagId - the ID of the tag</li>
+ * <li>formSubmit - indicates whether or not the enclosing Form should be submitted</li>
+ * </ul>
+ * @jsptagref.tagdescription <p>
+ * Generates a hyperlink with a clickable image. Provides support for image rollovers.
+ * <p>
+ * The <netui:imageAnchor> tag must have one of five attributes to correctly create the hyperlink:
+ * <blockquote>
+ * <ul>
+ * <li><code>action</code> - an action method invoked by clicking the hyperlink</li>
+ * <li><code>href</code> - an URL to go to</li>
+ * <li><code>linkName</code> - an internal place in the page to move to</li>
+ * <li><code>clientAction</code> - the action to run on the client</li>
+ * <li><code>tagId</code> - the ID of the tag</li>
+ * <li><code>formSubmit</code> - indicates whether or not the enclosing Form should be submitted</li>
+ * </ul>
+ * </blockquote>
+ *
+ * <p><b>JavaScript</b></p>
+ * <p>If the <code>formSubmit</code> attribute is set to <code>true</code> and no
+ * <code>onClick</code> attribute is set, the following JavaScript function will be written to the HTML page.
+ * This JavaScript function will be referenced by the <code>onclick</code> attribute of the generated image
+ * anchor tag.</p>
+ * <pre>
+ * function anchor_submit_form(netuiName, newAction)
+ * {
+ * for (var i=0; i<document.forms.length; i++) {
+ * if (document.forms[i].id == netuiName) {
+ * document.forms[i].method = "POST";
+ * document.forms[i].action = newAction;
+ * document.forms[i].submit();
+ * }
+ * }
+ * }</pre>
+ * <p>It is possible to write a custom <code>onClick</code> JavaScript event handler that would
+ * do additional work, for example form validation, and still submit the form correctly. To
+ * accomplish this, reference a JavaScript function in the <code>onClick</code>
+ * attribute:</p>
+ * <pre> <netui:imageAnchor formSubmit="true" <b>onClick="SubmitFromAnchor();return false;"</b>>
+ * View Results
+ * </netui:imageAnchor></pre>
+ *
+ * <p>And add the referenced JavaScript function to the page:</p>
+ * <pre> function SubmitFromAnchor()
+ * {
+ * // implement custom logic here
+ *
+ * for(var i=0; i<document.forms.length; i++)
+ * {
+ * // submit to the action /aWebapp/formPost.do
+ * if (document.forms[i].action == "/aWebapp/formPost.do")
+ * {
+ * document.forms[i].method="POST";
+ * document.forms[i].action="/aWebapp/formPost.do";
+ * document.forms[i].submit();
+ * }
+ * }
+ * }</pre>
+ *
+ * <p>This will cause the JavaScript function to be executed before posting the form.</p>
+ * @example In this sample, an <netui:imageAnchor> shows "top.jpg" at 25 x 25 pixels and navigates to
+ * index.jsp when clicked.
+ * <pre> <netui:imageAnchor href="index.jsp" src="top.jpg" height="25" width="25" /></pre>
+ * </p>
+ * @netui:tag name="imageAnchor" body-content="scriptless" dynamic-attributes="true" description="Combines the functionality of the netui:image and netui:anchor tags."
+ */
+public class ImageAnchor
+ extends Anchor
+ implements IHtmlAccessable
+{
+ /**
+ * Sets the property to specify where to align the image.
+ * @param align the image alignment.
+ * @jsptagref.attributedescription The alignment of the image.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_align</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The alignment of the image."
+ */
+ public void setAlign(String align)
+ {
+ ((ImageAnchorBehavior) _behavior).setAlign(align);
+ }
+
+ /**
+ * Sets the property to specify the alt text of the image.
+ * @param alt the image alignment.
+ * @jsptagref.attributedescription The alternative text of the image
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>string_alt</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The alternative text of the image."
+ */
+ public void setAlt(String alt)
+ {
+ ((ImageAnchorBehavior) _behavior).setAlt(alt);
+ }
+
+ /**
+ * Sets the property to specify a link to the the long description to supplement
+ * the short description in the <code>alt</code> attribute.
+ * @param longdesc the longdesc.
+ * @jsptagref.attributedescription Specifies a link to the the long description.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_longdesc</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="Specifies a link to the the long description."
+ */
+ public void setLongdesc(String longdesc)
+ {
+ ((ImageAnchorBehavior) _behavior).setLongdesc(longdesc);
+ }
+
+ /**
+ * Sets the border size around the image.
+ * @param border the border size.
+ * @jsptagref.attributedescription The border size around the image
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>integer_pixelBorder</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The border size around the image."
+ */
+ public void setBorder(String border)
+ {
+ ((ImageAnchorBehavior) _behavior).setBorder(border);
+ }
+
+ /**
+ * Sets the image height.
+ * @param height the height.
+ * @jsptagref.attributedescription The image height
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>integer_height</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The image height."
+ */
+ public void setHeight(String height)
+ {
+ ((ImageAnchorBehavior) _behavior).setHeight(height);
+ }
+
+ /**
+ * Sets the the horizontal spacing around the image.
+ * @param hspace the horizontal spacing.
+ * @jsptagref.attributedescription The horizontal spacing around the image.
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>integer_hspace</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The horizontal spacing around the image."
+ */
+ public void setHspace(String hspace)
+ {
+ ((ImageAnchorBehavior) _behavior).setHspace(hspace);
+ }
+
+ /**
+ * Sets the server-side image map declaration.
+ * @param ismap the image map declaration.
+ * @jsptagref.attributedescription The server-side map declaration.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_isMap</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The server-side map declaration."
+ */
+ public void setIsmap(String ismap)
+ {
+ ((ImageAnchorBehavior) _behavior).setIsmap(ismap);
+ }
+
+ /**
+ * Sets the roll-over image of the ImageAnchor.
+ * @param rolloverImage the rollover image.
+ * @jsptagref.attributedescription The URI of the rollover image.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_rolloverImage</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The URI of the rollover image."
+ */
+ public void setRolloverImage(String rolloverImage)
+ {
+ ((ImageAnchorBehavior) _behavior).setRolloverImage(rolloverImage);
+ }
+
+ /**
+ * Sets the image source URI.
+ * @param src the image source URI.
+ * @jsptagref.attributedescription The image source URI
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>string_src</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The image source URI"
+ * reftype="img-url"
+ */
+ public void setSrc(String src)
+ throws JspException
+ {
+ ((ImageAnchorBehavior) _behavior).setSrc(src);
+ }
+
+ /**
+ * Sets the client-side image map declaration.
+ * @param usemap the map declaration.
+ * @jsptagref.attributedescription The client-side image map declaration
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_useMap</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The client-side image map declaration"
+ */
+ public void setUsemap(String usemap)
+ {
+ ((ImageAnchorBehavior) _behavior).setUsemap(usemap);
+ }
+
+ /**
+ * Sets the vertical spacing around the image.
+ * @param vspace the vertical spacing.
+ * @jsptagref.attributedescription The vertical spacing around the image.
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>string_vspace</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The vertical spacing around the image."
+ */
+ public void setVspace(String vspace)
+ {
+ ((ImageAnchorBehavior) _behavior).setVspace(vspace);
+ }
+
+ /**
+ * Set the <img> style for the contained image. When the tag library is
+ * running in legacy mode, this will override the <code>style</code> attribute if that is
+ * set. If this is not set, and <code>style</code> is set, then it will be applied to
+ * the image.
+ * @param imageStyle the label style
+ * @jsptagref.attributedescription For legacy documents. Specifies style information for the
+ * contained image. When the tag library is running in legacy mode, this will override the
+ * <code>style</code> attribute. If this is not set, and <code>style</code> is set,
+ * then it will be applied to the image.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_imagestyle</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="Set the style for the contained image."
+ */
+ public void setImageStyle(String imageStyle)
+ {
+ ((ImageAnchorBehavior) _behavior).setImageStyle(imageStyle);
+ }
+
+ /**
+ * Set the label style class for each contained Image. When the tag library is
+ * running in legacy mode, this will override the <code>styleClass</code> attribute if that is
+ * set. If this is not set, and <code>styleClass</code> is set, then it will be applied to
+ * the image.
+ * @param imageClass the image class
+ * @jsptagref.attributedescription For legacy documents. The style class (a style sheet selector).
+ * When the tag library is running in legacy mode, this will override the <code>styleClass</code>
+ * attribute. If this is not set, and <code>styleClass</code> is set, then it will be applied to
+ * the image.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_imageclass</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="Set the label style class for each contained image."
+ */
+ public void setImageStyleClass(String imageClass)
+ {
+ ((ImageAnchorBehavior) _behavior).setImageStyleClass(imageClass);
+ }
+
+ /**
+ * Sets the image width.
+ * @param width the image width.
+ * @jsptagref.attributedescription The image width.
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>integer_pixelWidth</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The image width."
+ */
+ public void setWidth(String width)
+ {
+ ((ImageAnchorBehavior) _behavior).setWidth(width);
+ }
+
+ /**
+ * Insert rollover javascript.
+ * <p>
+ * Support for indexed property since Struts 1.1
+ * @throws JspException if a JSP exception has occurred
+ */
+ public void doTag() throws JspException, IOException
+ {
+ _behavior.start();
+
+ // evaluate the body, this is called basically so any parameters my be applied.
+ getBufferBody(false);
+
+ Appender appender = new ResponseAppender(getPageContext().getResponse());
+ _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/ImageAnchor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/Parameter.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/Parameter.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/Parameter.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/Parameter.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,101 @@
+/*
+ * 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;
+
+// java imports
+
+// internal imports
+
+import org.apache.beehive.netui.simpletags.core.IUrlParams;
+import org.apache.beehive.netui.simpletags.core.TagContext;
+import org.apache.beehive.netui.simpletags.core.services.BehaviorStack;
+import org.apache.beehive.netui.simpletags.util.ContextUtils;
+
+/**
+ * Writes a URL parameter to a URL on its parent tag. The parent tag must implement IUrlParams.
+ * @jsptagref.tagdescription Writes a name/value pair to the URL or the parent tag.
+ *
+ * You can dynamically determine the value of the <netui:parameter> through
+ * the <code>value</code> attribute.
+ * @example In this sample, the hyperlink is amended with the parameter <code>q=Socrates</code>
+ *
+ * <pre> <netui:anchor href="http://www.google.com/search">
+ * Search Google with the query "Socrates"
+ * <netui:parameter name="q" value="Socrates" />
+ * </netui:anchor></pre>
+ *
+ * The URL produced appears below:
+ *
+ * <pre> http://www.google.com/search?q=Socrates</pre>
+ * @netui:tag name="parameter" body-content="scriptless" description="Writes a URL parameter to a URL on its parent tag."
+ */
+public class Parameter extends AbstractSimpleTag
+{
+ private String _name = null;
+ private Object _value = null;
+
+ /**
+ * Return the name of the Tag.
+ */
+ public String getTagName()
+ {
+ return "Parameter";
+ }
+
+ /**
+ * Sets the name of the URL parameter.
+ * @param name the parameter name.
+ * @jsptagref.attributedescription The name of the parameter.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_name</i>
+ * @netui:attribute required="true" rtexprvalue="true"
+ * description="The name of the parameter."
+ */
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ /**
+ * Sets the value of the URL parameter. This can be an expression.
+ * @param value the parameter value.
+ * @jsptagref.attributedescription The value of the parameter. May be a literal or a data binding expression.
+ * @jsptagref.databindable true
+ * @jsptagref.attributesyntaxvalue <i>string_or_expression_value</i>
+ * @netui:attribute required="true" rtexprvalue="true" type="java.lang.Object"
+ * description="The value of the parameter."
+ */
+ public void setValue(Object value)
+ {
+ _value = value;
+ }
+
+ /**
+ * Add the URL parameter to the Parameter's parent.
+ */
+ public void doTag()
+ {
+ TagContext tagCtxt = ContextUtils.getTagContext();
+ BehaviorStack behaviors = tagCtxt.getBehaviorStack();
+ IUrlParams urlParams = (IUrlParams) behaviors.findAncestorWithClass(null, IUrlParams.class);
+ // @todo: how do we report an error here if the urlParams is null?
+ if (urlParams != null) {
+ urlParams.addParameter(_name, _value, null);
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/Parameter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ParameterMap.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ParameterMap.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ParameterMap.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ParameterMap.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,113 @@
+/*
+ * 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;
+
+// java imports
+
+import org.apache.beehive.netui.util.Bundle;
+import org.apache.beehive.netui.simpletags.core.TagContext;
+import org.apache.beehive.netui.simpletags.core.IUrlParams;
+import org.apache.beehive.netui.simpletags.core.Behavior;
+import org.apache.beehive.netui.simpletags.core.services.BehaviorStack;
+import org.apache.beehive.netui.simpletags.util.ContextUtils;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Writes each in a map of URL parameters to a URL on its parent tag.
+ * The parent tag must implement IUrlParams.
+ * @jsptagref.tagdescription <p>Writes a group of name/value pairs to the URL or the parent tag.
+ *
+ * <p>The <netui:parameterMap> can be nested inside of the
+ * {@link org.apache.beehive.netui.simpletags.jsptags.Anchor},
+ * {@link org.apache.beehive.netui.simpletags.jsptags.Button},
+ * {@link org.apache.beehive.netui.simpletags.jsptags.Form}, and
+ * {@link org.apache.beehive.netui.simpletags.jsptags.Image} tags.
+ *
+ * <p>You can dynamically determine the value of the <netui:parameterMap> tag by pointing
+ * the <code>map</code> attribute at a {@link java.util.HashMap java.util.HashMap} object.
+ * @example Assume that there is a java.util.HashMap
+ * object in the Controller file.
+ *
+ * <pre> public HashMap hashMap = new HashMap();
+ * hashMap.put("q", "Socrates");
+ * hashMap.put("lr", "lang_el");
+ * hashMap.put("as_qdr", "m3");</pre>
+ *
+ * <p>The following set of tags will read the HashMap object and generate a
+ * link with a set of URL parameters.
+ *
+ * <pre> <netui:anchor href="http://www.google.com/search">
+ * Search Greek language web sites updated in the last three months with the query "Socrates".
+ * <netui:parameterMap map="${pageFlow.hashMap}"/>
+ * </netui:anchor></pre>
+ *
+ * <p>The URL produced appears as follows:
+ *
+ * <pre> http://www.google.com/search?lr=lang_el&q=Socrates&as_qdr=m3</pre>
+ * @netui:tag name="parameterMap" body-content="scriptless" description="Uses a JSP 2.0 expression that points to a map of parameters. Each entry in the map provides a URL parameter that will be added to the parent tag's URL."
+ */
+public class ParameterMap extends AbstractSimpleTag
+{
+ private Map _map = null;
+ private String _error;
+
+ /**
+ * Sets the map expression.
+ * @param map the map expression.
+ * @jsptagref.attributedescription A data binding expression pointing to a {@link java.util.Map java.util.Map} of parameters.
+ * The expression can point at any implementation of the java.util.Map interface,
+ * including {@link java.util.AbstractMap java.util.AbstractMap},
+ * {@link java.util.HashMap java.util.HashMap},
+ * {@link java.util.Hashtable java.util.Hashtable}, etc.
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>string_mapObject</i>
+ * @netui:attribute required="true" rtexprvalue="true" type="java.util.Map"
+ * description="A JSP 2.0 EL expression pointing to a java.util.Map of parameters."
+ */
+ public void setMap(Map map)
+ {
+ if (map == null) {
+ _error = Bundle.getString("Tags_MapAttrValueRequired", new Object[]{"map"});
+ }
+ _map = map;
+ }
+
+ /**
+ * Add each parameter in the URL parameter map to the Parameter's parent.
+ */
+ public void doTag()
+ {
+ TagContext tagCtxt = ContextUtils.getTagContext();
+ BehaviorStack behaviors = tagCtxt.getBehaviorStack();
+ IUrlParams urlParams = (IUrlParams) behaviors.findAncestorWithClass(null, IUrlParams.class);
+ if (_error != null && urlParams != null) {
+ ((Behavior) urlParams).registerTagError(_error,null);
+ return;
+ }
+ // @todo: how do we report an error here if the urlParams is null?
+ if (urlParams != null) {
+ Iterator it = _map.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry key = (Map.Entry) it.next();
+ urlParams.addParameter(key.getKey().toString(), key.getValue(), null);
+ }
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ParameterMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ScriptContainer.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ScriptContainer.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ScriptContainer.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/ScriptContainer.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,127 @@
+/*
+ * 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.ScriptContainerBehavior;
+
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.JspFragment;
+
+/**
+ * Acts as a container that will bundle up JavaScript created by other NetUI tags,
+ * and output it within a single <script> tag. This is especially needed for
+ * Portal web applications, because they often cannot rely on having
+ * <html> ... </html> tags to provide a default container. In a portlet,
+ * some JSP pages might be included into other JSP pages. Having redundant
+ * <html> ... </html> tags in the rendered portlet JSP can result in display
+ * problems for some browsers. However, omitting the <html> tag (and the
+ * container it provides) can result in cluttered code, especially where Javascript
+ * appears in the file. To solve this issue, Beehive provides the
+ * <netui:scriptContainer> tag.
+ *
+ * @jsptagref.tagdescription Acts as a container that will bundle up JavaScript created by other <netui...> tags,
+ * and outputs it within a single <script> tag. This is especially useful for
+ * Portal web applications, because they often cannot rely on having
+ * <html> ... </html> tags to provide a default container. In a Portlet,
+ * some JSP pages might be included in other JSP pages. Having redundant
+ * <html> ... </html> tags in the rendered Portlet JSP can result in display
+ * problems for some browsers. On the other hand, omitting the <html> tag (and the
+ * container it provides) can result in cluttered code, especially where JavaScript
+ * appears in the file. To solve this issue, Beehive provides the
+ * <netui:scriptContainer> tag.
+ *
+ * <p>The <netui:scriptContainer> ... </netui:scriptContainer> tag set should
+ * enclose those <netui:...> tags that you want included in the script container.
+ * The first <netui:scriptContainer> tag should appear after the JSP's <body> tag.
+ * The closing </netui:scriptContainer> tag should appear before the JSP's </body> tag.
+ * @example The <netui:scriptContainer> ... </netui:scriptContainer tag set simply
+ * encloses other NetUI tags that you want to belong to that script container.
+ * The first <netui:scriptContainer> tag should appear after the JSP's <body> tag.
+ * The closing </netui:scriptContainer> tag should appear before the JSP's </body> tag.
+ * @netui:tag name="scriptContainer" body-content="scriptless" dynamic-attributes="true" description="ScriptContainers defines a container that will gather all of the JavaScript of their children and output it in a single <script> tag. In addition, they providing scoping of tagIds."
+ */
+public class ScriptContainer extends AbstractSimpleTag
+{
+ public final static String SCOPE_ID = "netui:scopeId";
+
+ public ScriptContainer()
+ {
+ _behavior = new ScriptContainerBehavior();
+ }
+
+ /////////////////////////// Attributes ////////////////////////////
+
+ /**
+ * Set the idScope associated with the code methods
+ * @jsptagref.attributedescription The id that is associated with the script methods.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_scopeId</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The id that is associated with the script methods."
+ */
+ public void setIdScope(String idScope)
+ {
+ ((ScriptContainerBehavior) _behavior).setIdScope(idScope);
+ }
+
+ /**
+ * return the scopeId associated with the ScriptContainer
+ */
+ public String getIdScope()
+ {
+ return ((ScriptContainerBehavior) _behavior).getIdScope();
+ }
+
+ /**
+ * If true generate a scope id for this script container. If this is set to true
+ * and a scopeId is also set, the scopeId set will be written.
+ * @jsptagref.attributedescription Automatically generate a scopeId for this script container.
+ * @jsptagref.databindable true
+ * @jsptagref.attributesyntaxvalue <i>string_generateScopeId</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="Automatically generate a ScopeId."
+ */
+ public void setGenerateIdScope(boolean genScopeValue)
+ {
+ ((ScriptContainerBehavior) _behavior).setGenerateIdScope(genScopeValue);
+ }
+ ///////////////////////////////// Tag Methods ////////////////////////////////////////
+
+ public void doTag()
+ throws JspException, java.io.IOException
+ {
+ _behavior.start();
+
+ 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/ScriptContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/TextBox.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/TextBox.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/TextBox.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/jsptags/TextBox.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,187 @@
+/*
+ * 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.TextBoxBehavior;
+import org.apache.beehive.netui.simpletags.html.IHtmlAccessable;
+
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.JspFragment;
+import java.io.IOException;
+
+/**
+ * Renders a databound TextBox with the given attributes.
+ * @jsptagref.tagdescription Renders an HTML <input type="text"> tag.
+ * @example In this sample, a <netui:textBox> reads from and writes to the Form Bean's firstname property.
+ * If the submitted text is NULL, the default value is specified by the Page Flow's firstName property.
+ * <pre> <netui:textBox dataSource="actionForm.firstName"
+ * defaultValue="${pageFlow.defaultFirstName}"
+ * size="20" /></pre>
+ * @netui:tag name="textBox" body-content="scriptless" dynamic-attributes="true" description="Renders a databound TextBox with the given attributes."
+ */
+public class TextBox extends HtmlDefaultableDataSourceTag
+ implements IHtmlAccessable
+{
+ public TextBox() {
+ _behavior = new TextBoxBehavior();;
+ }
+
+ //******************************** ATTRIBUTES *******************************
+
+ /**
+ * Set the maximum length (in characters) of the TextBox.
+ * @param maxlength the max length
+ * @jsptagref.attributedescription Integer. The maximum number of character that can be entered in the rendered <input> element.
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>integer_maxLength</i>
+ * @netui:attribute required="false" rtexprvalue="true" type="int"
+ * description="The maximum number of character that can be entered in the rendered <input> element."
+ */
+ public void setMaxlength(int maxlength)
+ {
+ ((TextBoxBehavior) _behavior).setMaxlength(maxlength);
+ }
+
+ /**
+ * Set the password state (true means this is a password field).
+ * @param password the password state
+ * @jsptagref.attributedescription Boolean. Determines whether the password characters that the user enters into the <input> element will be disguised in the browser.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>boolean_password</i>
+ * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+ * description="Determines whether the password characters that the user enters into the <input> element will be disguised in the browser."
+ */
+ public void setPassword(boolean password)
+ {
+ ((TextBoxBehavior) _behavior).setPassword(password);
+ }
+
+ /**
+ * Set if this TextBox is read-only.
+ * @param readonly the read-only state
+ * @jsptagref.attributedescription Boolean. Determines if the rendered <input> element is read-only.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>boolean_readOnly</i>
+ * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+ * description="Determines if the rendered <input> element is read-only"
+ */
+ public void setReadonly(boolean readonly)
+ {
+ ((TextBoxBehavior) _behavior).setReadonly(readonly);
+ }
+
+ /**
+ * Set the size (in characters) of the TextBox.
+ * @param size the size
+ * @jsptagref.attributedescription Integer. The number of characters visible in the <input> element.
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>integer_size</i>
+ * @netui:attribute required="false" rtexprvalue="true" type="int"
+ * description="The number of characters visible in the <input> element."
+ */
+ public void setSize(int size)
+ {
+ ((TextBoxBehavior) _behavior).setSize(size);
+ }
+
+ /**
+ * Sets the accessKey attribute value. This should key value of the
+ * keyboard navigation key. It is recommended not to use the following
+ * values because there are often used by browsers <code>A, C, E, F, G,
+ * H, V, left arrow, and right arrow</code>.
+ * @param accessKey the accessKey value.
+ * @jsptagref.attributedescription The keyboard navigation key for the element.
+ * The following values are not recommended because they
+ * are often used by browsers: <code>A, C, E, F, G,
+ * H, V, left arrow, and right arrow</code>
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_accessKey</i>
+ * @netui:attribute required="false" rtexprvalue="true" type="char"
+ * description="The keyboard navigation key for the element.
+ * The following values are not recommended because they
+ * are often used by browsers: A, C, E, F, G,
+ * H, V, left arrow, and right arrow"
+ */
+ public void setAccessKey(char accessKey)
+ {
+ ((TextBoxBehavior) _behavior).setAccessKey(accessKey);
+ }
+
+ /**
+ * Sets the alt attribute value.
+ * @param alt the alt value.
+ * @jsptagref.attributedescription The alt attribute of the element.
+ * @jsptagref.databindable Read Only
+ * @jsptagref.attributesyntaxvalue <i>string_alt</i>
+ * @netui:attribute required="false" rtexprvalue="true"
+ * description="The alt attribute of the element."
+ */
+ public void setAlt(String alt)
+ {
+ ((TextBoxBehavior) _behavior).setAlt(alt);
+ }
+
+ /**
+ * Sets the tabIndex of the rendered html tag.
+ * @param tabindex the tab index.
+ * @jsptagref.databindable false
+ * @jsptagref.attributedescription The tabIndex of the rendered HTML tag. This attribute determines the position of the
+ * tag in the sequence of page elements that the user may advance through by pressing the TAB key.
+ * @jsptagref.attributesyntaxvalue <i>string_tabIndex</i>
+ * @netui:attribute required="false" rtexprvalue="true" type="int"
+ * description="The tabIndex of the rendered HTML tag. This attribute determines the position of the
+ * tag in the sequence of page elements that the user may advance through by pressing the TAB key."
+ */
+ public void setTabindex(int tabindex)
+ {
+ ((TextBoxBehavior) _behavior).setTabindex(tabindex);
+ }
+
+ //*************************************** TAG METHODS *****************************************
+
+ /**
+ * Render the TextBox.
+ * @throws JspException if a JSP exception has occurred
+ */
+ public void doTag() throws JspException, IOException
+ {
+ _behavior.start();
+
+ // it is always required to set the variable resolver on a datasource.
+ ((TextBoxBehavior) _behavior).setVariableResolver(getPageContext().getVariableResolver());
+
+ // process the body so formatters can be applied to the text
+ ServletResponse response = getPageContext().getResponse();
+ Appender appender = new ResponseAppender(getPageContext().getResponse());
+
+ JspFragment frag = getJspBody();
+ if (frag != null) {
+ frag.invoke(response.getWriter());
+ }
+
+ _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/TextBox.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/FormDataNameInterceptor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/FormDataNameInterceptor.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/FormDataNameInterceptor.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/FormDataNameInterceptor.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,73 @@
+/*
+ * 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.naming;
+
+import org.apache.beehive.netui.script.ExpressionEvaluationException;
+import org.apache.beehive.netui.script.ExpressionEvaluator;
+import org.apache.beehive.netui.script.ExpressionEvaluatorFactory;
+import org.apache.beehive.netui.simpletags.core.Behavior;
+import org.apache.beehive.netui.util.logging.Logger;
+
+/**
+ * A {@link INameInterceptor} that qualifies all non-expression attributes
+ * that are expected to be expressions into valid
+ * expressions. This conversion is for Struts compatability;
+ * In Struts, the "property" property is used to specify which
+ * property on the action form should be rendered in a tag's
+ * HTML. These attributes are converted into expressions
+ * by qualifying them into the <code>actionForm</code> binding
+ * context.
+ * <br/>
+ * <br/>
+ * For example, the <code>dataSource</code> attribute on a text box
+ * tag would be qualified into the <code>actionForm</code> context
+ * if the attribute was not an expression.
+ */
+public class FormDataNameInterceptor
+ implements INameInterceptor
+{
+ private static final Logger logger = Logger.getInstance(FormDataNameInterceptor.class);
+
+ /**
+ * Qualify the name of a NetUI JSP tag into the "actionForm" data binding context.
+ * This feature is used to convert non-expression tag names, as those used in Struts,
+ * into actionForm expressions that NetUI consumes.
+ * @param name the name to qualify into the actionForm binding context. If this is "foo", the returned value
+ * is {actionForm.foo}
+ * @return the qualified name or <code>null</code> if an error occurred
+ */
+ public String rewriteName(String name, Behavior currentTag)
+ throws ExpressionEvaluationException
+ {
+ ExpressionEvaluator eval = ExpressionEvaluatorFactory.getInstance();
+
+ try {
+ if (!eval.isExpression(name))
+ return eval.qualify("actionForm", name);
+ return name;
+ }
+ catch (Exception e) {
+ if (logger.isErrorEnabled())
+ logger.error("Could not qualify name \"" + name + "\" into the actionForm binding context.", e);
+
+ // return the Struts name. This should cause regular Struts databinding to execute so this property will
+ // be updated anyway.
+ return name;
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/FormDataNameInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/INameInterceptor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/INameInterceptor.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/INameInterceptor.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/INameInterceptor.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,45 @@
+/*
+ * 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.naming;
+
+import org.apache.beehive.netui.script.ExpressionEvaluationException;
+import org.apache.beehive.netui.simpletags.core.Behavior;
+
+/**
+ * An interface that is used to allow interceptors to
+ * modify attributes that are going to be written to a
+ * client from a NetUI JSP tag.
+ * <br/>
+ * Several concrete implementations of this interface are
+ * provided in order to rewrite names on form tags as they
+ * are rendered to the browser.
+ * @see FormDataNameInterceptor
+ * @see IndexedNameInterceptor
+ * @see PrefixNameInterceptor
+ */
+public interface INameInterceptor
+{
+
+ /**
+ * @param name
+ * @param currentTag
+ * @return String
+ * @throws ExpressionEvaluationException
+ */
+ public String rewriteName(String name, Behavior currentTag) throws ExpressionEvaluationException;
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/INameInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/IndexedNameInterceptor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/IndexedNameInterceptor.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/IndexedNameInterceptor.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/IndexedNameInterceptor.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,225 @@
+/*
+ * 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.naming;
+
+// java imports
+
+import org.apache.beehive.netui.script.Expression;
+import org.apache.beehive.netui.script.ExpressionEvaluationException;
+import org.apache.beehive.netui.script.ExpressionEvaluator;
+import org.apache.beehive.netui.script.ExpressionEvaluatorFactory;
+import org.apache.beehive.netui.script.common.IDataAccessProvider;
+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.util.ContextUtils;
+import org.apache.beehive.netui.util.logging.Logger;
+
+import java.util.List;
+
+// external imports
+
+/**
+ * A {@link INameInterceptor} that is used to rewrite names which
+ * reference the <code>container</code> databinding context. This
+ * INameInterceptor is for use by tags that render form-updatable HTML
+ * elements. If the dataSource attribute of the tag references a
+ * <code>container</code> binding context, the name must be qualified
+ * into a real path down a bean / property hierarchy in order to
+ * correctly update that value on a POST. This INameInterceptor
+ * rewrites that name using the given name and the hierarchy of
+ * {@link org.apache.beehive.netui.script.common.IDataAccessProvider} tags in a JSP page.
+ */
+public class IndexedNameInterceptor
+ implements INameInterceptor
+{
+ private static final Logger _logger = Logger.getInstance(IndexedNameInterceptor.class);
+
+ /**
+ * Rewrite an expression into a fully-qualified reference to a specific JavaBean property
+ * on an object.
+ * @param name the expression to rewrite
+ * @param currentTag the current JSP tag that can be used as the leaf for walking up
+ * to find parent tags that provide information used to
+ * rewrite the expression.
+ */
+ public final String rewriteName(String name, Behavior currentTag)
+ throws ExpressionEvaluationException
+ {
+ if (_logger.isDebugEnabled()) _logger.debug("rewrite expression \"" + name + "\"");
+
+ IDataAccessProvider dap = getCurrentProvider(currentTag);
+ // if the DAP is null, there is no rewriting to do
+ if (dap == null)
+ return name;
+
+ // given a hierarchy of "container.container.container.item.someProp", the correct parent needs
+ // to be found so that expression rewriting can happen correctly.
+ //
+ // ensure that this expression contains container.item
+ Expression parsed = getExpressionEvaluator().parseExpression(name);
+ assert parsed != null;
+
+ int containerCount = 0;
+ List tokens = parsed.getTokens();
+ for (int i = 0; i < tokens.size(); i++) {
+ String tok = tokens.get(i).toString();
+ if (i == 0) {
+ if (!tok.equals("container"))
+ break;
+ else
+ continue;
+ }
+ // this skips the "current" IDataAccessProvider
+ else if (tok.equals("container"))
+ containerCount++;
+ else if (tok.equals("item"))
+ break;
+ }
+
+ if (_logger.isDebugEnabled()) _logger.debug("container parent count: " + containerCount);
+
+ // now walk up the DataAccessProvier hierarchy until the top-most parent is found
+ // the top-most parent is the first one that does not reference "container.item" but
+ // is bound directly to a specific object such as "actionForm" or "pageFlow". This
+ // handles the case where a set of nested IDataAccessProvider tags are "skipped" by
+ // an expression like "container.container.container.item.foo". In order to find
+ // the correct root to start rewriting the names, one needs to walk up three
+ // DAPs in order to find the correct root from which to start.
+ //
+ // In general, containerCount is zero here for the "container.item.foo" case.
+ for (int i = 0; i < containerCount; i++) {
+ dap = dap.getProviderParent();
+ }
+
+ // now, the top-most DAP parent is known
+ assert dap != null;
+
+ // strip off the "container.item" from the expression that is being rewritten
+ // this should be two tokens into the expression.
+ if (containerCount > 0) {
+ name = parsed.getExpression(containerCount);
+ }
+
+ // now, change the binding context of the parent DAP hierarchy to create a
+ // String that looks like "actionForm.customers[42].order[12].lineItem[2].name"
+ // note, this is done without using the expression that was passed-in and
+ // is derived entirely from the IDataAccessProvider parent hierarchy.
+ String parentNames = rewriteNameInternal(dap);
+
+ if (_logger.isDebugEnabled()) _logger.debug("name hierarchy: " + parentNames + " name: " + name);
+
+ // with a newly re-written expression prefix, substitute this fully-qualified binding
+ // string into the given expression for "container.item".
+ String newName = changeContext(name, "container.item", parentNames, dap.getCurrentIndex());
+
+ if (_logger.isDebugEnabled()) _logger.debug("rewrittenName: " + newName);
+
+ return newName;
+ }
+
+ /**
+ * A default method to find the "current" IDataAccessProvider. This method is
+ * left as non-final so that the implementation here can be tested
+ * outside of a servlet container.
+ */
+ protected IDataAccessProvider getCurrentProvider(Behavior tag)
+ {
+ TagContext tagCtxt = ContextUtils.getTagContext();
+ BehaviorStack stack = tagCtxt.getBehaviorStack();
+ return (IDataAccessProvider) stack.findAncestorWithClass(tag, IDataAccessProvider.class);
+ }
+
+ /**
+ * Rewrite a parent IDataAccessProvider's dataSource to be fully qualified.
+ *
+ * "container.container.container.container.item.foo" -> "DS1.DS2.DS3.DS4.foo"
+ */
+ private final String rewriteNameInternal(IDataAccessProvider dap)
+ throws ExpressionEvaluationException
+ {
+ if (_logger.isDebugEnabled())
+ _logger.debug("assign index to name: " + dap.getDataSource());
+
+ Expression parsedDataSource = getExpressionEvaluator().parseExpression(dap.getDataSource());
+ assert parsedDataSource != null;
+
+ boolean isContainerBound = (parsedDataSource.getTokens().get(0)).toString().equals("container");
+
+ // rewrite the name of the current IDataAccessProvider.
+ String parentName = null;
+ // if the current DAP has a parent IDataAccessProvider, rewrite the name of the parent
+ if (dap.getProviderParent() != null)
+ parentName = rewriteNameInternal(dap.getProviderParent());
+ // if the current DAP has no parent, or it does not reference the "container." binding context,
+ // we've found the "root" IDataAccessProvider
+ else if (dap.getProviderParent() == null || (dap.getProviderParent() != null && !isContainerBound)) {
+ return dap.getDataSource();
+ }
+
+ // now, we've found the root and can start rewriting the expressions throughout
+ // the rest of the DAP hierarchy
+ if (_logger.isDebugEnabled()) {
+ _logger.debug("changeContext: DAP.dataSource=" + dap.getDataSource() + " oldContext=container newContext=" +
+ parentName + " currentIndex=" + dap.getProviderParent().getCurrentIndex() +
+ " parentName is container: " + isContainerBound);
+ }
+
+ String retVal = null;
+ String ds = dap.getDataSource();
+
+ // If the current DAP's dataSource is "container.item", the binding context needs to change to that
+ // of the parent. This case should only occur for the last token -- the "name" passed into
+ // the method. Oterwise, just replace the "container" to that of the parent. Both are
+ // qualified with the DAP's current index so that "actionForm.customers" becomes
+ // "actionForm.customers[12]".
+
+ boolean isContainerItemBound = false;
+ if (isContainerBound && (parsedDataSource.getTokens().get(1)).toString().equals("item"))
+ isContainerItemBound = true;
+
+ if (isContainerItemBound)
+ retVal = changeContext(ds, "container.item", parentName, dap.getProviderParent().getCurrentIndex());
+ else
+ retVal = changeContext(ds, "container", parentName, dap.getProviderParent().getCurrentIndex());
+
+ if (_logger.isDebugEnabled()) _logger.debug("fully-qualified binding expression: \"" + retVal + "\"");
+
+ return retVal;
+ }
+
+ protected ExpressionEvaluator getExpressionEvaluator()
+ {
+ return ExpressionEvaluatorFactory.getInstance();
+ }
+
+ private final String changeContext(String dataSource, String oldContext, String newContext, int index)
+ throws ExpressionEvaluationException
+ {
+ try {
+ return getExpressionEvaluator().changeContext(dataSource, oldContext, newContext, index);
+ }
+ catch (ExpressionEvaluationException ee) {
+ if (_logger.isErrorEnabled())
+ _logger.error("An error occurred changing the binding context of the expression \"" +
+ dataSource + "\". Cause: " + ee, ee);
+
+ throw ee;
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/IndexedNameInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/PrefixNameInterceptor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/PrefixNameInterceptor.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/PrefixNameInterceptor.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/PrefixNameInterceptor.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,61 @@
+/*
+ * 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.naming;
+
+import org.apache.beehive.netui.script.ExpressionEvaluationException;
+import org.apache.beehive.netui.simpletags.core.Behavior;
+
+/**
+ * A {@link INameInterceptor} that is used to add a prefix handler onto a
+ * NetUI tag that is being written to the client. Occasionally, NetUI
+ * tags need to be pre-processed before passing the name and value
+ * to the {@link org.apache.beehive.netui.pageflow.ProcessPopulate} handler
+ * in order to update a bean property. This preprocessing is done by
+ * implementing a handler implementing the interface
+ * {@link org.apache.beehive.netui.pageflow.RequestParameterHandler}, registering
+ * this interface with the {@link org.apache.beehive.netui.pageflow.ProcessPopulate#registerPrefixHandler(String, org.apache.beehive.netui.pageflow.RequestParameterHandler)}
+ * method, and adding a prefix which references this RequestParameterHandler to the
+ * name of each paramter that should be handled by the implementation before
+ * updating the bean property.
+ */
+public class PrefixNameInterceptor implements INameInterceptor
+{
+ private String tagKey;
+
+ public PrefixNameInterceptor(String key)
+ {
+ tagKey = key;
+ }
+
+ protected PrefixNameInterceptor()
+ {
+ super();
+ }
+
+ public String rewriteName(String name, Behavior currentTag)
+ throws ExpressionEvaluationException
+ {
+ return rewriteNameInternal(name, tagKey);
+ }
+
+ protected String rewriteNameInternal(String name, String key)
+ throws ExpressionEvaluationException
+ {
+ return org.apache.beehive.netui.pageflow.ProcessPopulate.writeHandlerName(key, name);
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/naming/PrefixNameInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractAttributeState.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractAttributeState.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractAttributeState.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractAttributeState.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,139 @@
+/*
+ * 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.rendering;
+
+import org.apache.beehive.netui.util.Bundle;
+import org.apache.beehive.netui.util.logging.Logger;
+
+import java.util.HashMap;
+import java.util.Map;
+
+abstract public class AbstractAttributeState extends AbstractTagState
+{
+ private static final Logger logger = Logger.getInstance(AbstractAttributeState.class);
+
+ /**
+ * String constant for the empty string.
+ */
+ public static final String EMPTY_STRING = "";
+
+ /**
+ * The integer type constant indentifying the General Attributes <code>AbstractBaseTag</code>
+ * reserves 0-9 for indentification.
+ */
+ public static final int ATTR_GENERAL = 0;
+
+ private HashMap generalMap = null; // the map of general attributes
+
+ public HashMap getGeneralAttributeMap()
+ {
+ return generalMap;
+ }
+
+ /**
+ * This method will return the map that represents the passed in <code>type</code>. The boolean flag
+ * </code>createIfNull</code> indicates that the map should be created or not if it's null. This
+ * class defines two maps defined by <code>@see #ATTR_GENERAL</code> and <code>ATTR_GENERAL_EXPRESSION</code>
+ * @param type <code>integer</code> type indentifying the map to be created.
+ * @param createIfNull <code>boolean</code> flag indicating if the map should be created if it doesn't exist.
+ * @return The map or null
+ * @see #ATTR_GENERAL
+ */
+ public Map selectMap(int type, boolean createIfNull)
+ {
+ Map ret = null;
+ if (type == ATTR_GENERAL) {
+ if (generalMap == null && createIfNull)
+ generalMap = new HashMap();
+ ret = generalMap;
+ }
+
+ return ret;
+ }
+
+ public void clear()
+ {
+ if (generalMap != null)
+ generalMap.clear();
+ }
+
+ /**
+ * Register a name/value pair into a named attribute map. The base type
+ * supports the <code>ATTR_GENERAL<code> named map. Subclasses may add additional maps
+ * enabling attributes to be treated with different behavior.
+ * @param type an integer key identifying the map.
+ * @param attrName the name of the attribute
+ * @param value the value of the attribute
+ */
+ public void registerAttribute(int type, String attrName, String value, boolean ignoreEmpty)
+ {
+ assert(attrName != null);
+
+ // If the value is null or the empty string ignore the expression.
+ if (value == null)
+ return;
+ if (ignoreEmpty && "".equals(value))
+ return;
+
+ Map map = selectMap(type, true);
+ if (map == null) {
+ String s = Bundle.getString("Tags_ParameterAccessError",
+ new Object[]{new Integer(type), attrName});
+ logger.error(s);
+ return;
+ }
+ map.put(attrName, value);
+ }
+
+ public void registerAttribute(int type, String attrName, String value)
+ {
+ registerAttribute(type, attrName, value, true);
+ }
+
+ /**
+ * Remove a previously registered attribute value from map.
+ * @param type an integer key indentifying the map
+ * @param attrName the name of the attribute to remove from the specified map
+ */
+ public void removeAttribute(int type, String attrName)
+ {
+ Map map = selectMap(type, false);
+ if (map == null) {
+ String s = Bundle.getString("Tags_ParameterAccessError",
+ new Object[]{new Integer(type), attrName});
+ logger.error(s);
+ return;
+ }
+
+ map.remove(attrName);
+ }
+
+ /**
+ * Return a named attribute value from the specified attribute map.
+ * @param type an integer key indentifying the map
+ * @param attrName the name of the attribute we will get the value from.
+ * @return a string value of the attribute if set or null.
+ */
+ public String getAttribute(int type, String attrName)
+ {
+ Map map = selectMap(type, false);
+ if (map == null)
+ return null;
+ return (String) map.get(attrName);
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractAttributeState.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlControlState.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlControlState.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlControlState.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlControlState.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,20 @@
+package org.apache.beehive.netui.simpletags.rendering;
+
+/**
+ * This class adds the name attribute to the base HTML state. The name attribute
+ * is used by the HTML Controls as the control name. For all successful controls
+ * durinig a form post the name and value are posted back.
+ */
+abstract public class AbstractHtmlControlState extends AbstractHtmlState
+{
+ public String name;
+
+ /**
+ * Initialize the state values.
+ */
+ public void clear()
+ {
+ super.clear();
+ name = null;
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlControlState.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlState.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlState.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlState.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlState.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,95 @@
+/*
+ * 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.rendering;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class extends the <code>AbstractAttributeState</code> to add support for HTML.
+ * This class add support for the <code>id</code>, <code>style</code>, and <code>class</code>
+ * attributes. In addition, there is a <code>Map</code> that supports the JavaScript
+ * event attributes.
+ */
+public class AbstractHtmlState extends AbstractAttributeState
+{
+ /**
+ * Define the Attribute Map for the JavaScript event handler attributes.
+ */
+ public static final int ATTR_JAVASCRIPT = 12;
+
+ /**
+ * The HTML <code>id</code> attribute.
+ */
+ public String id;
+
+ /**
+ * The HTML <code>style</code> attribute.
+ */
+ public String style;
+
+ /**
+ * The HTML <code>class</code> attribute.
+ */
+ public String styleClass;
+
+ private HashMap _jsMap = null; // Map used to hold the registered JavaScript attributes.
+
+ /**
+ * Return the Map Containing the JavaScript entries.
+ * @return a <code>Map</code> of the JavaScript attributes.
+ */
+ public HashMap getEventMap()
+ {
+ return _jsMap;
+ }
+
+ /**
+ * Initialize the state.
+ */
+ public void clear()
+ {
+ super.clear();
+
+ if (_jsMap != null)
+ _jsMap.clear();
+
+ id = null;
+ style = null;
+ styleClass = null;
+ }
+
+ /**
+ * This method will return the map that represents the passed in <code>type</code>. The boolean flag
+ * </code>createIfNull</code> indicates that the map should be created or not if it's null. This
+ * class defines two maps defined by <code>@see #ATTR_STYLE</code> and <code>ATTR_JAVASCRIPT</code>
+ * @param type <code>integer</code> type indentifying the map to be created.
+ * @param createIfNull <code>boolean</code> flag indicating if the map should be created if it doesn't exist.
+ * @return The map or null
+ * @see #ATTR_JAVASCRIPT
+ */
+ public Map selectMap(int type, boolean createIfNull)
+ {
+ if (type == ATTR_JAVASCRIPT) {
+ if (_jsMap == null && createIfNull)
+ _jsMap = new HashMap();
+ return _jsMap;
+ }
+ return super.selectMap(type, createIfNull);
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractHtmlState.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractTagState.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractTagState.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractTagState.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractTagState.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,23 @@
+/*
+ * 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.rendering;
+
+abstract public class AbstractTagState
+{
+ abstract public void clear();
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AbstractTagState.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AnchorTag.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AnchorTag.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AnchorTag.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AnchorTag.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,92 @@
+/*
+ * 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.rendering;
+
+import org.apache.beehive.netui.simpletags.html.HtmlConstants;
+import org.apache.beehive.netui.simpletags.appender.Appender;
+
+import java.util.HashMap;
+
+/**
+ * Rendering for HTML anchor tags $lt;a>. In HTML 4.01 the start and end tags are both required.
+ * There are no required attributes.
+ */
+abstract public class AnchorTag extends TagHtmlBase implements HtmlConstants
+{
+ /**
+ * Add the Renderer for the HTML and XHTML tokens.
+ * @param html The map of HTML Tag Renderers
+ * @param xhtml The map of XHTML Tag Renderers
+ */
+ public static void add(HashMap html, HashMap htmlQuirks, HashMap xhtml)
+ {
+ html.put(ANCHOR_TAG, new Rendering());
+ htmlQuirks.put(ANCHOR_TAG, new Rendering());
+ xhtml.put(ANCHOR_TAG, new Rendering());
+ }
+
+ /**
+ * The State assocated with the Anchor Tag.
+ */
+ public static class State extends AbstractHtmlState
+ {
+ public String name;
+ public String href;
+
+ public void clear()
+ {
+ super.clear();
+
+ name = null;
+ href = null;
+ }
+ }
+
+ /**
+ * Private class implementation of of the Anchor Tag.
+ */
+ private static class Rendering extends AnchorTag
+ {
+ public void doStartTag(Appender sb, AbstractTagState renderState)
+ {
+ assert(sb != null) : "Parameter 'sb' must not be null";
+ assert(renderState != null) : "Parameter 'renderState' must not be null";
+ assert(renderState instanceof State) : "Paramater 'renderState' must be an instance of AnchorTag.State";
+
+ // convert to AnchorTag.State
+ State state = (State) renderState;
+
+ renderTag(sb, ANCHOR);
+ renderAttribute(sb, ID, state.id);
+ renderAttribute(sb, NAME, state.name);
+ renderAttribute(sb, HREF, state.href);
+
+ renderAttribute(sb, CLASS, state.styleClass);
+ renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state);
+ renderAttribute(sb, STYLE, state.style);
+
+ renderAttributes(AbstractHtmlState.ATTR_JAVASCRIPT, sb, state);
+ sb.append(">");
+ }
+
+ public void doEndTag(Appender sb)
+ {
+ renderEndTag(sb, ANCHOR);
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AnchorTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AreaTag.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AreaTag.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AreaTag.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AreaTag.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,72 @@
+package org.apache.beehive.netui.simpletags.rendering;
+
+import org.apache.beehive.netui.simpletags.html.HtmlConstants;
+import org.apache.beehive.netui.simpletags.appender.Appender;
+
+import java.util.HashMap;
+
+abstract public class AreaTag extends TagHtmlBase implements HtmlConstants
+{
+ /**
+ * Add the Renderer for the HTML and XHTML tokens.
+ * @param html The map of HTML Tag Renderers
+ * @param xhtml The map of XHTML Tag Renderers
+ */
+ public static void add(HashMap html, HashMap htmlQuirks, HashMap xhtml)
+ {
+ html.put(AREA_TAG, new HtmlRendering());
+ htmlQuirks.put(AREA_TAG, new HtmlRendering());
+ xhtml.put(AREA_TAG, new XhtmlRendering());
+ }
+
+ public void doStartTag(Appender sb, AbstractTagState renderState)
+ {
+ assert(sb != null) : "Parameter 'sb' must not be null";
+ assert(renderState != null) : "Parameter 'renderState' must not be null";
+ assert(renderState instanceof AnchorTag.State) : "Paramater 'renderState' must be an instance of AnchorTag.State:"
+ + renderState.getClass().getName();
+
+ AnchorTag.State state = (AnchorTag.State) renderState;
+
+ renderTag(sb, AREA);
+ renderAttribute(sb, ID, state.id);
+ renderAttribute(sb, NAME, state.name);
+ renderAttribute(sb, HREF, state.href);
+
+ renderAttribute(sb, CLASS, state.styleClass);
+ renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state);
+ renderAttribute(sb, STYLE, state.style);
+
+ //String onclick = state.getAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK);
+ //if (onclick != null)
+ // state.removeAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK);
+ renderAttributes(AbstractHtmlState.ATTR_JAVASCRIPT, sb, state);
+
+ // backward compat for a second
+ //renderAttributeSingleQuotes(sb, ONCLICK, onclick);
+
+ writeEnd(sb);
+ }
+
+ public void doEndTag(Appender sb)
+ {
+ }
+
+ abstract protected void writeEnd(Appender sb);
+
+ private static class HtmlRendering extends AreaTag
+ {
+ protected void writeEnd(Appender sb)
+ {
+ sb.append(">");
+ }
+ }
+
+ private static class XhtmlRendering extends AreaTag
+ {
+ protected void writeEnd(Appender sb)
+ {
+ sb.append(" />");
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/AreaTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BaseTag.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BaseTag.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BaseTag.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BaseTag.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,94 @@
+/*
+ * 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.rendering;
+
+import org.apache.beehive.netui.simpletags.html.HtmlConstants;
+import org.apache.beehive.netui.simpletags.appender.Appender;
+
+import java.util.HashMap;
+
+/**
+ * Render the HTML <base> tag. This is the document base URI.
+ * In HTML 4.01 the start tag is required and the end tag forbidden.
+ * The tag will be rendered as a single tag. The href attribute is required in HTML 4.01 and optional
+ * in XHTML.
+ */
+public abstract class BaseTag extends TagHtmlBase implements HtmlConstants
+{
+ public static void add(HashMap html, HashMap htmlQuirks, HashMap xhtml)
+ {
+ html.put(BASE_TAG, new HtmlRendering());
+ htmlQuirks.put(BASE_TAG, new HtmlRendering());
+ xhtml.put(BASE_TAG, new XhtmlRendering());
+ }
+
+ public static class State extends AbstractAttributeState
+ {
+ public String target;
+ public String href;
+
+ public void clear()
+ {
+ super.clear();
+
+ target = null;
+ href = null;
+ }
+ }
+
+ public void doStartTag(Appender sb, AbstractTagState renderState)
+ {
+ assert(sb != null) : "Parameter 'sb' must not be null";
+ assert(renderState != null) : "Parameter 'renderState' must not be null";
+ assert(renderState instanceof BaseTag.State) : "Paramater 'renderState' must be an instance of Base.State";
+
+ State state = (State) renderState;
+
+ renderTag(sb, BASE);
+ renderAttribute(sb, HREF, state.href);
+ renderAttribute(sb, TARGET, state.target);
+
+ // These are not actually used by the <base> tag, but may be set by external sources.
+ renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state);
+ writeEnd(sb);
+ }
+
+ public void doEndTag(Appender sb)
+ {
+ // do nothing...
+ }
+
+ abstract protected void writeEnd(Appender sb);
+
+
+ private static class HtmlRendering extends BaseTag
+ {
+ protected void writeEnd(Appender sb)
+ {
+ sb.append(">");
+ }
+ }
+
+ private static class XhtmlRendering extends BaseTag
+ {
+ protected void writeEnd(Appender sb)
+ {
+ sb.append(" />");
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BaseTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BodyTag.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BodyTag.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BodyTag.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BodyTag.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,71 @@
+/*
+ * 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.rendering;
+
+import org.apache.beehive.netui.simpletags.html.HtmlConstants;
+import org.apache.beehive.netui.simpletags.appender.Appender;
+
+import java.util.HashMap;
+
+/**
+ * Render the HTML <body> tag. In HTML 4.01 both the start and end tag are optional. This
+ * renderer will write both. There are no required attributes.
+ */
+public abstract class BodyTag extends TagHtmlBase
+{
+ public static void add(HashMap html, HashMap htmlQuirks, HashMap xhtml)
+ {
+ html.put(BODY_TAG, new Rendering());
+ htmlQuirks.put(BODY_TAG, new Rendering());
+ xhtml.put(BODY_TAG, new Rendering());
+ }
+
+ public static class State extends AbstractHtmlState
+ {
+ public void clear()
+ {
+ super.clear();
+ }
+ }
+
+ private static class Rendering extends BodyTag implements HtmlConstants
+ {
+ public void doStartTag(Appender sb, AbstractTagState renderState)
+ {
+ assert(sb != null) : "Parameter 'sb' must not be null";
+ assert(renderState != null) : "Parameter 'renderState' must not be null";
+ assert(renderState instanceof State) : "Paramater 'renderState' must be an instance of BodyTag.State";
+
+ State state = (State) renderState;
+
+ renderTag(sb, BODY);
+ renderAttribute(sb, ID, state.id);
+ renderAttribute(sb, CLASS, state.styleClass);
+
+ renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state);
+ renderAttribute(sb, STYLE, state.style);
+ renderAttributes(AbstractHtmlState.ATTR_JAVASCRIPT, sb, state);
+ sb.append(">");
+ }
+
+ public void doEndTag(Appender sb)
+ {
+ renderEndTag(sb, BODY);
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/rendering/BodyTag.java
------------------------------------------------------------------------------
svn:eol-style = native