1

I added a property to ViewModel and marked it with Editing.ENABLED.

@DomainObject(
        nature = Nature.VIEW_MODEL,
        objectType = "homepage.HomePageViewModel"
)
public class HomePageViewModel {

    @Setter @Getter
    @Property(editing = Editing.ENABLED)
    private String editableField;

}

But this field is not editable on UI: ViewModel property Editing.ENABLED

But it works fine for SimpleObject: Simple DomainObj property Editing.Enabled

Does it work correctly for ViewModel? Maybe ViewModel shouldn't have any properties?

Krunal
  • 77,632
  • 48
  • 245
  • 261
Yurii
  • 25
  • 5

1 Answers1

0

No, it isn't working correctly for view models... the framework is meant to support this.

The good news is that there is a workaround. If you annotate the class to use the (more flexible) JAXB-style of view model, then it all works as expected.

Here's an updated version of the class; look for annotations starting @Xml...:

@XmlRootElement(name = "compareCustomers")
@XmlType(
    propOrder = {
            "editableField"
    }
)
@XmlAccessorType(XmlAccessType.FIELD)
public class HomePageViewModel {

    @XmlElement(required = true)
    @Setter @Getter
    @Property(editing = Editing.ENABLED)
    private String editableField;

    public TranslatableString title() {
        return TranslatableString.tr("{num} objects", "num", getObjects().size());
    }

    public List<SimpleObject> getObjects() {
        return simpleObjectRepository.listAll();
    }

    @XmlTransient
    @javax.inject.Inject
    SimpleObjectRepository simpleObjectRepository;
}

For more on JAXB view models, see the user guide.

Meantime I've raised a JIRA ticket for the issue you've discovered,

Dan Haywood
  • 2,215
  • 2
  • 17
  • 23
  • The workaround with JAXB View Model will work only in 1.15.0 version. See https://stackoverflow.com/questions/44624897/apache-isis-v1-14-0-property-is-not-editable-in-jaxb-view-model – Yurii Jun 19 '17 at 13:56