husted 2002/09/12 05:39:50
Modified: contrib/scaffold/src/java/org/apache/struts/scaffold
ProcessFormAction.java ProcessDispatchAction.java
ProcessAction.java BaseForm.java BaseAction.java
Log:
+ Replace calls to BeanUtils.populate with copyProperties
+ Migrate to latest commons.beanutil.BeanUtils
Revision Changes Path
1.5 +7 -9
jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/ProcessFormAction.java
Index: ProcessFormAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/ProcessFormAction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ProcessFormAction.java 20 Aug 2002 21:35:25 -0000 1.4
+++ ProcessFormAction.java 12 Sep 2002 12:39:50 -0000 1.5
@@ -3,8 +3,9 @@
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
-// import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
-import org.apache.struts.util.BeanUtils; // Struts 1.0.x
+
+import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
+// import org.apache.struts.util.BeanUtils; // Struts 1.0.x
import org.apache.commons.scaffold.lang.ChainedException;
import org.apache.commons.scaffold.lang.Log;
@@ -73,8 +74,7 @@
}
else {
try {
- BeanUtils.populate(form,
- BeanUtils.describe(bean));
+ BeanUtils.copyProperties(form,bean);
}
catch (Exception e) {
throw new RuntimeException(e.toString());
@@ -88,8 +88,7 @@
}
else {
try {
- BeanUtils.populate(form,
- BeanUtils.describe(bean));
+ BeanUtils.copyProperties(form,bean);
}
catch (Exception e) {
throw new RuntimeException(e.toString());
@@ -103,8 +102,7 @@
}
else {
try {
- BeanUtils.populate(form,
- BeanUtils.describe(bean));
+ BeanUtils.copyProperties(form,bean);
}
catch (Exception e) {
throw new RuntimeException(e.toString());
1.5 +7 -5
jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/ProcessDispatchAction.java
Index: ProcessDispatchAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/ProcessDispatchAction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ProcessDispatchAction.java 23 Aug 2002 18:30:00 -0000 1.4
+++ ProcessDispatchAction.java 12 Sep 2002 12:39:50 -0000 1.5
@@ -20,8 +20,10 @@
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
-// import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
-import org.apache.struts.util.BeanUtils; // Struts 1.0.x
+// import org.apache.struts.util.BeanUtils; // Struts 1.0.x
+// import org.apache.struts.util.PropertyUtils; // Struts 1.0.x
+import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
+import org.apache.commons.beanutils.PropertyUtils; // Struts 1.1
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
@@ -130,12 +132,12 @@
dataBean.setRemoteServer(getRemoteServer());
}
else {
- properties = BeanUtils.describe(form);
+ properties = PropertyUtils.describe(form);
}
} // end null form
else if (null!=userBean) {
// if no form, but is profile, still use profile
- properties = BeanUtils.describe(userBean);
+ properties = PropertyUtils.describe(userBean);
}
// Execute business logic, using values from map
1.3 +5 -5
jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/ProcessAction.java
Index: ProcessAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/ProcessAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ProcessAction.java 20 Aug 2002 21:35:25 -0000 1.2
+++ ProcessAction.java 12 Sep 2002 12:39:50 -0000 1.3
@@ -16,8 +16,8 @@
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
-// import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
-import org.apache.struts.util.BeanUtils; // Struts 1.0.x
+import org.apache.commons.beanutils.PropertyUtils; // Struts 1.1
+// import org.apache.struts.util.PropertyUtils; // Struts 1.0.x
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
@@ -481,12 +481,12 @@
dataBean.setRemoteServer(getRemoteServer());
}
else {
- properties = BeanUtils.describe(form);
+ properties = PropertyUtils.describe(form);
}
} // end null form
else if (null!=userBean) {
// if no form, but is profile, still use profile
- properties = BeanUtils.describe(userBean);
+ properties = PropertyUtils.describe(userBean);
}
// Execute business logic, using values from map
1.5 +16 -13
jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/BaseForm.java
Index: BaseForm.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/BaseForm.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BaseForm.java 6 Sep 2002 21:48:52 -0000 1.4
+++ BaseForm.java 12 Sep 2002 12:39:50 -0000 1.5
@@ -8,11 +8,14 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-// import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
-import org.apache.struts.util.BeanUtils; // Struts 1.0.x
+// import org.apache.struts.util.BeanUtils; // Struts 1.0.x
+// import org.apache.struts.util.PropertyUtils; // Struts 1.0.x
+import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
+import org.apache.commons.beanutils.PropertyUtils; // Struts 1.1
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
// import org.apache.struts.validator.ValidatorForm; // Struts 1.1
@@ -28,7 +31,7 @@
* @todo Change from BeanUtil.populate to copyProperties
* in 1.1 version.
*/
-public class BaseForm extends ValidatorForm {
+public class BaseForm extends ActionForm {
// ----------------------------------------------------------- Properties
@@ -260,7 +263,7 @@
/**
* Return map of properties for this bean.
- * Base method uses <code>BeanUtils.describe</code>.
+ * Base method uses <code>PropertyUtils.describe</code>.
* Override if some properties should not be transfered
* this way, or a property name should be altered.
* This will return the actual public properties.
@@ -270,7 +273,7 @@
public Map describe() throws Exception {
try {
- return BeanUtils.describe(this);
+ return PropertyUtils.describe(this);
} catch (Throwable t) {
throw new ChainedException(t);
}
@@ -280,8 +283,8 @@
/**
* Set properties from given object.
- * Base method uses <code>BeanUtils.populate</code> and
- * <code>BeanUtils.describe</code>.
+ * Base method uses <code>BeanUtils.copyProperties</code> and
+ * <code>PropertyUtils.describe</code>.
*
* @param o The object to use to populate this object.
* @exception Throws Exception on any error.
@@ -289,7 +292,7 @@
public void set(Object o) throws Exception {
try {
- BeanUtils.populate(this,BeanUtils.describe(o));
+ BeanUtils.copyProperties(this,o);
} catch (Throwable t) {
throw new ChainedException(t);
}
@@ -299,7 +302,7 @@
/**
* Populate matching properties on given object.
- * Base method uses <code>BeanUtils.populate</code> and
+ * Base method uses <code>BeanUtils.copyProperties</code> and
* <code>describe()</code>.
*
* @param o The object to populate from this object.
@@ -308,7 +311,7 @@
public void populate(Object o) throws Exception {
try {
- BeanUtils.populate(o,describe());
+ BeanUtils.copyProperties(o,describe());
} catch (Throwable t) {
throw new ChainedException(t);
}
@@ -334,7 +337,7 @@
* <p>
* This method is forwardly-compatible with BaseMapForm.
* For an instance of BaseMapForm, getMap() is used; otherwise
- * describe() or BeanUtils.describe() is used.
+ * describe() or PropertyUtils.describe() is used.
*
* @fixme Needs testing. Works OK without a profile bean =:o)
* @param profile The profile bean, if any
@@ -363,7 +366,7 @@
userMap = form.describe();
}
else {
- userMap = BeanUtils.describe(this);
+ userMap = PropertyUtils.describe(this);
}
// Add user element to formMap if form element is null or blank
1.3 +5 -6
jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/BaseAction.java
Index: BaseAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/scaffold/src/java/org/apache/struts/scaffold/BaseAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseAction.java 19 Aug 2002 22:36:15 -0000 1.2
+++ BaseAction.java 12 Sep 2002 12:39:50 -0000 1.3
@@ -13,8 +13,8 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-// import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
-import org.apache.struts.util.BeanUtils; // Struts 1.0.x
+// import org.apache.struts.util.BeanUtils; // Struts 1.0.x
+import org.apache.commons.beanutils.BeanUtils; // Struts 1.1
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
@@ -58,10 +58,9 @@
* @deprecated Will be removed after Struts 1.1 final ships.
*/
private final boolean isStruts_1_0() {
- return true;
+ return true; // Struts 1.0.x
+// return false; // Struts 1.1
}
-
-
// ---------------------------------------------------------------- Log
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>