|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.click.util.ContainerUtils
public class ContainerUtils
Provides Container access and copy utilities.
| Constructor Summary | |
|---|---|
ContainerUtils()
|
|
| Method Summary | |
|---|---|
static void |
copyContainerToObject(Container container,
Object object)
Populate the given object attributes from the Containers field values. |
static void |
copyContainerToObject(Container container,
Object object,
List fieldList)
Populate the given object attributes from the Containers field values. |
static void |
copyObjectToContainer(Object object,
Container container)
Populate the given Container field values from the object attributes. |
static void |
copyObjectToContainer(Object object,
Container container,
List fieldList)
Populate the given Container field values from the object attributes. |
static Control |
findControlByName(Container container,
String name)
Find and return the first control with a matching name in the specified container. |
static Form |
findForm(Control control)
Find and return the specified controls parent Form or null if no Form is present. |
static List |
getButtons(Container container)
Return the list of Buttons for the given Container, recursively including any Fields contained in child containers. |
protected int |
getDepth(Control control)
Return how deep the control is in the container hierarchy. |
static List |
getErrorFields(Container container)
Return a list of container fields which are not valid, not hidden and not disabled. |
static Map |
getFieldMap(Container container)
Return a map of all Fields for the given Container, recursively including any Fields contained in child containers. |
static List |
getFields(Container container)
Return the list of Fields for the given Container, recursively including any Fields contained in child containers. |
static List |
getFieldsAndLabels(Container container)
Return the list of Fields for the given Container, recursively including any Fields contained in child containers. |
static List |
getHiddenFields(Container container)
Return the list of hidden Fields for the given Container, recursively including any Fields contained in child containers. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ContainerUtils()
| Method Detail |
|---|
public static List getButtons(Container container)
container - the container to obtain the buttons from
public static List getFields(Container container)
container - the container to obtain the fields from
public static List getFieldsAndLabels(Container container)
container - the container to obtain the fields from
public static Map getFieldMap(Container container)
container - the container to obtain the fields from
public static List getHiddenFields(Container container)
container - the container to obtain the fields from
public static List getErrorFields(Container container)
container - the container to obtain the invalid fields from
public static Form findForm(Control control)
control - the control to check for Form
public static Control findControlByName(Container container,
String name)
container - the container that is checked for controls for matching
namesname - the name of the control to find
public static void copyContainerToObject(Container container,
Object object,
List fieldList)
public void onInit() {
List formFields = new ArrayList();
for(Iterator it = form.getFieldList().iterator(); it.hasNext(); ) {
Field field = (Field) formFields.next();
// Exclude disabled fields
if (!field.isDisabled()) {
formFields.add(field);
}
}
Customer customer = new Customer();
ContainerUtils.copyContainerToObject(form, customer, formFields);
}
The specified Object can either be a POJO (plain old java object) or
a Map. If a POJO is specified, its attributes are
populated from matching container fields. If a map is specified, its
key/value pairs are populated from matching container fields.
container - the fieldList Containerobject - the object to populate with field valuesfieldList - the list of fields to obtain values from
IllegalArgumentException - if container, object or fieldList is
null
public static void copyContainerToObject(Container container,
Object object)
container - the Container to obtain field values fromobject - the object to populate with field valuescopyContainerToObject(net.sf.click.control.Container, java.lang.Object, java.util.List)
public static void copyObjectToContainer(Object object,
Container container,
List fieldList)
Map. If a POJO is specified, its attributes are
copied to matching container fields. If a map is specified, its key/value
pairs are copied to matching container fields.
object - the object to obtain attribute values fromcontainer - the Container to populatefieldList - the list of fields to populate from the object
attributes
public static void copyObjectToContainer(Object object,
Container container)
object - the object to obtain attribute values fromcontainer - the Container to populatecopyObjectToContainer(java.lang.Object, net.sf.click.control.Container, java.util.List)protected int getDepth(Control control)
control - the control which depth to return
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||