oalexeev 01/07/24 04:42:15
Modified: src/share/org/apache/struts/taglib/html SubmitTag.java
SelectTag.java LocalStrings.properties LinkTag.java
CheckboxTag.java ButtonTag.java BaseHandlerTag.java
BaseFieldTag.java
Log:
Add support for indexed tags in html taglib.
Submitted by David Hay
Revision Changes Path
1.4 +47 -44
jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java
Index: SubmitTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SubmitTag.java 2001/04/18 01:31:15 1.3
+++ SubmitTag.java 2001/07/24 11:42:15 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java,v 1.3
2001/04/18 01:31:15 craigmcc Exp $
- * $Revision: 1.3 $
- * $Date: 2001/04/18 01:31:15 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java,v 1.4
2001/07/24 11:42:15 oalexeev Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/07/24 11:42:15 $
*
* ====================================================================
*
@@ -70,13 +70,14 @@
import javax.servlet.jsp.JspWriter;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.ResponseUtils;
+import org.apache.struts.util.RequestUtils;
+import org.apache.struts.taglib.logic.IterateTag;
-
/**
* Tag for input fields of type "submit".
*
* @author Craig R. McClanahan
- * @version $Revision: 1.3 $ $Date: 2001/04/18 01:31:15 $
+ * @version $Revision: 1.4 $ $Date: 2001/07/24 11:42:15 $
*/
public class SubmitTag extends BaseHandlerTag {
@@ -118,7 +119,7 @@
*/
public String getProperty() {
- return (this.property);
+ return (this.property);
}
@@ -130,7 +131,7 @@
*/
public void setProperty(String property) {
- this.property = property;
+ this.property = property;
}
@@ -140,7 +141,7 @@
*/
public String getValue() {
- return (this.value);
+ return (this.value);
}
@@ -152,7 +153,7 @@
*/
public void setValue(String value) {
- this.value = value;
+ this.value = value;
}
@@ -167,9 +168,9 @@
*/
public int doStartTag() throws JspException {
- // Do nothing until doEndTag() is called
+ // Do nothing until doEndTag() is called
this.text = null;
- return (EVAL_BODY_TAG);
+ return (EVAL_BODY_TAG);
}
@@ -199,40 +200,42 @@
*/
public int doEndTag() throws JspException {
- // Acquire the label value we will be generating
- String label = value;
- if ((label == null) && (text != null))
- label = text;
- if ((label == null) || (label.length() < 1))
- label = "Submit";
-
- // Generate an HTML element
- StringBuffer results = new StringBuffer();
- results.append("<input type=\"submit\" name=\"");
- results.append(property);
- results.append("\"");
- if (accesskey != null) {
- results.append(" accesskey=\"");
- results.append(accesskey);
- results.append("\"");
- }
- if (tabindex != null) {
- results.append(" tabindex=\"");
- results.append(tabindex);
- results.append("\"");
- }
- results.append(" value=\"");
- results.append(label);
- results.append("\"");
- results.append(prepareEventHandlers());
- results.append(prepareStyles());
- results.append(">");
+ // Acquire the label value we will be generating
+ String label = value;
+ if ((label == null) && (text != null))
+ label = text;
+ if ((label == null) || (label.length() < 1))
+ label = "Submit";
+
+ // Generate an HTML element
+ StringBuffer results = new StringBuffer();
+ results.append("<input type=\"submit\" name=\"");
+ results.append(property);
+ if( indexed )
+ prepareIndex( results, null );
+ results.append("\"");
+ if (accesskey != null) {
+ results.append(" accesskey=\"");
+ results.append(accesskey);
+ results.append("\"");
+ }
+ if (tabindex != null) {
+ results.append(" tabindex=\"");
+ results.append(tabindex);
+ results.append("\"");
+ }
+ results.append(" value=\"");
+ results.append(label);
+ results.append("\"");
+ results.append(prepareEventHandlers());
+ results.append(prepareStyles());
+ results.append(">");
- // Render this element to our writer
+ // Render this element to our writer
ResponseUtils.write(pageContext, results.toString());
// Evaluate the remainder of this page
- return (EVAL_PAGE);
+ return (EVAL_PAGE);
}
@@ -242,10 +245,10 @@
*/
public void release() {
- super.release();
- property = "submit";
+ super.release();
+ property = "submit";
text = null;
- value = null;
+ value = null;
}
1.7 +85 -83
jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java
Index: SelectTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SelectTag.java 2001/07/16 00:44:55 1.6
+++ SelectTag.java 2001/07/24 11:42:15 1.7
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java,v 1.6
2001/07/16 00:44:55 craigmcc Exp $
- * $Revision: 1.6 $
- * $Date: 2001/07/16 00:44:55 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java,v 1.7
2001/07/24 11:42:15 oalexeev Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/07/24 11:42:15 $
*
* ====================================================================
*
@@ -81,7 +81,7 @@
* inside a form tag.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.6 $ $Date: 2001/07/16 00:44:55 $
+ * @version $Revision: 1.7 $ $Date: 2001/07/24 11:42:15 $
*/
public class SelectTag extends BaseHandlerTag {
@@ -110,11 +110,11 @@
protected String multiple = null;
public String getMultiple() {
- return (this.multiple);
+ return (this.multiple);
}
public void setMultiple(String multiple) {
- this.multiple = multiple;
+ this.multiple = multiple;
}
@@ -124,11 +124,11 @@
protected String name = Constants.BEAN_KEY;
public String getName() {
- return (this.name);
+ return (this.name);
}
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
@@ -151,11 +151,11 @@
protected String size = null;
public String getSize() {
- return (this.size);
+ return (this.size);
}
public void setSize(String size) {
- this.size = size;
+ this.size = size;
}
@@ -191,7 +191,7 @@
*/
public String getProperty() {
- return (this.property);
+ return (this.property);
}
@@ -203,7 +203,7 @@
*/
public void setProperty(String property) {
- this.property = property;
+ this.property = property;
}
@@ -213,7 +213,7 @@
*/
public String getValue() {
- return (this.value);
+ return (this.value);
}
@@ -225,7 +225,7 @@
*/
public void setValue(String value) {
- this.value = value;
+ this.value = value;
}
@@ -240,74 +240,76 @@
*/
public int doStartTag() throws JspException {
- // Create an appropriate "form" element based on our parameters
- StringBuffer results = new StringBuffer("<select");
- results.append(" name=\"");
- results.append(property);
- results.append("\"");
- if (accesskey != null) {
- results.append(" accesskey=\"");
- results.append(accesskey);
- results.append("\"");
- }
- if (multiple != null) {
- results.append(" multiple=\"multiple\"");
- }
- if (size != null) {
- results.append(" size=\"");
- results.append(size);
- results.append("\"");
- }
- if (tabindex != null) {
- results.append(" tabindex=\"");
- results.append(tabindex);
- results.append("\"");
- }
- results.append(prepareEventHandlers());
- results.append(prepareStyles());
- results.append(">");
+ // Create an appropriate "form" element based on our parameters
+ StringBuffer results = new StringBuffer("<select");
+ results.append(" name=\"");
+ if( indexed )
+ prepareIndex( results, name );
+ results.append(property);
+ results.append("\"");
+ if (accesskey != null) {
+ results.append(" accesskey=\"");
+ results.append(accesskey);
+ results.append("\"");
+ }
+ if (multiple != null) {
+ results.append(" multiple=\"multiple\"");
+ }
+ if (size != null) {
+ results.append(" size=\"");
+ results.append(size);
+ results.append("\"");
+ }
+ if (tabindex != null) {
+ results.append(" tabindex=\"");
+ results.append(tabindex);
+ results.append("\"");
+ }
+ results.append(prepareEventHandlers());
+ results.append(prepareStyles());
+ results.append(">");
- // Print this field to our output writer
+ // Print this field to our output writer
ResponseUtils.write(pageContext, results.toString());
- // Store this tag itself as a page attribute
- pageContext.setAttribute(Constants.SELECT_KEY, this);
+ // Store this tag itself as a page attribute
+ pageContext.setAttribute(Constants.SELECT_KEY, this);
- // Calculate the match values we will actually be using
- if (value != null) {
- match = new String[1];
+ // Calculate the match values we will actually be using
+ if (value != null) {
+ match = new String[1];
match[0] = value;
} else {
- Object bean = pageContext.findAttribute(name);
- if (bean == null) {
+ Object bean = pageContext.findAttribute(name);
+ if (bean == null) {
JspException e = new JspException
- (messages.getMessage("getter.bean", name));
+ (messages.getMessage("getter.bean", name));
RequestUtils.saveException(pageContext, e);
throw e;
}
- try {
- match = BeanUtils.getArrayProperty(bean, property);
- if (match == null)
- match = new String[0];
- } catch (IllegalAccessException e) {
+ try {
+ match = BeanUtils.getArrayProperty(bean, property);
+ if (match == null)
+ match = new String[0];
+ } catch (IllegalAccessException e) {
RequestUtils.saveException(pageContext, e);
throw new JspException
- (messages.getMessage("getter.access", property, name));
- } catch (InvocationTargetException e) {
- Throwable t = e.getTargetException();
+ (messages.getMessage("getter.access", property, name));
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
RequestUtils.saveException(pageContext, t);
- throw new JspException
- (messages.getMessage("getter.result",
- property, t.toString()));
- } catch (NoSuchMethodException e) {
+ throw new JspException
+ (messages.getMessage("getter.result",
+ property, t.toString()));
+ } catch (NoSuchMethodException e) {
RequestUtils.saveException(pageContext, e);
throw new JspException
- (messages.getMessage("getter.method", property, name));
- }
- }
+ (messages.getMessage("getter.method", property, name));
+ }
+ }
- // Continue processing this page
- return (EVAL_BODY_TAG);
+ // Continue processing this page
+ return (EVAL_BODY_TAG);
}
@@ -339,20 +341,20 @@
*/
public int doEndTag() throws JspException {
- // Remove the page scope attributes we created
- pageContext.removeAttribute(Constants.SELECT_KEY);
+ // Remove the page scope attributes we created
+ pageContext.removeAttribute(Constants.SELECT_KEY);
- // Render a tag representing the end of our current form
- StringBuffer results = new StringBuffer();
- if (saveBody != null)
- results.append(saveBody);
- results.append("</select>");
+ // Render a tag representing the end of our current form
+ StringBuffer results = new StringBuffer();
+ if (saveBody != null)
+ results.append(saveBody);
+ results.append("</select>");
- // Print this value to our output writer
+ // Print this value to our output writer
ResponseUtils.write(pageContext, results.toString());
- // Continue processing this page
- return (EVAL_PAGE);
+ // Continue processing this page
+ return (EVAL_PAGE);
}
@@ -362,14 +364,14 @@
*/
public void release() {
- super.release();
- match = null;
- multiple = null;
- name = Constants.BEAN_KEY;
- property = null;
+ super.release();
+ match = null;
+ multiple = null;
+ name = Constants.BEAN_KEY;
+ property = null;
saveBody = null;
- size = null;
- value = null;
+ size = null;
+ value = null;
}
1.11 +1 -0
jakarta-struts/src/share/org/apache/struts/taglib/html/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LocalStrings.properties,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- LocalStrings.properties 2001/07/12 05:24:19 1.10
+++ LocalStrings.properties 2001/07/24 11:42:15 1.11
@@ -37,3 +37,4 @@
optionsTag.iterator=Cannot create iterator for {0}
optionsTag.select=Options tag must be nested in a Select tag
rewrite.url=Cannot create rewrite URL: {0}
+indexed.noEnclosingIterate=indexed=\"true\" is only valid within an enclosing
iterate tag
1.17 +73 -37
jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java
Index: LinkTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- LinkTag.java 2001/06/11 17:40:30 1.16
+++ LinkTag.java 2001/07/24 11:42:15 1.17
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java,v 1.16
2001/06/11 17:40:30 craigmcc Exp $
- * $Revision: 1.16 $
- * $Date: 2001/06/11 17:40:30 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java,v 1.17
2001/07/24 11:42:15 oalexeev Exp $
+ * $Revision: 1.17 $
+ * $Date: 2001/07/24 11:42:15 $
*
* ====================================================================
*
@@ -70,6 +70,7 @@
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Map;
+import java.util.HashMap;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -83,13 +84,13 @@
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
+import org.apache.struts.taglib.logic.IterateTag;
-
/**
* Generate a URL-encoded hyperlink to the specified URI.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.16 $ $Date: 2001/06/11 17:40:30 $
+ * @version $Revision: 1.17 $ $Date: 2001/07/24 11:42:15 $
*/
public class LinkTag extends BaseHandlerTag {
@@ -127,11 +128,11 @@
protected String forward = null;
public String getForward() {
- return (this.forward);
+ return (this.forward);
}
public void setForward(String forward) {
- this.forward = forward;
+ this.forward = forward;
}
@@ -141,11 +142,11 @@
protected String href = null;
public String getHref() {
- return (this.href);
+ return (this.href);
}
public void setHref(String href) {
- this.href = href;
+ this.href = href;
}
@@ -176,11 +177,11 @@
protected String name = null;
public String getName() {
- return (this.name);
+ return (this.name);
}
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
@@ -261,11 +262,11 @@
protected String property = null;
public String getProperty() {
- return (this.property);
+ return (this.property);
}
public void setProperty(String property) {
- this.property = property;
+ this.property = property;
}
@@ -289,11 +290,11 @@
protected String target = null;
public String getTarget() {
- return (this.target);
+ return (this.target);
}
public void setTarget(String target) {
- this.target = target;
+ this.target = target;
}
@@ -310,6 +311,18 @@
this.transaction = transaction;
}
+ /**
+ * Name of parameter to generate to hold index number
+ */
+ protected String indexId = null;
+
+ public String getIndexId() {
+ return (this.indexId);
+ }
+
+ public void setIndexId(String indexId) {
+ this.indexId = indexId;
+ }
// --------------------------------------------------------- Public Methods
@@ -330,10 +343,33 @@
return (EVAL_BODY_TAG);
}
- // Generate the hyperlink URL
+ // Generate the hyperlink URL
Map params = RequestUtils.computeParameters
(pageContext, paramId, paramName, paramProperty, paramScope,
name, property, scope, transaction);
+
+ //if "indexed=true", add "index=x" parameter to query string
+ if( indexed ) {
+ // look for outer iterate tag
+ IterateTag iterateTag = (IterateTag) findAncestorWithClass(this,
IterateTag.class);
+ if (iterateTag == null) {
+ // this tag should only be nested in iteratetag, if it's not, throw
exception
+ JspException e = new
JspException(messages.getMessage("indexed.noEnclosingIterate"));
+ RequestUtils.saveException(pageContext, e);
+ throw e;
+ }
+
+ //calculate index, and add as a parameter
+ if (params == null) {
+ params = new HashMap(); //create new HashMap if no other
params
+ }
+ if (indexId != null) {
+ params.put(indexId, Integer.toString(iterateTag.getIndex()));
+ } else {
+ params.put("index", Integer.toString(iterateTag.getIndex()));
+ }
+ }
+
String url = null;
try {
url = RequestUtils.computeURL(pageContext, forward, href,
@@ -348,21 +384,21 @@
StringBuffer results = new StringBuffer("<a href=\"");
results.append(url);
results.append("\"");
- if (target != null) {
- results.append(" target=\"");
- results.append(target);
- results.append("\"");
- }
+ if (target != null) {
+ results.append(" target=\"");
+ results.append(target);
+ results.append("\"");
+ }
results.append(prepareStyles());
results.append(prepareEventHandlers());
- results.append(">");
+ results.append(">");
- // Print this element to our output writer
+ // Print this element to our output writer
ResponseUtils.write(pageContext, results.toString());
- // Evaluate the body of this tag
+ // Evaluate the body of this tag
this.text = null;
- return (EVAL_BODY_TAG);
+ return (EVAL_BODY_TAG);
}
@@ -398,11 +434,11 @@
results.append(text);
results.append("</a>");
- // Render the remainder to the output stream
+ // Render the remainder to the output stream
ResponseUtils.write(pageContext, results.toString());
// Evaluate the remainder of this page
- return (EVAL_PAGE);
+ return (EVAL_PAGE);
}
@@ -412,20 +448,20 @@
*/
public void release() {
- super.release();
+ super.release();
anchor = null;
- forward = null;
- href = null;
+ forward = null;
+ href = null;
linkName = null;
- name = null;
+ name = null;
page = null;
- paramId = null;
- paramName = null;
- paramProperty = null;
- paramScope = null;
- property = null;
+ paramId = null;
+ paramName = null;
+ paramProperty = null;
+ paramScope = null;
+ property = null;
scope = null;
- target = null;
+ target = null;
text = null;
transaction = false;
1.7 +40 -38
jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java
Index: CheckboxTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CheckboxTag.java 2001/06/10 03:53:31 1.6
+++ CheckboxTag.java 2001/07/24 11:42:15 1.7
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java,v
1.6 2001/06/10 03:53:31 craigmcc Exp $
- * $Revision: 1.6 $
- * $Date: 2001/06/10 03:53:31 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java,v
1.7 2001/07/24 11:42:15 oalexeev Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/07/24 11:42:15 $
*
* ====================================================================
*
@@ -76,7 +76,7 @@
* Tag for input fields of type "checkbox".
*
* @author Craig R. McClanahan
- * @version $Revision: 1.6 $ $Date: 2001/06/10 03:53:31 $
+ * @version $Revision: 1.7 $ $Date: 2001/07/24 11:42:15 $
*/
public class CheckboxTag extends BaseHandlerTag {
@@ -98,11 +98,11 @@
protected String name = Constants.BEAN_KEY;
public String getName() {
- return (this.name);
+ return (this.name);
}
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
@@ -132,7 +132,7 @@
*/
public String getProperty() {
- return (this.property);
+ return (this.property);
}
@@ -144,7 +144,7 @@
*/
public void setProperty(String property) {
- this.property = property;
+ this.property = property;
}
@@ -154,7 +154,7 @@
*/
public String getValue() {
- return (this.value);
+ return (this.value);
}
@@ -166,7 +166,7 @@
*/
public void setValue(String value) {
- this.value = value;
+ this.value = value;
}
@@ -181,21 +181,23 @@
*/
public int doStartTag() throws JspException {
- // Create an appropriate "input" element based on our parameters
- StringBuffer results = new StringBuffer("<input type=\"checkbox\"");
- results.append(" name=\"");
- results.append(this.property);
- results.append("\"");
- if (accesskey != null) {
- results.append(" accesskey=\"");
- results.append(accesskey);
- results.append("\"");
- }
- if (tabindex != null) {
- results.append(" tabindex=\"");
- results.append(tabindex);
- results.append("\"");
- }
+ // Create an appropriate "input" element based on our parameters
+ StringBuffer results = new StringBuffer("<input type=\"checkbox\"");
+ results.append(" name=\"");
+ if( indexed )
+ prepareIndex( results, name );
+ results.append(this.property);
+ results.append("\"");
+ if (accesskey != null) {
+ results.append(" accesskey=\"");
+ results.append(accesskey);
+ results.append("\"");
+ }
+ if (tabindex != null) {
+ results.append(" tabindex=\"");
+ results.append(tabindex);
+ results.append("\"");
+ }
results.append(" value=\"");
if (value == null)
results.append("on");
@@ -209,20 +211,20 @@
if (!(result instanceof String))
result = result.toString();
String checked = (String) result;
- if (checked.equalsIgnoreCase("true")
+ if (checked.equalsIgnoreCase("true")
|| checked.equalsIgnoreCase("yes")
- || checked.equalsIgnoreCase("on"))
- results.append(" checked=\"checked\"");
- results.append(prepareEventHandlers());
- results.append(prepareStyles());
- results.append(">");
+ || checked.equalsIgnoreCase("on"))
+ results.append(" checked=\"checked\"");
+ results.append(prepareEventHandlers());
+ results.append(prepareStyles());
+ results.append(">");
- // Print this field to our output writer
+ // Print this field to our output writer
ResponseUtils.write(pageContext, results.toString());
- // Continue processing this page
+ // Continue processing this page
this.text = null;
- return (EVAL_BODY_TAG);
+ return (EVAL_BODY_TAG);
}
@@ -267,11 +269,11 @@
*/
public void release() {
- super.release();
- name = Constants.BEAN_KEY;
- property = null;
+ super.release();
+ name = Constants.BEAN_KEY;
+ property = null;
text = null;
- value = null;
+ value = null;
}
1.5 +9 -7
jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java
Index: ButtonTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ButtonTag.java 2001/06/01 17:13:36 1.4
+++ ButtonTag.java 2001/07/24 11:42:15 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java,v 1.4
2001/06/01 17:13:36 craigmcc Exp $
- * $Revision: 1.4 $
- * $Date: 2001/06/01 17:13:36 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java,v 1.5
2001/07/24 11:42:15 oalexeev Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/07/24 11:42:15 $
*
* ====================================================================
*
@@ -74,7 +74,7 @@
* Renders an HTML BUTTON tag within the Struts framework.
*
* @author Don Clasen
- * @version $Revision: 1.4 $ $Date: 2001/06/01 17:13:36 $
+ * @version $Revision: 1.5 $ $Date: 2001/07/24 11:42:15 $
*/
public class ButtonTag extends BaseHandlerTag {
@@ -188,6 +188,8 @@
if (property != null) {
results.append(" name=\"");
results.append(property);
+ if( indexed )
+ prepareIndex( results, null );
results.append("\"");
}
if (accesskey != null) {
@@ -221,10 +223,10 @@
*/
public void release() {
- super.release();
- property = null;
+ super.release();
+ property = null;
text = null;
- value = null;
+ value = null;
}
1.8 +72 -27
jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java
Index: BaseHandlerTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BaseHandlerTag.java 2001/06/21 16:18:17 1.7
+++ BaseHandlerTag.java 2001/07/24 11:42:15 1.8
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java,v
1.7 2001/06/21 16:18:17 craigmcc Exp $
- * $Revision: 1.7 $
- * $Date: 2001/06/21 16:18:17 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java,v
1.8 2001/07/24 11:42:15 oalexeev Exp $
+ * $Revision: 1.8 $
+ * $Date: 2001/07/24 11:42:15 $
*
* ====================================================================
*
@@ -61,8 +61,11 @@
package org.apache.struts.taglib.html;
+import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import org.apache.struts.util.MessageResources;
+import org.apache.struts.util.RequestUtils;
+import org.apache.struts.taglib.logic.IterateTag;
/**
* Base class for tags that render form elements capable of including JavaScript
@@ -71,7 +74,7 @@
* appropriate implementations of these.
*
* @author Don Clasen
- * @version $Revision: 1.7 $ $Date: 2001/06/21 16:18:17 $
+ * @version $Revision: 1.8 $ $Date: 2001/07/24 11:42:15 $
*/
public abstract class BaseHandlerTag extends BodyTagSupport {
@@ -95,6 +98,11 @@
/** Tab index value. */
protected String tabindex = null;
+// Indexing ability for Iterate
+
+ /** Whether to created indexed names for fields */
+ protected boolean indexed = false;
+
// Mouse Events
/** Mouse click event. */
@@ -174,25 +182,37 @@
/** Sets the accessKey character. */
public void setAccesskey(String accessKey) {
- this.accesskey = accessKey;
+ this.accesskey = accessKey;
}
/** Returns the accessKey character. */
public String getAccesskey() {
- return (this.accesskey);
+ return (this.accesskey);
}
/** Sets the tabIndex value. */
public void setTabindex(String tabIndex) {
- this.tabindex = tabIndex;
+ this.tabindex = tabIndex;
}
/** Returns the tabIndex value. */
public String getTabindex() {
- return (this.tabindex);
+ return (this.tabindex);
}
+// Indexing ability for Iterate
+
+ /** Sets the indexed value. */
+ public void setIndexed(boolean indexed) {
+ this.indexed = indexed;
+ }
+
+ /** Returns the indexed value. */
+ public boolean getIndexed() {
+ return (this.indexed);
+ }
+
// Mouse Events
/** Sets the onClick event handler. */
@@ -414,35 +434,60 @@
*/
public void release() {
- super.release();
- accesskey = null;
- tabindex = null;
- onclick = null;
- ondblclick = null;
- onmouseover = null;
- onmouseout = null;
- onmousemove = null;
- onmousedown = null;
- onmouseup = null;
- onkeydown = null;
- onkeyup = null;
- onkeypress = null;
- onselect = null;
- onchange = null;
- onblur = null;
- onfocus = null;
+ super.release();
+ accesskey = null;
+ tabindex = null;
+ onclick = null;
+ ondblclick = null;
+ onmouseover = null;
+ onmouseout = null;
+ onmousemove = null;
+ onmousedown = null;
+ onmouseup = null;
+ onkeydown = null;
+ onkeyup = null;
+ onkeypress = null;
+ onselect = null;
+ onchange = null;
+ onblur = null;
+ onfocus = null;
disabled = false;
readonly = false;
- style = null;
- styleClass = null;
+ style = null;
+ styleClass = null;
styleId = null;
title = null;
+ indexed = false;
}
// ------------------------------------------------------ Protected Methods
+ /**
+ * Appends bean name with index in brackets for tags with
+ * 'true' value in 'indexed' attribute.
+ * @param handlers The StringBuffer that output will be appended to.
+ * @exception JspException if 'indexed' tag used outside of iterate tag.
+ */
+ protected void prepareIndex( StringBuffer handlers, String name )
+ throws JspException {
+ // look for outer iterate tag
+ IterateTag iterateTag = (IterateTag) findAncestorWithClass(this,
IterateTag.class);
+ if (iterateTag == null) {
+ // this tag should only be nested in iteratetag, if it's not, throw
exception
+ JspException e = new
JspException(messages.getMessage("indexed.noEnclosingIterate"));
+ RequestUtils.saveException(pageContext, e);
+ throw e;
+ }
+ if( name!=null )
+ handlers.append( name );
+ handlers.append("[");
+ handlers.append(iterateTag.getIndex());
+ handlers.append("]");
+ if( name!=null )
+ handlers.append(".");
+ }
/**
* Prepares the style attributes for inclusion in the component's HTML tag.
1.8 +56 -54
jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java
Index: BaseFieldTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BaseFieldTag.java 2001/04/29 00:38:04 1.7
+++ BaseFieldTag.java 2001/07/24 11:42:15 1.8
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java,v
1.7 2001/04/29 00:38:04 craigmcc Exp $
- * $Revision: 1.7 $
- * $Date: 2001/04/29 00:38:04 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java,v
1.8 2001/07/24 11:42:15 oalexeev Exp $
+ * $Revision: 1.8 $
+ * $Date: 2001/07/24 11:42:15 $
*
* ====================================================================
*
@@ -79,7 +79,7 @@
* Convenience base class for the various input tags for text fields.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.7 $ $Date: 2001/04/29 00:38:04 $
+ * @version $Revision: 1.8 $ $Date: 2001/07/24 11:42:15 $
*/
public abstract class BaseFieldTag extends BaseInputTag {
@@ -97,11 +97,11 @@
protected String accept = null;
public String getAccept() {
- return (this.accept);
+ return (this.accept);
}
public void setAccept(String accept) {
- this.accept = accept;
+ this.accept = accept;
}
@@ -111,11 +111,11 @@
protected String name = Constants.BEAN_KEY;
public String getName() {
- return (this.name);
+ return (this.name);
}
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
@@ -150,57 +150,59 @@
*/
public int doStartTag() throws JspException {
- // Create an appropriate "input" element based on our parameters
- StringBuffer results = new StringBuffer("<input type=\"");
- results.append(type);
- results.append("\" name=\"");
- results.append(property);
- results.append("\"");
- if (accesskey != null) {
- results.append(" accesskey=\"");
- results.append(accesskey);
- results.append("\"");
- }
- if (accept != null) {
- results.append(" accept=\"");
- results.append(accept);
- results.append("\"");
- }
- if (maxlength != null) {
- results.append(" maxlength=\"");
- results.append(maxlength);
- results.append("\"");
- }
- if (cols != null) {
- results.append(" size=\"");
- results.append(cols);
- results.append("\"");
- }
- if (tabindex != null) {
- results.append(" tabindex=\"");
- results.append(tabindex);
- results.append("\"");
- }
- results.append(" value=\"");
- if (value != null) {
- results.append(ResponseUtils.filter(value));
- } else if (redisplay || !"password".equals(type)) {
+ // Create an appropriate "input" element based on our parameters
+ StringBuffer results = new StringBuffer("<input type=\"");
+ results.append(type);
+ results.append("\" name=\"");
+ if( indexed )
+ prepareIndex( results, name );
+ results.append(property);
+ results.append("\"");
+ if (accesskey != null) {
+ results.append(" accesskey=\"");
+ results.append(accesskey);
+ results.append("\"");
+ }
+ if (accept != null) {
+ results.append(" accept=\"");
+ results.append(accept);
+ results.append("\"");
+ }
+ if (maxlength != null) {
+ results.append(" maxlength=\"");
+ results.append(maxlength);
+ results.append("\"");
+ }
+ if (cols != null) {
+ results.append(" size=\"");
+ results.append(cols);
+ results.append("\"");
+ }
+ if (tabindex != null) {
+ results.append(" tabindex=\"");
+ results.append(tabindex);
+ results.append("\"");
+ }
+ results.append(" value=\"");
+ if (value != null) {
+ results.append(ResponseUtils.filter(value));
+ } else if (redisplay || !"password".equals(type)) {
Object value = RequestUtils.lookup(pageContext, name, property,
null);
if (value == null)
value = "";
results.append(ResponseUtils.filter(value.toString()));
- }
- results.append("\"");
- results.append(prepareEventHandlers());
- results.append(prepareStyles());
- results.append(">");
+ }
+ results.append("\"");
+ results.append(prepareEventHandlers());
+ results.append(prepareStyles());
+ results.append(">");
- // Print this field to our output writer
+ // Print this field to our output writer
ResponseUtils.write(pageContext, results.toString());
- // Continue processing this page
- return (EVAL_BODY_TAG);
+ // Continue processing this page
+ return (EVAL_BODY_TAG);
}
@@ -210,9 +212,9 @@
*/
public void release() {
- super.release();
- accept = null;
- name = Constants.BEAN_KEY;
+ super.release();
+ accept = null;
+ name = Constants.BEAN_KEY;
redisplay = true;
}