Details
Description
The order of properties is not preserved when using the beanutils to fetch
properties from a DynaBean. Since DynaBeans use an array to define properties
it is natural desire to use the order of this array to do things with a
DynaBean. With a 2 line patch to BeanUtilsBean.java, it can be made to return
a LinkedHashMap for DynaBean properties which preserves the ordering of these
properties.
This patch is particularly usefull if you are using the <display> tag to
display DynaBeans. Several people have suggested a patch like this on the
<display> tag mailing list.
-
-
- BeanUtilsBean.java
- BeanUtilsBean.java.ordered
-
- 26,31 ****
- 26,32 ----
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+ import java.util.LinkedHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap; -
- 487,493 ****
log.debug("Describing bean: " + bean.getClass().getName());
}
-
! Map description = new HashMap();
if (bean instanceof DynaBean)
! Map description = new LinkedHashMap();
if (bean instanceof DynaBean) {
DynaProperty descriptors[] =
((DynaBean) bean).getDynaClass().getDynaProperties();