public abstract class FormComponent extends Object implements Serializable, com.vaadin.server.ClientConnector.AttachListener
FormComponent
. As a consequence, there is no Repeater component anymore -
just add necessary components dynamically. Also, there are no table iterators.FormComponent
connectors do not extend Vaadin components themselves - they instead provide proper Vaadin component instances
via getWidget()
. This allows for parallel inheritance hierarchy.call("methodName", [args])
method in the expression language - the call(ExecutionContext, String, Object[])
will be called.
Please red the call(ExecutionContext, String, Object[])
javadoc for further information.
To call back the LSPS UI:
rv = form.getDef(this)
rv.closure().noScope().call(params)
rv.call(executionContext.getNamespace(), "method", "arg1", new Decimal(2));
ComponentServiceBase
, then insert this field into your component:
@EJB private YourBean bean;The EJBs are injected right after the constructor finishes.
Modifier and Type | Field and Description |
---|---|
protected Form |
form
Every component maintains a link to its owner form.
|
static String |
INTERNAL_STATE_RECORD_PROPERTY
Property used to store internal state (when saving todo or form state).
|
Modifier | Constructor and Description |
---|---|
protected |
FormComponent() |
Modifier and Type | Method and Description |
---|---|
void |
addDataErrorMessage(String errorMessage)
Adds data validation error message.
|
void |
addStyleName(String style) |
void |
attach(com.vaadin.server.ClientConnector.AttachEvent event) |
Object |
call(ExecutionContext ctx,
String method,
Object[] args)
Calls a method on the underlying Java UI component.
|
void |
clearDataErrorMessages()
Removes all data error messages.
|
protected RecordHolder |
createEvent(String type) |
protected abstract com.vaadin.ui.AbstractComponent |
createWidget()
Called once, to create the actual Vaadin component.
|
boolean |
equals(Object obj) |
String |
getCaption() |
EnumerationImpl |
getComponentAlignment()
Gets the component alignment
|
ClosureHolder |
getContextClickHandler()
Gets the context click handler.
|
String |
getCustomErrorMessage()
Gets the component error message.
|
ListHolder |
getDataErrorMessages() |
String |
getDescription() |
Decimal |
getExpandRatio()
Gets the expand ratio of this component.
|
IHasChildren |
getHasChildrenAdapter()
Provides an adapter of this component which allows easily invoke methods on
the
forms::HasChildren interface. |
String |
getHeight()
Gets the height of this component
|
RecordHolder |
getIcon()
Gets the icon of this component.
|
String |
getModelingId()
Gets the modeling ID of this component.
|
Namespace |
getNamespace()
Gets the namespace this form component should use when it needs
to create LSPS objects of complex types or call record methods.
|
String |
getStyleName() |
Decimal |
getTabIndex()
Gets the tabulator index of this component.
|
com.vaadin.ui.AbstractComponent |
getWidget()
Gets the Vaadin representation of this component.
|
String |
getWidth()
Gets the width of this component.
|
int |
hashCode() |
boolean |
isEnabled() |
boolean |
isReadOnly() |
boolean |
isVisible() |
protected String |
localize(String message)
Utility method which simply calls
LspsLocalizer to localize given string. |
void |
markAsDirty() |
void |
preventGC(Set<ValueHolder> set)
Override for all components which are actively using some record holders, not directly linked to the model.
|
void |
removeStyleName(String style) |
protected void |
restoreInternalState(Map<String,Object> state)
Restores the UI state of this component which was previously written
by
writeInternalState(Map) . |
void |
restoreState()
Restores the UI state of this component from the state stored in the definition record.
|
void |
saveState()
Saves the UI state of this component to the record definition.
|
void |
setCaption(String caption) |
void |
setComponentAlignment(EnumerationImpl align)
Sets the component alignment.
|
void |
setContextClickHandler(ClosureHolder clickHandler)
Sets the context click handler.
|
void |
setContextMenuItems(ListHolder itemsHolder)
Sets the context menu items.
|
void |
setCustomErrorMessage(String errorMessage)
Sets custom component error message.
|
void |
setDescription(String description) |
void |
setEnabled(boolean enabled) |
void |
setExpandRatio(Decimal ratio)
Sets the expand ratio of this component.
|
void |
setHeight(String height) |
void |
setIcon(RecordHolder resource)
Sets the icon of this component.
|
void |
setReadOnly(boolean readOnly) |
void |
setStyleName(String style) |
void |
setTabIndex(Decimal tabIndex)
Sets the tabulator index of this component
|
void |
setVisible(boolean visible) |
void |
setWidth(String width) |
String |
toString() |
protected void |
writeInternalState(Map<String,Object> state)
Writes the UI state of this component to the provided map.
|
public static final String INTERNAL_STATE_RECORD_PROPERTY
protected final Form form
protected abstract com.vaadin.ui.AbstractComponent createWidget()
public com.vaadin.ui.AbstractComponent getWidget()
public Object call(ExecutionContext ctx, String method, Object[] args)
FormComponent
connector;
if there is no such method, the underlying Vaadin widget is searched. If there is no such method, this method fails with an exception.
getWidget()
. You can override this mechanism by overriding this method, but this is not recommended, unless you somehow wish to support
dynamic number of methods. In such case, do not forget to call the super method (this method).ctx
- method
- the method name, not null.args
- optional list of parameters, not null.RuntimeException
- if no such method exists.public Namespace getNamespace()
Boolean
,
String
, Date
, Decimal
. In the other hand when creating
RecordHolder
, CollectionHolder
and any other
complex type, the namespace must be used so that the created object
of the complex type is also registered in the model instance.
Usage example
getNamespace().createRecord("uicommon::FileResource");
public String getWidth()
public String getModelingId()
protected String localize(String message)
LspsLocalizer
to localize given string.message
- the message, may be nullpublic void setCustomErrorMessage(String errorMessage)
errorMessage
- the error message to setpublic String getCustomErrorMessage()
setErrorMessage
method, it does NOT contain data constraint error messages nor validation error messages.public void addDataErrorMessage(String errorMessage)
errorMessage
- public void clearDataErrorMessages()
public ListHolder getDataErrorMessages()
protected RecordHolder createEvent(String type)
public Decimal getTabIndex()
public void setTabIndex(Decimal tabIndex)
tabIndex
- the tabulator indexpublic String getHeight()
public void preventGC(Set<ValueHolder> set)
WTabSheet
maintains a set of opened tabs. These tab records are not referenced
directly from forms::TabSheet and will therefore be garbage-collected. We however need those records to not to be GCed as the user
may ask for them simply by calling getTab(Integer).
Please note that the component definition records (e.g. forms::Button) are already GC-protected and they do not need to be added to this set.
Also, any child components currently attached to the UI are automatically protected and are not required to be registered in the set.set
- a set of records which are to be GC-prevented, never null. The component should add any records here.
Default implementation does nothing.public void attach(com.vaadin.server.ClientConnector.AttachEvent event)
attach
in interface com.vaadin.server.ClientConnector.AttachListener
public void setExpandRatio(Decimal ratio)
ratio
- the expand ratio to setpublic Decimal getExpandRatio()
public void setComponentAlignment(EnumerationImpl align)
Layout.AlignmentHandler
.align
- the alignment to setpublic EnumerationImpl getComponentAlignment()
public void setIcon(RecordHolder resource)
resource
- the icon.public RecordHolder getIcon()
null
public void setContextClickHandler(ClosureHolder clickHandler)
clickHandler
- the context click handlerpublic ClosureHolder getContextClickHandler()
null
if none is installedpublic void setContextMenuItems(ListHolder itemsHolder)
itemsHolder
- a list of context menu itemspublic IHasChildren getHasChildrenAdapter()
forms::HasChildren
interface. If this component does not implement the interface then
and adapter returning no children is returned.IHasChildren
interface, never null
.public final void saveState()
writeInternalState(Map)
public final void restoreState()
restoreInternalState(Map)
protected void writeInternalState(Map<String,Object> state)
Many UI attributes such as size, caption, etc. are not held in the records but are stored exclusively in the Vaadin components. In the records the getter/setter methods of such attributes directly delegate to the underlying component. For the purposes of the Save Document/Todo use case the state of such attributes has to be preserved.
Subclasses should override this method. The overriding method should call
super.writeInternalState(state)
to store the state form the super
class as well. The attributes should be written to the provided state
parameter. The type of the values written to the state
can only by
Java representation of LSPS types. That is java.util.Date
,
java.lang.String
, Decimal
, RecordHolder
,
ListHolder
, ... The name of the attributes stored in the map
should be unique and should not collide with the names used by any
of the superclass. It is the responsibility of the overridden method to ensure
that.
Subclasses overriding this method should also override
restoreInternalState(Map)
and restore the state written
by this method.
state
- a map to which this method should write the component's UI state.restoreInternalState(Map)
,
saveState()
protected void restoreInternalState(Map<String,Object> state)
writeInternalState(Map)
.
Subclasses should override and call super.restoreInternalState(state);
state
- a map of attributes and their valueswriteInternalState(Map)
public boolean isVisible()
public void setVisible(boolean visible)
public void setWidth(String width)
public void setHeight(String height)
public String getCaption()
public void setCaption(String caption)
public boolean isReadOnly()
public void setReadOnly(boolean readOnly)
public String getStyleName()
public void setStyleName(String style)
public void addStyleName(String style)
public void removeStyleName(String style)
public boolean isEnabled()
public void setEnabled(boolean enabled)
public String getDescription()
public void setDescription(String description)
public void markAsDirty()
Copyright © 2007-2018 Whitestein Technologies. All Rights Reserved.