Provides a DataObject property Select control: <select></select>. The PropertySelect provides a Select control for {@link DataObject}relationship properties (properties which are also DataObjects). For properties which are not DataObjects use the {@link QuerySelect} control.
The PropertySelect control will only work inside a CayenneForm as it obtains meta data about DataObject property from the parent form.
Currently this control only supports selecting a single element.
PropertySelect Example
For example given a Pet DataObject which has a PetType DataObject property.
public class Pet implements DataObject { public PetType getType() { .. } public void setType(PetType value) { .. } } public class PetType implements DataObject { public String getName() { .. } }
You would use the PropertySelect in a CayenneForm to edit the Pet type property. In this example the PetType name property is rendered as the select options label.
CayenneForm form = new CayenneForm("form", Pet.class); PropertySelect typeSelect = new PropertySelect("type", true); typeSelect.setOptionLabel("name"); form.add(typeSelect);
In this example no query is specified and the control will create a simple {@link SelectQuery} based on the property class. However,generally you should use a named query (configured in the Cayenne Modeler) or an explicity set
SelectQuery.
Note when using a named query ensure that it will return DataObjects and not DataRows.
Also note that the CayenneForm is not able to determine whether a property is required, so you must set the PropertySelect required status manually.
OptionList Caching in Stateful Pages
Note the PropertySelect will cache its optionList in a stateful page. If you need the optionList refreshed in each page view you will need to clear the option list. For example:
public void onDestroy() { customerSelect.getOptionList().clear(); super.onDestroy(); }
@see CayenneForm
@see QuerySelect