Each mixin contributes a single member; so write new mixins for those other fields to be decoded.
You'll see I'm using the technique in this code [1] currently under development. HTH Dan [1] https://github.com/apache/isis/tree/ISIS-993/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport On 25 February 2016 at 11:13, Vishma Senadhi Dias <[email protected]> wrote: > Hi Dan, > > Following your method I was able to override BookType field in the > LibrayMember using Mixins. But when I try to override more than one field > in the LibrayMember class using Mixins it seems that only one fields is > shown in the UI. > > For an example when I code like below, only the last field is shown. > > @Mixin > public class LibraryMember_decodedBookType { > private final LibraryMember libraryMember; > public LibraryMember_decodedBookType(LibraryMember lm) { > this.libraryMember = lm; } > > @Action(semanticsOf=SAFE) > @ActionLayout(contributed=AS.Association) > public String bookTypeDecoded() { > return libraryMember.getBookType().equals("N") ? "Novel": "Misc"; > } > > > @Action(semanticsOf=SAFE) > @ActionLayout(contributed=AS.Association) > public boolean Field1Decoded() { > ... > } > > @Action(semanticsOf=SAFE) > @ActionLayout(contributed=AS.Association) > public boolean Field2Decoded() { > ... > } > > > ... > } > > > Can you suggest me a way to fix this and how to edit the JSON to customize > the layout. > > > > > > On 2/23/2016 12:15 PM, Dan Haywood wrote: > >> Hi Vishma, >> >> It you can't change the original class - because it was written for some >> other purpose - then perhaps it might be better to wrap it in a view model >> of your own control. I'm not certain that overriding getBookType() is >> going to work, because it would impact any other users of that view model. >> >> One way to achieve your objective would be to use >> LibraryMember.layout.json >> to hide the original getBookType(), and then define a mixin to expose your >> decode. >> >> @Mixin >> public class LibraryMember_decodedBookType { >> private final LibraryMember libraryMember; >> public LibraryMember_decodedBookType(LibraryMember lm) { >> this.libraryMember = lm; } >> >> @Action(semanticsOf=SAFE) >> @ActionLayout(contributed=AS.Association) >> public String bookTypeDecoded() { >> return libraryMember.getBookType().equals("N") ? "Novel": >> "Misc"; >> } >> } >> >> HTH >> Dan >> >> >> >> >> >> >> On 23 February 2016 at 06:30, Vishma Senadhi Dias < >> [email protected]> >> wrote: >> >> Hi all, >>> >>> I have a jaxb annotated view model which have several fields with getters >>> and setters. I want to override the getter of a specific field so that >>> different value will appear on the UI. But the original getter should not >>> be changed. >>> >>> example: >>> >>> |public class LibraryMember { private String bookType; public String >>> getBookType() { ... } public void setBoookType(String bookType) { ... } >>> }| >>> >>> >>> In the above example, can I override getBookType() so that a different >>> value will render on the wicket viewer? I should be able to update the >>> getter like this, >>> >>> |public String updateBookType( if(this.getBookType.equals("N")) return >>> "novel"; else return "Misc"; }| >>> >>> >>> >>> I have restrictions like I cannot change the original class. Can I use a >>> DomainService or some other inbuilt implementation of ISIS to achieve my >>> objective without altering my original class? >>> Any help would be highly appreciated. >>> >>> Thanks in advance, >>> Vishma. >>> >>> >
