Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
5.3.2
-
None
Description
I want to add css class to label if field is required in my custom ValidationDecorator:
@Override
public void insideLabel(Field field, Element labelElement) {
if(field == null) return;
if(field.isRequired())
{ labelElement.addClassName("required-label"); }if(inError(field))
{ labelElement.addClassName(CSSClassConstants.ERROR); }}
It does not work with BeanEditForm component. The problem arises because method ValidationDecorator.insideLabel(...) is called in Label component after removal of PropertyContext from Environment (PropertyContext is needed for get the validator and call isRequired() method):
@HeartbeatDeferred
private void updateAttributes()
The solution for this problem would be to move the call to decorator.insideLabel (field, labelElement) to the beginRender method in Label component. Label decorating does not need to wait for rendering field element and only needs a label element.