Author: dolander
Date: Sun Aug 8 20:49:39 2004
New Revision: 36091
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractSimpleTag.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FileUpload.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatDate.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatNumber.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatString.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatTag.java
Log:
Cleanup the Form and FileUpLoad tags
Convert the Format tags to be SimpleTags
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractSimpleTag.java
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractSimpleTag.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractSimpleTag.java
Sun Aug 8 20:49:39 2004
@@ -3,6 +3,7 @@
import org.apache.beehive.netui.util.Bundle;
import org.apache.beehive.netui.util.logging.Logger;
import org.apache.struts.util.RequestUtils;
+import org.apache.struts.Globals;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
@@ -13,6 +14,7 @@
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
+import java.util.Locale;
/**
*
@@ -76,6 +78,20 @@
protected final String setNonEmptyValueAttribute(String attrValue)
{
return ("".equals(attrValue)) ? null : attrValue;
+ }
+
+ /**
+ * This method will return the user local of the request.
+ * @return the Locale object to use when rendering this tag
+ */
+ protected Locale getUserLocale()
+ {
+ PageContext pageContext = getPageContext();
+ Locale userLocale = (Locale)
pageContext.getAttribute(Globals.LOCALE_KEY, PageContext.SESSION_SCOPE);
+ if (userLocale == null)
+ return pageContext.getRequest().getLocale();
+ else
+ return userLocale;
}
/**
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FileUpload.java
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FileUpload.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FileUpload.java
Sun Aug 8 20:49:39 2004
@@ -260,11 +260,8 @@
idScript = addTagIdMapping(tagId, realName);
}
- if (hasErrors()) {
- reportErrors();
- localRelease();
- return EVAL_PAGE;
- }
+ if (hasErrors())
+ return reportAndExit(EVAL_PAGE);
StringBuilder results = new StringBuilder(32);
TagRenderingBase br =
TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_FILE_TAG, req);
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
Sun Aug 8 20:49:39 2004
@@ -576,14 +576,9 @@
*/
public int doStartTag() throws JspException
{
- // report all errors in the attributes. If the values are in error
then we will
- // not process the form content.
- if (hasErrors()) {
- reportErrors();
- _reportedError=true;
+ if (hasErrors())
return SKIP_BODY;
- }
-
+
// Error out if there is a parent form
// @todo: should this just be a design time test?
if (getNearestForm() != null) {
@@ -592,11 +587,8 @@
// Look up the form bean name, scope, and type if necessary
lookup();
- if (hasErrors()) {
- reportErrors();
- _reportedError=true;
+ if (hasErrors())
return SKIP_BODY;
- }
// Create an appropriate "form" element based on our parameters
HttpServletRequest request = (HttpServletRequest)
pageContext.getRequest();
@@ -645,11 +637,8 @@
}
}
- if (hasErrors()) {
- reportErrors();
- _reportedError=true;
- return SKIP_BODY;
- }
+ if (hasErrors())
+ return SKIP_BODY;
if (bean instanceof ActionForm) {
((ActionForm) bean).reset(_mapping, request);
@@ -692,10 +681,9 @@
*/
public int doEndTag() throws JspException
{
- if (_reportedError) {
- localRelease();
- return EVAL_PAGE;
- }
+ if (hasErrors())
+ return reportAndExit(EVAL_PAGE);
+
String idScript = null;
// Create an appropriate "form" element based on our parameters
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatDate.java
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatDate.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatDate.java
Sun Aug 8 20:49:39 2004
@@ -22,7 +22,7 @@
import org.apache.beehive.netui.util.logging.Logger;
import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.JspTag;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
@@ -185,7 +185,7 @@
* <netui:formatDate pattern="MM/dd/yyyy" />
* </netui:label></pre>
*
- * @netui:tag name="formatDate" description="A formatter used to format dates."
+ * @netui:tag name="formatDate" body-content="empty" description="A formatter
used to format dates."
* @netui.tldx:tag requiredparent="label select textArea textBox
data:anchorColumn data:basicColumn data:expressionColumn"
* requiredchild="#nothing"
* renderer="workshop.netui.jspdesigner.tldx.FormatDateRenderer"
@@ -233,9 +233,10 @@
* Create the internal Formatter instance and perform the formatting.
* @throws JspException if a JSP exception has occurred
*/
- public int doStartTag() throws JspException
+ public void doTag()
+ throws JspException
{
- Tag parentTag = getParent();
+ JspTag parentTag = getParent();
// if there are errors we need to either add these to the parent
AbstractBastTag or report an error.
if (hasErrors()) {
@@ -244,8 +245,7 @@
parent.formatterHasError();
}
reportErrors();
- localRelease();
- return SKIP_BODY;
+ return;
}
if (parentTag instanceof Formattable) {
@@ -261,9 +261,6 @@
registerTagError(s,null);
reportErrors();
}
-
- localRelease();
- return SKIP_BODY;
}
/**
@@ -390,14 +387,5 @@
return formattedString.toString();
}
- }
-
- /**
- * Release any acquired resources.
- */
- protected void localRelease()
- {
- super.localRelease();
- _stringInput = null;
}
}
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatNumber.java
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatNumber.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatNumber.java
Sun Aug 8 20:49:39 2004
@@ -21,7 +21,7 @@
import org.apache.beehive.netui.util.Bundle;
import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.JspTag;
import java.text.DecimalFormat;
import java.util.Locale;
@@ -105,7 +105,7 @@
* <netui:formatNumber country="US" language="en" type="currency" />
* </netui:label></pre>
*
- * @netui:tag name="formatNumber" description="A formatter used to format
numbers."
+ * @netui:tag name="formatNumber" body-content="empty" description="A
formatter used to format numbers."
* @netui.tldx:tag requiredparent="label select textArea textBox
data:anchorColumn data:basicColumn data:expressionColumn"
* requiredchild="#nothing"
* renderer="workshop.netui.jspdesigner.tldx.FormatNumberRenderer"
@@ -155,9 +155,10 @@
* Create the internal Formatter instance and perform the formatting.
* @throws JspException if a JSP exception has occurred
*/
- public int doStartTag() throws JspException
+ public void doTag()
+ throws JspException
{
- Tag parentTag = getParent();
+ JspTag parentTag = getParent();
// if there are errors we need to either add these to the parent
AbstractBastTag or report an error.
if (hasErrors()) {
@@ -166,8 +167,7 @@
parent.formatterHasError();
}
reportErrors();
- localRelease();
- return SKIP_BODY;
+ return;
}
// if there are no errors then add this to the parent as a formatter.
@@ -184,17 +184,6 @@
registerTagError(s,null);
reportErrors();
}
- localRelease();
- return SKIP_BODY;
- }
-
- /**
- * Release any acquired resources.
- */
- protected void localRelease()
- {
- super.localRelease();
- _type = null;
}
/**
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatString.java
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatString.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatString.java
Sun Aug 8 20:49:39 2004
@@ -22,6 +22,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.JspTag;
//java imports
@@ -93,7 +94,7 @@
* <netui:formatString pattern="phone (###) ###-####"/>
* </netui:label> </pre>
*
- * @netui:tag name="formatString" description="A formatter used to format
strings."
+ * @netui:tag name="formatString" body-content="empty" description="A
formatter used to format strings."
* @netui.tldx:tag requiredparent="label select textArea textBox
data:anchorColumn data:basicColumn data:expressionColumn"
* requiredchild="#nothing"
* renderer="workshop.netui.jspdesigner.tldx.FormatStringRenderer"
@@ -134,9 +135,10 @@
* Create the internal Formatter instance and perform the formatting.
* @throws JspException if a JSP exception has occurred
*/
- public int doStartTag() throws JspException
+ public void doTag()
+ throws JspException
{
- Tag parentTag = getParent();
+ JspTag parentTag = getParent();
// if there are errors we need to either add these to the parent
AbstractBastTag or report an error.
if (hasErrors()) {
@@ -145,8 +147,7 @@
parent.formatterHasError();
}
reportErrors();
- localRelease();
- return SKIP_BODY;
+ return;
}
if (parentTag instanceof Formattable) {
@@ -161,18 +162,6 @@
registerTagError(s,null);
reportErrors();
}
-
- localRelease();
- return SKIP_BODY;
- }
-
- /**
- * Release any acquired resources.
- */
- protected void localRelease()
- {
- super.localRelease();
- truncate = false;
}
/**
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatTag.java
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatTag.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FormatTag.java
Sun Aug 8 20:49:39 2004
@@ -18,10 +18,8 @@
*/
package org.apache.beehive.netui.tags.html;
-import org.apache.beehive.netui.tags.AbstractClassicTag;
import org.apache.beehive.netui.tags.AbstractSimpleTag;
import org.apache.beehive.netui.util.Bundle;
-import org.apache.beehive.netui.util.logging.Logger;
import javax.servlet.jsp.JspException;
import java.util.Locale;
@@ -30,7 +28,7 @@
* Abstract base class for formatting tags. Provides the basic formatting
properties,
* as well as the base for the internal FormatTag.Formatter class.
*/
-public abstract class FormatTag extends AbstractClassicTag
+public abstract class FormatTag extends AbstractSimpleTag
{
private String _language = null;
private String _country = null;
@@ -93,36 +91,6 @@
throws JspException
{
_pattern = setRequiredValueAttribute(pattern,"patttern");
- }
-
- /**
- * Create the internal Formatter instance and perform the formatting.
- * @throws JspException if a JSP exception has occurred
- */
- /*
- public int doStartTag() throws JspException
- {
- Tag parentTag = getParent();
- if (parentTag instanceof Formattable) {
- Formatter formatter = new Formatter();
- formatter.setPattern(_pattern);
- Formattable parent = (Formattable) parentTag;
- parent.addFormatter(formatter);
- }
- localRelease();
- return SKIP_BODY;
- }
- */
-
- /**
- * Release any acquired resources.
- */
- protected void localRelease()
- {
- super.localRelease();
- _language = null;
- _country = null;
- _pattern = null;
}
/**