Hi Dan,
I initially thought I need to apply the titleUiEvent to the
Mixin but when I changed it to the original view model it worked. I haven't
tried using the custom facet factory still. I will follow the documentation
on that. Thank you.
Best Regards,
Dilshan.
On Sun, Mar 20, 2016 at 8:09 PM, Dan Haywood <[email protected]>
wrote:
> Hi Dilshan,
>
> You don't quite have this right.
>
> It's still necessary to annotate the view model with @DomainObjectLayout,
> and optionally to specify a titleUiEvent, eg [1]
>
> The event subscriber then checks for the event on the JAXB view model, eg
> [2]
>
> If you didn't want to annotate the JAXB view model with
> @DomainObjectLayout, then you could instead write a custom facet factory
> that looked for the JAXB @XmlRootElement and did the same job; details in
> [3]. I've raised ISIS-1337 for this idea [4]
>
> HTH
> Dan
>
>
> [1]
>
> https://github.com/isisaddons/isis-app-todoapp/blob/master/dom/src/main/java/todoapp/app/viewmodels/todoitem/v1/ToDoItemV1_1.java#L43
> [2]
>
> https://github.com/isisaddons/isis-app-todoapp/blob/master/app/src/main/java/todoapp/app/services/titlesubscriber/UiEventSubscriber.java#L41
> [3] http://isis.apache.org/guides/ugbtb.html#_modifying_the_prog_model
> [4] https://issues.apache.org/jira/browse/ISIS-1337
>
>
>
> On 2 March 2016 at 09:55, Shan Wijesinghe <[email protected]>
> wrote:
>
> > * Please ignore the mismatch between the Myclass_viewmodel and it's
> > constructor named as TrsItem_ViewModelTrs
> >
> > On Wed, Mar 2, 2016 at 3:18 PM, Shan Wijesinghe <
> [email protected]
> > >
> > wrote:
> >
> > > Thank you for the information Dan.
> > >
> > > I did the following. But it seems title is not set still. What is the
> > > problem.
> > >
> > > // Mixin
> > >
> > > @DomainObject(nature = Nature.MIXIN)
> > > @DomainObjectLayout(titleUiEvent =
> Myclass_viewmodel.TitleUiEvent.class)
> > > public class Myclass_viewmodel {
> > >
> > > private final Myclass myclass;
> > >
> > > public TrsItem_ViewModelTrs(Myclass myclass) {
> > >
> > > this.myclass = myclass ;
> > > }
> > > ...
> > >
> > >
> > >
> > > public static class TitleUiEvent extends
> > >
> org.apache.isis.applib.services.eventbus.TitleUiEvent<Myclass_viewmodel>
> > {
> > >
> > > protected String title ;
> > > public String getTitle() {
> > > return title ;
> > > }
> > >
> > > public void setTitle(String title) {
> > > this.title = title ;
> > > }
> > > public TitleUiEvent() {
> > >
> > > }
> > > }
> > >
> > > }
> > >
> > >
> > > // Subscriber
> > >
> > >
> > > @DomainService(nature=NatureOfService.DOMAIN)
> > > public class MyclassTitle extends AbstractSubscriber{
> > > @com.google.common.eventbus.Subscribe
> > > public void on(TitleUiEvent ev) {
> > > if(ev.getSource() instanceof Myclass_viewmodel) {
> > >
> > > ev.setTitle("MY TITLE");
> > >
> > > }
> > > }
> > >
> > > }
> > >
> > >
> > > On Wed, Mar 2, 2016 at 12:53 PM, Dan Haywood <
> > [email protected]
> > > > wrote:
> > >
> > >> The easiest approach is probably to use the UiEvent classes defined in
> > >> @DomainObjectLayout, and then set up a subscriber of these events.
> > >>
> > >> HTH, Dan
> > >> On 2 Mar 2016 07:03, "Shan Wijesinghe" <[email protected]>
> > wrote:
> > >>
> > >> > Hi all,
> > >> >
> > >> > I have a JAXB annotated view model. I want to change "title" and
> > >> > "iconName" using a Mixin to my original java class without adding
> > title
> > >> > and iconName methods to original class. How can I do this. Please
> make
> > >> > suggestions. Thanks in advance.
> > >> >
> > >> > --regards
> > >> > Dilshan.
> > >> >
> > >>
> > >
> > >
> >
>