|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.bebop.Completable
com.arsdigita.bebop.SimpleComponent
com.arsdigita.bebop.TextStylable
com.arsdigita.bebop.BlockStylable
com.arsdigita.bebop.SimpleContainer
com.arsdigita.bebop.PropertyEditor
Maintains a set of forms that are used when editing the properties of some object. The component maintains a single display pane and a list of forms that are selectable by links.
By default, the component looks something like this:
When the user clicks on a link, the display pane is hidden and the corresponding form is shown.+----------------+ | | | Display Pane | | | +----------------+ [link to form1] [link to form2] [link to form3]
When the user clicks the Save or Cancel button on the form, the form is hidden and the display pane (with its list of links) is shown once again.Enter foo: [ ] Enter bar: [ ] [Save] [Cancel]
The simple usage pattern for this class is as follows:
ThePropertyEditor editor = new PropertyEditor(); editor.setDisplayComponent(new FooComponent()); NameEditForm n = new NameEditForm(); editor.add("name", "Edit Name", n, n.getCancelButton()); AddressEditForm a = new AddressEditForm(); editor.add("address", "Edit Address", a, a.getCancelButton());
PropertyEditor
will automatically add the right
listeners to the forms.
This class is used extensively in the default authoring kit steps,
especially PageEdit
and TextPageBody
in CMS.
Advanced Usage:
The PropertyEditor
may be used to maintain
visibility of any components, not just forms. The
addComponent(String, String, Component)
method
can be used to add an arbitrary component to the editor. The
component will be shown in the list of links, along with other components
and/or forms. The component will be shown as usual when the user clicks
on a link. However, you must be sure to include a call to
showDisplayPane(PageState)
when the component needs to be hidden.
In addition, it is possible to manually generate ActionLink
s
that will display the right components in the editor. The
addComponent(String, Component)
method can be used to add
a component to the PropertyEditor
without automatically
generating the link for it. The addVisibilityListener(ActionLink, String)
method can
then be used to add an appropriate ActionListener
to any
ActionLink
. For example:
Note that the visibility of the form will be handled automatically. There is no need to show or hide it manually. This approach allows greater flexibility in placing links on a page. The links may be part of the editor's display pane, but they do not have to be.// Add a form Form fooForm = new FooForm(); editor.addComponent(FOO_FORM, fooForm); editor.addListeners(fooForm, fooForm.getCancelButton()); // Create a link that shows the form fooLink = new ActionLink("Edit the Foo property"); editor.addVisibilityListener(fooLink, FOO_FORM);
More-advanced Usage:
The PropertyEditor
is backed by a
PropertyEditorModel
through a PropertyEditorModelBuilder
.
Therefore, the PropertyEditor
is a model-backed component,
as described in the Bebop tutorials. This means that the list
of properties for the editor could be generated dynamically during
each request. The setModelBuilder(PropertyEditorModelBuilder)
method can be used to set
a specialized PropertyEditorModelBuilder
for the editor. In order
to write the model builder, you may choose to extend the protected
inner classes PropertyEditor.DefaultModelBuilder
and
PropertyEditor.DefaultModel
. It is also possible to write the model
builder and the corresponding model from scratch. However, most people won't need to
do this.
For example, SecurityPropertyEditor
uses a custom
PropertyEditorModelBuilder
in order to hide the links for properties
which the web user is not allowed to edit.
Nested Class Summary | |
protected static class |
PropertyEditor.DefaultModel
Default implementation of the PropertyEditorModel . |
protected static class |
PropertyEditor.DefaultModelBuilder
Default implementation of the PropertyEditorModelBuilder . |
protected static class |
PropertyEditor.IdentityCellRenderer
Renders the components generated by the model directly |
Field Summary | |
static String |
versionId
|
Fields inherited from class com.arsdigita.bebop.BlockStylable |
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP |
Fields inherited from class com.arsdigita.bebop.SimpleComponent |
m_attr |
Fields inherited from interface com.arsdigita.bebop.Component |
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE |
Constructor Summary | |
PropertyEditor()
Constructs a new, empty PropertyEditor . |
|
PropertyEditor(Component display)
Constructs a new PropertyEditor with the given
display component. |
|
PropertyEditor(Component display,
Container pane)
Constructs a new PropertyEditor with the given
display component and display pane. |
Method Summary | |
void |
add(String key,
String label,
Form form)
Adds a form to the set of forms that can be used to edit the properties. |
void |
add(String key,
String label,
FormSection formSection)
Adds a form to the set of forms that can be used to edit the properties. |
void |
add(String key,
String label,
FormSection formSection,
Submit cancelButton)
Adds a form to the set of forms that can be used to edit the properties. |
void |
add(String key,
String label,
Form form,
Submit cancelButton)
Adds a form to the set of forms that can be used to edit the properties. |
void |
addCancelListener(FormSection form,
Submit cancelButton)
Adds a submission listener to the form that will hide all components and show the display pane. |
void |
addComponent(String key,
Component c)
Adds a component to the property editor. |
void |
addComponent(String key,
String label,
Component c)
Adds a component to the list of links. |
void |
addListeners(FormSection form,
Submit cancelButton)
Adds all required listeners to the form to ensure that if the form is either submitted successfully or cancelled, the display pane will be shown. |
void |
addProcessListener(FormSection form)
Adds a process listener to the form that will hide all components and show the display pane. |
void |
addVisibilityListener(ActionLink l,
String key)
This method can be used to add an ActionListener to any
ActionLink , causing the action link to show the specified
component when it is clicked. |
Component |
getComponent(String key)
Retrieves the component at the specified key. |
Component |
getDisplayComponent()
Returns the display component. |
Container |
getDisplayPane()
Returns the display pane (component + list). |
protected SequentialMap |
getLabelsMap()
Returns the map of labels. |
List |
getList()
Returns the List that contains all the links. |
protected PropertyEditorModel |
getModel(PageState s)
Returns the PropertyEditorModel in use during the current
request. |
protected PropertyEditorModelBuilder |
getModelBuilder()
Returns the PropertyEditorModelBuilder that supplies this
property editor with its PropertyEditorModel during each
request. |
String |
getSelectedComponentKey(PageState state)
Returns the key of the currently visible component, or null if the display pane is currently visible. |
void |
lock()
Locks this component. |
void |
register(Page p)
Registers state parameters for the page with its model. |
void |
setDisplayComponent(Component c)
Adds the display component if it has not been added already. |
protected void |
setModelBuilder(PropertyEditorModelBuilder b)
Sets the PropertyEditorModelBuilder that will supply this
property editor with its PropertyEditorModel during each
request. |
void |
showComponent(PageState state,
String key)
Shows the component that is identified by the specified key. |
void |
showDisplayPane(PageState state)
Hides the form(s) and shows the display pane. |
Methods inherited from class com.arsdigita.bebop.SimpleContainer |
add, add, children, contains, generateChildrenXML, generateParent, generateXML, get, getNamespace, getTag, indexOf, isEmpty, setNamespace, setTag, size |
Methods inherited from class com.arsdigita.bebop.BlockStylable |
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment |
Methods inherited from class com.arsdigita.bebop.TextStylable |
setBackgroundColor, setColor |
Methods inherited from class com.arsdigita.bebop.SimpleComponent |
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, register, respond, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible |
Methods inherited from class com.arsdigita.bebop.Completable |
addCompletionListener, fireCompletionEvent |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.arsdigita.bebop.Component |
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, register, respond, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible |
Methods inherited from interface com.arsdigita.util.Lockable |
isLocked |
Field Detail |
public static final String versionId
Constructor Detail |
public PropertyEditor()
PropertyEditor
.
The setDisplayComponent(Component)
method must be called before
this component is locked.
public PropertyEditor(Component display)
PropertyEditor
with the given
display component. The pane defaults to a SimpleContainer
.
display
- the display componentpublic PropertyEditor(Component display, Container pane)
PropertyEditor
with the given
display component and display pane.
display
- the display componentpane
- the display pane. The caller should pass in a
freshly allocated Container.Method Detail |
public void register(Page p)
Component
param
would do
the following in the body of this method:
p.addComponent(this); p.addComponentStateParam(this, param);You should override this method to set the default visibility of your component:
public void register(Page p) { super.register(p); p.setVisibleDefault(childNotInitiallyShown,false); p.setVisibleDefault(anotherChild, false); }Always call
super.register
when you override
register
. Otherwise your component may
malfunction and produce errors like "Widget ... isn't
associated with any Form"
register
in interface Component
register
in class SimpleComponent
public void showDisplayPane(PageState state)
state
- the page statepublic void showComponent(PageState state, String key)
state
- the page statepublic String getSelectedComponentKey(PageState state)
state
- the page state
public void setDisplayComponent(Component c)
c
- the display component to addpublic void addComponent(String key, Component c)
showComponent(PageState, String)
to display the component and to
call showDisplayPane(PageState)
when the component needs to be hidden.
key
- the symbolic key for the component (must be unique
for this PropertyEditor
)c
- the componentpublic void addComponent(String key, String label, Component c)
showDisplayPane(PageState)
when it is done.
key
- the symbolic key for the component (must be unique
for this PropertyEditor
)label
- the label for the linkc
- the componentpublic void add(String key, String label, Form form)
key
- the symbolic key for the form (must be unique
for this PropertyEditor
)label
- the label for the linkform
- the form componentpublic void add(String key, String label, Form form, Submit cancelButton)
key
- the symbolic key for the form (must be unique
for this PropertyEditor
)label
- the label for the linkform
- the form componentcancelButton
- the Cancel button on the formpublic void add(String key, String label, FormSection formSection)
key
- the symbolic key for the form (must be unique
for this PropertyEditor
)label
- the label for the linkformSection
- the form componentpublic void add(String key, String label, FormSection formSection, Submit cancelButton)
key
- the symbolic key for the form (must be unique
for this PropertyEditor
)label
- the label for the linkformSection
- the form componentcancelButton
- the Cancel button on the formpublic Component getComponent(String key)
key
- the key of the component to retrieve
PropertyEditor
at the specified key, or null
if no such component exists.public void addCancelListener(FormSection form, Submit cancelButton)
PropertyEditor
.
form
- the formcancelButton
- the Cancel button on the formpublic void addProcessListener(FormSection form)
PropertyEditor
.
form
- the formpublic void addListeners(FormSection form, Submit cancelButton)
PropertyEditor
.
form
- the formcancelButton
- the Cancel button on the formpublic void addVisibilityListener(ActionLink l, String key)
ActionListener
to any
ActionLink
, causing the action link to show the specified
component when it is clicked. For example, this method may be useful
if the ActionLink
that is supposed to show the component is
buried somewhere deep within the UI.
l
- the ActionLink
key
- the key of the component that will be shown when the link
is clicked, as specified in the addComponent(String, Component)
methodaddComponent(String, Component)
public List getList()
List
that contains all the links.
List
that contains all the links.protected final PropertyEditorModelBuilder getModelBuilder()
PropertyEditorModelBuilder
that supplies this
property editor with its PropertyEditorModel
during each
request.
PropertyEditorModelBuilder
for this component.protected final void setModelBuilder(PropertyEditorModelBuilder b)
PropertyEditorModelBuilder
that will supply this
property editor with its PropertyEditorModel
during each
request.
b
- the property editor model builderprotected final PropertyEditorModel getModel(PageState s)
PropertyEditorModel
in use during the current
request.
s
- represents the current request
PropertyEditorModel
that supplies the properties
for the current request.public Component getDisplayComponent()
public Container getDisplayPane()
protected SequentialMap getLabelsMap()
public void lock()
lock
in interface Lockable
lock
in class SimpleComponent
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |