...
Anchor |
---|
| viewListeners |
---|
| viewListeners |
---|
|
2.5.
...
Row style resolver
(Grid's row ) Row style resolvers returns set of CSS clas names for given row entity. You can use them to mark specified grid rows, e.g. whith negative balance of some arbitrary values.
Resolver method is invoked for each of grid's entity.
Code Block |
---|
theme | Eclipse |
---|
language | java |
---|
linenumbers | true |
---|
|
public Set<String> gridRowStyleResolverNamerowStyleResolverName(final Entity rowEntity) {
// GRID ROW STYLE RESOLVER BODY
}
|
Where
- gridRowStyleResolverName rowStyleResolverName - arbitrary name of resolver method
- rowEntity - entity which will be shown in row
To attach see how to bind created resolver method to grid or lookup component see 'grid with view component go to 'row style resolvers' section.
3. Example
3.1 Custom validator example
...
Code Block |
---|
theme | Eclipse |
---|
language | java |
---|
linenumbers | true |
---|
|
public void checkAcceptedDefectsQuantity(final ViewDefinitionState viewDefinitionState, final ComponentState state,
final String[] args) {
if (!(state instanceof FieldComponentState)) {
throw new IllegalStateException("component is not input");
}
FieldComponentState acceptedDefectsQuantity = (FieldComponentState) state;
FieldComponentState comment = (FieldComponentState) viewDefinitionState.getComponentByReference("comment");
if (acceptedDefectsQuantity.getFieldValue() != null) {
if (isNumber(acceptedDefectsQuantity.getFieldValue().toString())
&& (new BigDecimal(acceptedDefectsQuantity.getFieldValue().toString())).compareTo(BigDecimal.ZERO) > 0) {
comment.setRequired(true);
} else {
comment.setRequired(false);
}
}
} |
3.4
...
Row style resolver example
Code Block |
---|
theme | Eclipse |
---|
language | java |
---|
linenumbers | true |
---|
|
public Set<String> testResolverMethodproductsListRowStyleResolver(final Entity product) {
final Set<String> entityStyles = Sets.newHashSet();
final String materialType = product.getStringField(ProductFields.GLOBAL_TYPE_OF_MATERIAL);
if ("04waste".equals(materialType)) {
entityStyles.add(GridComponent.CSS_RED_BG);
}
if (StringUtils.isBlank(product.getStringField(ProductFields.EAN))) {
entityStyles.add(GridComponent.CSS_BOLD_FONT);
}
return entityStyles;
} |