Compoisite Component Permission

I have a composite component that extends a datefield to add “today” and “clear” buttons. These buttons should be disabled when the field is not editable or when it is not enabled. When I call setEditable or setEnabled from a screen controller, the field behaves as expected. However, the buttons do not seem to honor attribute permissions. If I set a date attribute as read-only as part of a role and use my custom component as the component in a form, the value field honors those permissions but I can’t figure out how to get the buttons to also honor them.

Attached are the definitions and controller for the composite component.

Help? (4.5 KB)
todaydate-component.xml (539 Bytes) (6.2 KB)


There is a two options I can suggest:

  1. Extend WebDateField and track if editable is changed. In TodayDate component subscribe to editable change event. For instance:
Exntension of WebDateFied
public class WebTodayDateField<V extends Comparable<V>> extends WebDateField<V> {

    protected void setEditableToComponent(boolean editable) {

        publish(EditableChangeEvent.class, new EditableChangeEvent(this, editable));

    public Subscription addEditableChangeListener(Consumer<EditableChangeEvent> listener) {
        return getEventHub().subscribe(EditableChangeEvent.class, listener);

    public static class EditableChangeEvent extends EventObject {

        protected Boolean editable;

        public EditableChangeEvent(WebTodayDateField source, Boolean editable) {

            this.editable = editable;

        public WebTodayDateField getSource() {
            return (WebTodayDateField) super.getSource();

        public Boolean getEditable() {
            return editable;
Extension loader
public class WebTodayDateFieldLoader extends DateFieldLoader {

    public void createComponent() {
        resultComponent = factory.create(WebTodayDateField.NAME);
        loadId(resultComponent, element);
private void onCreate(CreateEvent createEvent) {
    valueField = getInnerComponent("valueField");
    todayBtn = getInnerComponent("todayBtn");
    clearBtn = getInnerComponent("clearBtn");

    todayBtn.addClickListener(clickEvent -> setTodayDate());
    clearBtn.addClickListener(clickEvent -> clearDate());

    ((WebTodayDateField<Date>) valueField).addEditableChangeListener(editableChangeEvent -> {
  1. Add state change listener to the ValueSource. The state will be active if an item is set to the container, and we can update the availability of buttons. However, it doesn’t work if an item won’t be loaded or we set ValueSource that already has an item to the component.