|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.control.AbstractControl org.apache.click.control.Field org.apache.click.control.Select org.apache.click.extras.cayenne.PropertySelect
public class PropertySelect
Provides a DataObject property Select control: <select></select>.
Property Select |
DataObject
relationship properties (properties which are also DataObjects). For
properties which are not DataObjects use the 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.
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
SelectQuery
based on the property class. However,
generally you should use a named query (configured in the Cayenne Modeler)
or an explicitly 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.
public void onDestroy() { customerSelect.getOptionList().clear(); super.onDestroy(); }
CayenneForm
,
QuerySelect
,
Serialized FormField Summary | |
---|---|
protected Decorator |
decorator
The option label rendering decorator. |
protected org.apache.cayenne.query.NamedQuery |
namedQuery
The option list Cayenne NamedQuery. |
protected boolean |
optional
The flag indicating whether the option list includes an empty option value. |
protected String |
optionLabel
The data object property to render as the option label. |
protected org.apache.cayenne.query.Ordering |
ordering
The select query ordering. |
protected boolean |
orderingApplied
The flag indicating whether the ordering has been applied. |
protected String |
queryName
The name of the configured select query. |
protected org.apache.cayenne.query.SelectQuery |
selectQuery
The option list Cayenne SelectQuery. |
protected org.apache.cayenne.DataObject |
valueObject
The property value object. |
Fields inherited from class org.apache.click.control.Select |
---|
dataProvider, defaultOption, multiple, optionList, selectedValues, size, VALIDATE_SELECT_FUNCTION |
Fields inherited from class org.apache.click.control.Field |
---|
disabled, error, focus, form, help, label, labelStyle, labelStyleClass, parentStyleClassHint, parentStyleHint, readonly, required, tabindex, title, trim, validate, value |
Fields inherited from class org.apache.click.control.AbstractControl |
---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface org.apache.click.Control |
---|
CONTROL_MESSAGES |
Constructor Summary | |
---|---|
PropertySelect()
Create a PropertySelect field with no name defined, please note the control's name must be defined before it is valid. |
|
PropertySelect(String name)
Create a PropertySelect field with the given name. |
|
PropertySelect(String name,
boolean required)
Create a PropertySelect field with the given name and required status. |
|
PropertySelect(String name,
String label)
Create a PropertySelect field with the given name and label. |
|
PropertySelect(String name,
String label,
boolean required)
Create a PropertySelect field with the given name, label and required status. |
Method Summary | |
---|---|
Decorator |
getDecorator()
Return the option label rendering decorator. |
org.apache.cayenne.query.NamedQuery |
getNamedQuery()
Return the NamedQuery to populate the options list with. |
String |
getOptionLabel()
Return the DataObject property to render as the option label. |
org.apache.cayenne.query.Ordering |
getOrdering()
Return the select query ordering. |
String |
getQueryName()
Return the name of the configured query to populate the options list with. |
org.apache.cayenne.query.SelectQuery |
getSelectQuery()
Return the SelectQuery to populate the options list with. |
Object |
getValueObject()
Return the property DataObject value, or null if value was not defined. |
boolean |
isMultiple()
Return true if multiple options can be selected. |
boolean |
isOptional()
Return true if the option list includes an empty option value. |
protected void |
loadDataObject()
Load the DataObject based on the submitted primary key value and setting this object as the Select valueObject. |
protected void |
loadOptionList()
Load the Select options list. |
void |
onDestroy()
Clear the cached valueObject. |
boolean |
onProcess()
Process the page request returning true to continue processing or false otherwise. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the PropertySelect. |
void |
setDecorator(Decorator decorator)
Set the decorator to render the option labels. |
void |
setMultiple(boolean value)
Set the multiple options can be selected flag. |
void |
setNamedQuery(org.apache.cayenne.query.NamedQuery namedQuery)
Set the NamedQuery to populate the options list with. |
void |
setOptional(boolean value)
Set whether the option list includes an empty option value. |
void |
setOptionLabel(String optionLabel)
Set the DataObject property to render as the option label. |
void |
setOrdering(org.apache.cayenne.query.Ordering ordering)
Set the select query ordering. |
void |
setQueryName(String queryName)
Set the name of the configured query to populate the options list with. |
void |
setSelectQuery(org.apache.cayenne.query.SelectQuery selectQuery)
Set the SelectQuery to populate the options list with. |
void |
setValueObject(Object object)
Set the valueObject with the given DataObject and the select value to the DataObject primary key value. |
void |
validate()
Validate the QuerySelect request submission. |
Methods inherited from class org.apache.click.control.Select |
---|
add, add, add, add, addAll, addAll, addAll, addAll, bindRequestValue, getControlSizeEst, getDataProvider, getDefaultOption, getDefaultOptionValue, getMultipleValues, getOptionList, getSelectedValues, getSize, getState, getTag, getValidationJavaScript, onRender, setDataProvider, setDefaultOption, setInitialValue, setMultipleValues, setOptionList, setSelectedValues, setSize, setState |
Methods inherited from class org.apache.click.control.Field |
---|
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParent, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setValue, setWidth |
Methods inherited from class org.apache.click.control.AbstractControl |
---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, onInit, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Decorator decorator
protected String queryName
protected org.apache.cayenne.query.NamedQuery namedQuery
protected boolean optional
protected org.apache.cayenne.query.Ordering ordering
protected boolean orderingApplied
protected String optionLabel
protected org.apache.cayenne.query.SelectQuery selectQuery
protected org.apache.cayenne.DataObject valueObject
Constructor Detail |
---|
public PropertySelect(String name)
name
- the name of the fieldpublic PropertySelect(String name, String label)
name
- the name of the fieldlabel
- the label of the fieldpublic PropertySelect(String name, boolean required)
name
- the name of the fieldrequired
- the field required statuspublic PropertySelect(String name, String label, boolean required)
name
- the name of the fieldlabel
- the label of the fieldrequired
- the field required statuspublic PropertySelect()
Method Detail |
---|
public Decorator getDecorator()
public void setDecorator(Decorator decorator)
decorator
- the decorator to render the select option labelspublic String getQueryName()
public void setQueryName(String queryName)
queryName
- the name of the configured query to populate the options list withpublic boolean isMultiple()
isMultiple
in class Select
Select.isMultiple()
public void setMultiple(boolean value)
setMultiple
in class Select
value
- the multiple options can be selected flagSelect.setMultiple(boolean)
public org.apache.cayenne.query.NamedQuery getNamedQuery()
public void setNamedQuery(org.apache.cayenne.query.NamedQuery namedQuery)
namedQuery
- to populate the options list withpublic boolean isOptional()
public void setOptional(boolean value)
value
- set whether the option list includes an empty option valuepublic String getOptionLabel()
public void setOptionLabel(String optionLabel)
optionLabel
- the DataObject property to render as the
option labelpublic org.apache.cayenne.query.SelectQuery getSelectQuery()
public org.apache.cayenne.query.Ordering getOrdering()
public void setOrdering(org.apache.cayenne.query.Ordering ordering)
ordering
- the select query orderingpublic void setSelectQuery(org.apache.cayenne.query.SelectQuery selectQuery)
selectQuery
- the SelectQuery to populate the options
list withpublic Object getValueObject()
getValueObject
in class Field
Field.getValueObject()
public void setValueObject(Object object)
setValueObject
in class Field
object
- the object value to setField.setValueObject(Object)
public boolean onProcess()
loadDataObject()
to load the
DataObject.
onProcess
in interface Control
onProcess
in class Field
Field.onProcess()
public void onDestroy()
onDestroy
in interface Control
onDestroy
in class AbstractControl
Control.onDestroy()
public void validate()
validate
in class Select
Select.validate()
public void render(HtmlStringBuffer buffer)
render
in interface Control
render
in class Select
buffer
- the specified buffer to render the control's output toAbstractControl.toString()
protected void loadDataObject()
protected void loadOptionList()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |