|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.control.AbstractControl net.sf.click.control.Field net.sf.click.control.Select net.sf.click.extras.cayenne.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 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.
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 net.sf.click.control.Select |
multiple, optionList, selectedValues, size, VALIDATE_SELECT_FUNCTION |
Fields inherited from class net.sf.click.control.Field |
disabled, error, focus, form, help, label, readonly, required, tabindex, title, validate, value |
Fields inherited from class net.sf.click.control.AbstractControl |
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface net.sf.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 | |
void |
bindRequestValue()
Bind the request value to the control, looking up the DataObject based on the submitted primary key value and setting this object as the Select valueObject. |
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 |
loadOptionList()
Load the Select options list. |
void |
onDestroy()
Clear the cached valueObject. |
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. |
Methods inherited from class net.sf.click.control.Select |
add, add, add, addAll, addAll, addAll, addAll, getControlSizeEst, getMultipleValues, getOptionList, getSelectedValues, getSize, getTag, getValidationJavaScript, setInitialValue, setMultipleValues, setOptionList, setSelectedValues, setSize, validate |
Methods inherited from class net.sf.click.control.Field |
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getWidth, isDisabled, isHidden, isReadonly, isRequired, isValid, onInit, onProcess, setDisabled, setError, setErrorMessage, setErrorMessage, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setListener, setParent, setReadonly, setRequired, setTabIndex, setTextAlign, setTitle, setValidate, setValue, setWidth |
Methods inherited from class net.sf.click.control.AbstractControl |
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getHtmlImports, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasStyles, onDeploy, onRender, registerActionEvent, removeStyleClass, renderTagBegin, 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()
Select.isMultiple()
public void setMultiple(boolean value)
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()
Field.getValueObject()
public void setValueObject(Object object)
object
- the object value to setField.setValueObject(Object)
public void bindRequestValue()
Select.bindRequestValue()
public void render(HtmlStringBuffer buffer)
buffer
- the specified buffer to render the control's output toAbstractControl.toString()
public void onDestroy()
Control.onDestroy()
protected void loadOptionList()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |