Author: dolander
Date: Sun Feb 20 15:15:48 2005
New Revision: 154571
URL: http://svn.apache.org/viewcvs?view=rev&rev=154571
Log:
Added the Behavior tag and the IBehaviorConsumer.
Added BVT that verifies it can be used and reports errors.
Added:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/IBehaviorConsumer.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Behavior.java
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/Controller.jpf
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/index.jsp
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/CtBehaviorNullBinding.xml
Modified:
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Added:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/IBehaviorConsumer.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/IBehaviorConsumer.java?view=auto&rev=154571
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/IBehaviorConsumer.java
(added)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/IBehaviorConsumer.java
Sun Feb 20 15:15:48 2005
@@ -0,0 +1,22 @@
+package org.apache.beehive.netui.tags;
+
+import javax.servlet.jsp.JspException;
+
+/**
+ * This interfaces is implemented by tags that allow a behavior to
+ * added and/or modified through an open ended set of name/value pairs.
+ */
+public interface IBehaviorConsumer
+{
+ /**
+ * Set a behavior value on the implementing class. The <code>name</code>
represents
+ * the name of the behavior. The <code>value</code> represents the value.
+ * The <code>facet</code> is optional and may be used by complex types to
+ * target the behavior.
+ * @param name The name of the behavior. This value may not be null or
the empty string.
+ * @param value The value of the behavior.
+ * @param facet The name of a facet to which the attribute will be
applied. This is optional.
+ * @throws JspException A JspException may be thrown if there is an error
setting the attribute.
+ */
+ void setAttribute(String name, String value, String facet) throws
JspException;
+}
Added:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Behavior.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Behavior.java?view=auto&rev=154571
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Behavior.java
(added)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Behavior.java
Sun Feb 20 15:15:48 2005
@@ -0,0 +1,115 @@
+/*
+ * 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.tags.html;
+
+import org.apache.beehive.netui.tags.AbstractSimpleTag;
+import org.apache.beehive.netui.tags.IBehaviorConsumer;
+import org.apache.beehive.netui.util.Bundle;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.JspTag;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+
+/**
+ * @netui:tag name="behavior" body-content="empty" description="Add an
attribute to the parent tag which be rendered."
+ * @netui.tldx:tag renderer="workshop.netui.jspdesigner.tldx.AttributeRenderer"
+ * bodycontentpref="empty" whitespace="indent"
+ */
+public class Behavior extends AbstractSimpleTag
+{
+ private String _name = null;
+ private String _value = null;
+ private String _facet = null;
+
+ /**
+ * Return the name of the Tag.
+ */
+ public String getTagName()
+ {
+ return "Behavior";
+ }
+
+ /**
+ * Sets the <code>name</code> behavior.
+ * @param name - the value of the <code>name</code> behavior.
+ * @jsptagref.attributedescription The name of the behavior to add to the
parent tag.
+ * @jsptagref.databindable false
+ * @jsptagref.attributesyntaxvalue <i>string_name</i>
+ * @netui:attribute required="true" rtexprvalue="true"
+ * description="The name of the behavior to add to the parent tag."
+ * @netui.tldx:attribute
+ */
+ public void setName(String name)
+ throws JspException
+ {
+ _name = setRequiredValueAttribute(name, "name");
+ }
+
+ /**
+ * Sets the <code>value</code> behavior.
+ * @param value - the value of the <code>name</code> behavior.
+ * @jsptagref.attributedescription The value of the behavior to add to the
parent tag.
+ * @jsptagref.databindable true
+ * @jsptagref.attributesyntaxvalue <i>string_or_expression_value</i>
+ * @netui:attribute required="true" rtexprvalue="true"
+ * description="The value of the behavior to add to the parent tag."
+ * @netui.tldx:attribute
+ */
+ public void setValue(String value)
+ {
+ _value = setNonEmptyValueAttribute(value);
+ }
+
+ /**
+ * Sets the <code>facet</code> behavior.
+ * @param facet - the value of the <code>facet</code> attribute.
+ * @netui:attribute rtexprvalue="true"
+ * description="The name of the facet targetted by the behavior."
+ * @netui.tldx:attribute
+ */
+ public void setFacet(String facet)
+ throws JspException
+ {
+ _facet = setRequiredValueAttribute(facet, "facet");
+ }
+
+ /**
+ * Add the name/value pair to the IBehaviorConsumer parent of the tag.
+ * @throws JspException if a JSP exception has occurred
+ */
+ public void doTag()
+ throws JspException
+ {
+ if (hasErrors()) {
+ reportErrors();
+ return;
+ }
+
+ JspTag tag = SimpleTagSupport.findAncestorWithClass(this,
IBehaviorConsumer.class);
+ if (tag == null) {
+ String s = Bundle.getString("Tags_BehaviorInvalidParent");
+ registerTagError(s, null);
+ reportErrors();
+ return;
+ }
+
+ IBehaviorConsumer ac = (IBehaviorConsumer) tag;
+ ac.setAttribute(_name, _value, _facet);
+ return;
+ }
+}
Modified:
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties?view=diff&r1=154570&r2=154571
==============================================================================
---
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties
(original)
+++
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties
Sun Feb 20 15:15:48 2005
@@ -80,6 +80,7 @@
Tags_AttributeNameNotSet=The paramater "<b>name</b>" may not be null or the
empty string.
Tags_AttributeFacetNotSupported=The facet "<b>{0}</b>" is not supported by
this tag.
Tags_AttributeInvalidParent=The parent tag of this "<b>attribute</b>" does not
support dynamic attributes.
+Tags_BehaviorInvalidParent=The parent tag of this "<b>behavior</b>" does not
support dynamic behaviors.
Tags_ButtonText=Click
Tags_ButtonTypeError=The type of a button must be one of 'submit', 'button' or
'reset', found ''{0}''.
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/Controller.jpf?view=auto&rev=154571
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/Controller.jpf
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/Controller.jpf
Sun Feb 20 15:15:48 2005
@@ -0,0 +1,70 @@
+/*
+ * 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 coretags.behavior.nullbinding;
+
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+/**
+ * This is the default controller for a blank web application.
+ */
[EMAIL PROTECTED]
[EMAIL PROTECTED](
+ value = {
+ "<!-- This data is auto-generated. Hand-editing this section is not
recommended. -->",
+ "<view-properties>",
+ "<pageflow-object
id='pageflow:/coretags/base/nullbinding/Controller.jpf'/>",
+ "<pageflow-object id='action:begin.do'>",
+ " <property value='80' name='x'/>",
+ " <property value='100' name='y'/>",
+ "</pageflow-object>",
+ "<pageflow-object id='page:index.jsp'>",
+ " <property value='220' name='x'/>",
+ " <property value='100' name='y'/>",
+ "</pageflow-object>",
+ "<pageflow-object id='forward:[EMAIL PROTECTED]:begin.do@'>",
+ " <property value='116,140,140,164' name='elbowsX'/>",
+ " <property value='92,92,92,92' name='elbowsY'/>",
+ " <property value='East_1' name='fromPort'/>",
+ " <property value='West_1' name='toPort'/>",
+ " <property value='index' name='label'/>",
+ "</pageflow-object>",
+ "</view-properties>"
+ }
+)
+public class Controller extends PageFlowController
+{
+ private String _nullValue = null;
+
+ public String getNullValue() {
+ return _nullValue;
+ }
+
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="index", path="index.jsp")
+ }
+ )
+ protected Forward begin()
+ {
+ return new Forward("index");
+ }
+
+
+}
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/index.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/index.jsp?view=auto&rev=154571
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/index.jsp
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/behavior/nullbinding/index.jsp
Sun Feb 20 15:15:48 2005
@@ -0,0 +1,25 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+<netui:html>
+ <head>
+ <netui:base />
+ </head>
+ <netui:body>
+ <h4>Null binding in the Beehavior tag</h4>
+ <p style="color:green">This test verifies that values bound to the
+ Behavior tag are handled correctly. In the first two, both <b>name</b>
+ and <b>facet</b> are required to provide a value. These will report
+ an error. The third case generates an error because the parent
+ doesn't support IBehaviorConsumer.
+ <br>
+ This is a single page test.
+ </p>
+ <ul>
+ <li><netui:behavior name="${pageFlow.nullValue}" value="nullName"/></li>
+ <li><netui:behavior name="nullFacet" facet="${pageFlow.nullValue}"
value="nullFacet"/></li>
+ <li><netui:behavior name="nullValue" value="${pageFlow.nullValue}"/></li>
+ </ul>
+ </netui:body>
+</netui:html>
+
+
Modified:
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&r1=154570&r2=154571
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
(original)
+++
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Sun Feb 20 15:15:48 2005
@@ -1992,6 +1992,20 @@
</features>
</test>
<test>
+ <name>CtBehaviorNullBinding</name>
+ <description>Binding to null in the Behavior tags
attributes</description>
+ <webapp>coreWeb</webapp>
+ <categories>
+ <category>bvt</category>
+ <category>bvt.struts11</category>
+ <category>tags</category>
+ </categories>
+ <features>
+ <feature>Behavior</feature>
+ <feature>Binding</feature>
+ </features>
+ </test>
+ <test>
<name>CtBindingNullBinding</name>
<description>Binding to null in the BindingUpdateErrors tags
attributes</description>
<webapp>coreWeb</webapp>
Added:
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/CtBehaviorNullBinding.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/CtBehaviorNullBinding.xml?view=auto&rev=154571
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/CtBehaviorNullBinding.xml
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/CtBehaviorNullBinding.xml
Sun Feb 20 15:15:48 2005
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ses:recorderSession
xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session">
+ <ses:sessionName>CtBehaviorNullBinding</ses:sessionName>
+ <ses:tester>Daryl</ses:tester>
+ <ses:startDate>20 Feb 2005, 03:52:25.671 PM MST</ses:startDate>
+ <ses:description>Basic test of the null binding errors in a
behavior.</ses:description>
+ <ses:tests>
+ <ses:test>
+ <ses:testNumber>1</ses:testNumber>
+ <ses:request>
+ <ses:protocol>HTTP</ses:protocol>
+ <ses:protocolVersion>1.1</ses:protocolVersion>
+ <ses:host>localhost</ses:host>
+ <ses:port>8080</ses:port>
+
<ses:uri>/coreWeb/coretags/behavior/nullbinding/Controller.jpf</ses:uri>
+ <ses:method>GET</ses:method>
+ <ses:parameters/>
+ <ses:cookies>
+ <ses:cookie>
+ <ses:name>JSESSIONID</ses:name>
+ <ses:value>79360B72B2731A3371646424A76503BA</ses:value>
+ </ses:cookie>
+ </ses:cookies>
+ <ses:headers>
+ <ses:header>
+ <ses:name>---------------</ses:name>
+ <ses:value>------------</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept</ses:name>
+
<ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-charset</ses:name>
+ <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-language</ses:name>
+ <ses:value>en-us,en;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>connection</ses:name>
+ <ses:value>keep-alive</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>cookie</ses:name>
+
<ses:value>JSESSIONID=79360B72B2731A3371646424A76503BA</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>host</ses:name>
+ <ses:value>localhost:8080</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>keep-alive</ses:name>
+ <ses:value>300</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>user-agent</ses:name>
+ <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.7.5) Gecko/20041107 Firefox/1.0</ses:value>
+ </ses:header>
+ </ses:headers>
+ </ses:request>
+ <ses:response>
+ <ses:statusCode>200</ses:statusCode>
+ <ses:reason/>
+ <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+
+ <head>
+ <base
href="http://localhost:8080/coreWeb/coretags/behavior/nullbinding/index.jsp">
+ </head>
+ <body>
+ <h4>Null binding in the Beehavior tag</h4>
+ <p style="color:green">This test verifies that values bound to the
+ Behavior tag are handled correctly. In the first two, both <b>name</b>
+ and <b>facet</b> are required to provide a value. These will report
+ an error. The third case generates an error because the parent
+ doesn't support IBehaviorConsumer.
+ <br>
+ This is a single page test.
+ </p>
+ <ul>
+ <li><span style="color:red;background-color:white">
+ [<b>Tag Error:1</b>, Found in tag <b>Behavior</b>]</span></li>
+ <li><span style="color:red;background-color:white">
+ [<b>Tag Error:2</b>, Found in tag <b>Behavior</b>]</span></li>
+ <li><span style="color:red;background-color:white">
+ [<b>Tag Error:3</b>, Found in tag <b>Behavior</b>]</span></li>
+ </ul>
+ <div> <hr /><table border="1" cellspacing="0"
style="color:red;background-color:white">
+ <tr><th colspan="6">Page Errors</th></tr>
+ <tr><th>Error Number</th><th>Tag Type</th><th colspan="4">Error</th></tr>
+<tr><th>1</th><th>Behavior</th><th>Message</th><td>Attribute 'name' is
required to have a value. The value "" is illegal. This is often cause by
binding to an object with a null value.</td></tr>
+<tr><th>2</th><th>Behavior</th><th>Message</th><td>Attribute 'facet' is
required to have a value. The value "" is illegal. This is often cause by
binding to an object with a null value.</td></tr>
+<tr><th>3</th><th>Behavior</th><th>Message</th><td>The parent tag of this
"<b>behavior</b>" does not support dynamic behaviors.</td></tr>
+</table></div>
+</body>
+
+</html>]]></ses:responseBody>
+ </ses:response>
+ </ses:test>
+ </ses:tests>
+ <ses:endDate>20 Feb 2005, 03:52:32.421 PM MST</ses:endDate>
+ <ses:testCount>1</ses:testCount>
+</ses:recorderSession>
\ No newline at end of file