Index: src/doc/struts-html.xml
===================================================================
RCS file: /home/cvspublic/jakarta-struts/src/doc/struts-html.xml,v
retrieving revision 1.6
diff -u -r1.6 struts-html.xml
--- src/doc/struts-html.xml 2001/02/07 23:10:42 1.6
+++ src/doc/struts-html.xml 2001/02/09 02:23:12
@@ -2400,7 +2400,26 @@
The value to be transmitted if this checkbox is
checked when the form is submitted. </info> -
</attribute> + </attribute>
+ <attribute>
+ <name>valueName</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>
+ The name of the bean which has teh property used as
the value to be transmitted if this checkbox is
+ checked when the form is submitted.
+ </info>
+ </attribute>
+ <attribute>
+ <name>valueProperty</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>
+ The property of the bean to get value to be
transmitted if this checkbox is
+ checked when the form is submitted.
+ </info>
+ </attribute>
+ </tag> Index:
src/share/org/apache/struts/taglib/html/MultiboxTag.java
===================================================================
RCS file:
/home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/Multi
boxTag.java,v
retrieving revision 1.1
diff -u -r1.1 MultiboxTag.java
--- src/share/org/apache/struts/taglib/html/MultiboxTag.java 2001/01/06
21:50:39 1.1
+++ src/share/org/apache/struts/taglib/html/MultiboxTag.java 2001/02/09
02:23:21
@@ -123,7 +123,20 @@
*/
protected String value = null;
-
+ /**
+ * The name of the bean that contains the property for value which will
mark this checkbox as "checked" if present
+ * in the array returned by our property getter.
+ */
+ protected String valueName = null;
+
+ /**
+ * The property of the value bean which will mark this checkbox as
"checked" if present
+ * in the array returned by our property getter.
+ */
+ protected String valueProperty = null;
+
+
+
// -------------------------------------------------------------
Properties
@@ -170,7 +183,49 @@
}
+ /**
+ * Return he name of the bean property to get value from..
+ */
+ public String getValueProperty() {
+
+ return (this.valueProperty);
+
+ }
+
+
+ /**
+ * Set the name of the bean property to get value from..
+ *
+ * @param value The new server value
+ */
+ public void setValueProperty(String valueProerty) {
+
+ this.valueProperty = valueProperty;
+
+ }
+ /**
+ * Return the name of the bean to get value from..
+ */
+ public String getValueName() {
+
+ return (this.valueName);
+
+ }
+
+ /**
+ * Set the name of the bean to get value from.
+ *
+ * @param value The new server valueName
+ */
+ public void setValueName(String valueName) {
+
+ this.valueName = valueName;
+
+ }
+
+
+
// --------------------------------------------------------- Public
Methods
@@ -197,6 +252,30 @@
results.append("\"");
}
results.append(" value=\"");
+ if (value == null) {
+ Object valueBean = pageContext.findAttribute(valueName);
+
+ if (valueBean == null)
+ throw new
JspException(messages.getMessage("getter.bean", valueName));
+ try {
+ value = BeanUtils.getProperty(valueBean,
valueProperty);
+ if (value == null) {
+ throw new
JspException(messages.getMessage("getter.result", valueBean + "." +
valueProperty, "null"));
+ }
+ } catch (IllegalAccessException e) {
+ throw new JspException(
+ messages.getMessage("getter.access",
valueProperty, valueName));
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ throw new JspException(
+ messages.getMessage("getter.result",
valueProperty, t.toString()));
+ } catch (NoSuchMethodException e) {
+ throw new JspException(
+ messages.getMessage("getter.method",
valueProperty, valueName));
+ }
+
+ }
+
results.append(this.value);
results.append("\"");
Object bean = pageContext.findAttribute(name);
@@ -279,6 +358,8 @@
name = null;
property = null;
value = null;
+ valueName = null;
+ valueProperty = null;
}