@Properties({
@Property(name="phones", entityPropertyType=EntityCollectionProperty.class,
memberType=String.class, view={ViewType.ALL}),
@Property(name="expense", view={ViewType.ALL},
renderStyle=@RenderStyleDef(size=8,
number=@NumberDesc(type=NumberDescriptor.Type.CURRENCY)),
partialBehavior=@PartialBehaviorDef(event=PartialBehavior.EVENT_CHANGE,
execute=VisitTarget.THIS, mode={ModeType.CREATE, ModeType.EDIT}),
column=@Column(styleClass=EntityProperty.CSS_ALIGN_RIGHT),
query=@Query(entityPropertyType=RangeEntityProperty.class, orderByProperty=true))
})
public boolean hasPropertyAnnotations() {
return true;
}
For the example below, the property "type" and "number" is grouped under the group named "typeNumberGroup". Its member layout can be FLOW, GRID, TABLE, or TAB VIEW.
@Properties({
@Property(name="typeNumberGroup", visibleName="TypeAndNumber",
grouping=true, userDefined=true,
renderStyle=@RenderStyleDef(showMemberNames=false, layout=Layout.FLOW, memberSeparator=","),
view={ViewType.ENTITY, ViewType.QUERY}),
@Property(name="type", view={ViewType.ALL}, group="typeNumberGroup",
renderStyle=@RenderStyleDef(style=RenderStyle.SELECT_ONE_MENU),
query=@Query(orderByProperty=true, groupByProperty=true)),
@Property(name="number", view={ViewType.ALL}, group="typeNumberGroup",
renderStyle=@RenderStyleDef(size=2),
query=@Query(orderByProperty=true))
})
The grouping is enabled only in ENTITY and QUERY view. In entity list view,
the grouping is disabled. The group is user defined and does not belong to
the entity type.
Member separator can be a plain or HTML text such as <br/>.
If a parent property has a number of child properties, the parent property can be rendered as a grouping of its child properties.
@Properties({
@Property(name="address", grouping=true,
renderStyle=@RenderStyleDef(showMemberNames=false, layout=Layout.FLOW, memberSeparator="<br/>"),
view={ViewType.ENTITY, ViewType.QUERY}),
@Property(name="address.street", view={ViewType.ALL},
renderStyle=@RenderStyleDef(size=50)),
@Property(name="address.city", view={ViewType.ALL},
renderStyle=@RenderStyleDef(size=30),
query=@Query(orderByProperty=true))
})
@Properties({
@Property(name="address.street", view={ViewType.ENTITY, ViewType.QUERY},
renderStyle=@RenderStyleDef(size=50)),
@Property(name="address.city", view={ViewType.ENTITY, ViewType.QUERY},
renderStyle=@RenderStyleDef(size=30),
query=@Query(orderByProperty=true))
})
Hidden property "address" will be created for view Type ENTITY and QUERY.
@Properties({
@Property(name="level", dynamicValue=true, custom=true,
type=Integer.class,
view={ViewType.ALL}, mode={ModeType.VIEW, ModeType.QUERY},
renderStyle=@RenderStyleDef(size=2))
})
The type attribute specifies the value type of the custom property.
@Properties({
@Property(name="password", retype=true,
minLength=6, maxLength=18,
view={ViewType.ENTITY}, mode={ModeType.CREATE, ModeType.EDIT},
renderStyle=@RenderStyleDef(style=RenderStyle.INPUT_SECRET, feedback=true),
help=@HelpDef(message="InputPasswordHelp", popup=true)),
})
Re-type will create two EntityProperty(s) and their value equality will be validated.
@Properties({
@Property(name="department",
entityPropertyType=EntityHierarchyProperty.class,
renderStyle=@RenderStyleDef(style=RenderStyle.SELECT_ONE_MENU,
pathShowStyle=PathShowStyle.NAME_PATH),
view={ViewType.ALL},
query=@Query(orderByProperty=true))
})
@Properties({
@Property(name="name", view={ViewType.ALL},
column=@Column(renderStyle=@RenderStyleDef(
actionOnClick=ActionOnClick.SHOW_ENTITY,
style=RenderStyle.COMMAND_LINK, openDialogOnShowResults=true)),
query=@Query(orderByProperty=true)),
})
The attribute openDialogOnShowResults specifies whether to open a dialog
to show the action results.
The value of actionOnClick can be SHOW_ENTITY, SHOW_PROPERTY_VALUE, SHOW_PARENT_PROPERTY_VALUE, CUSTOM. For CUSTOM, its action needs to be handled in the EntityBackingBean. For example, show a message onclick:
public class MyTypeBean extends EntityBackingBean<MyType> {
@Override
public PageNavigation clickPropertyValue(PersistenceDataBackingBean<MyType> backingBean,
MyType entity, EntityProperty<MyType> property,
ContainerRenderRegions containerRenderRegions) throws SystemException {
if (property.getName().equals("name")) {
// show a message
ContainerBean containerBean = containerRenderRegions.getTargetContainerBean();
MapEntityBean<MapEntity> textBean = MapEntityBean.createTextBean(property,
new ParameterizedMessage("Info", true, null),
"I am clicked<br/>" + new Date(), true, null, containerBean);
return containerBean.showBean(textBean, containerRenderRegions.getRenderRegions(), true);
}
return super.clickPropertyValue(backingBean, entity, property, containerRenderRegions);
}
}
@Properties({
@Property(name="name", view={ViewType.ALL},
domEvent={DomEventDef(event=DomEventSupport.EVENT_CHANGE,
handler="alert('changed')", mode={ModeType.EDIT})})
})
If a property DOM event handler is dynamic, for example,
DomEventSupport domEventSupport = property.getDomEventSupport(true);
domEventSupport.setDynamic(DomEventSupport.EVENT_CHANGE, true);
its EntityBackingBean needs to provide handler by overriding:
public String getDomEventDynamicHandler(PersistenceDataBackingBean<T> backingBean,
T entity, EntityProperty<T> property, MenuNode menuNode, String event) throws SystemException;
@Properties({
@Property(name="period", uiInsert="ui_insert_period",
view={ViewType.ALL},
converter=PeriodConverter.class,
renderStyle=@RenderStyleDef(size=10)),
@Property(name="", uiInsert="ui_insert_more_properties")
})
The "period" property defined as uiInsert which can be overridden by subclass @UIDefine
annotation. The next property with an empty name defines a placeholder and subclass can
define more properties. A property with an empty name will be ignored if not overridden.
@UIDefines({
@UIDefine(name="ui_insert_more_properties", value={
@Property(name="groupBy", view={ViewType.ALL},
renderStyle=@RenderStyleDef(style=RenderStyle.SELECT_ONE_MENU)),
@Property(name="employee", view={ViewType.ALL}),
@Property(name="code", view={ViewType.ALL})
})
})
public boolean hasPropertyAnnotations() {
return true;
}
A subclass can define uiInsert properties inside the @UIDefine
and they can be overridden by its subclasses. Subclasses here
mean all descendant classes, not only direct subclasses.
EntityBackingBean entityBackingBean = ...
EntityProperty property = new EntityProperty(...);
entityBackingBean.getEntityProperties().add(property);
Users can define their own EntityProperty subclasses.
see Extensions.