Copy the given object's attributes into the Form's field values. In other words automatically populate Form's field values with the given objects attributes.
The following example populates the Form field with Customer attributes:
public void onGet() { Long customerId = .. Customer customer = CustomerDAO.findByPK(customerId); form.copyFrom(customer); }
copyForm also supports
java.util.Map as an argument.
By specifying a map, the Form's field values will be populated by matching key/value pairs. A match occurs when the map's key is equal to a field's name.
The following example populates the Form fields with a map's key/value pairs:
public void onInit() { form = new Form("form"); form.add(new TextField("name")); form.add(new TextField("address.street")); } public void onGet() { Map map = new HashMap(); map.put("name", "Steve"); map.put("address.street", "12 Long street"); form.copyFrom(map); }
For more information on how Fields and Objects are copied see {@link org.apache.click.util.ContainerUtils#copyObjectToContainer(java.lang.Object,org.apache.click.control.Container)}.
@param object the object to obtain attribute values from
@throws IllegalArgumentException if the object parameter is null