Thanks Dan. It worked. Using a mixin is much better for my approach.

Thanks a lot.
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 <vishma...@cse.mrt.ac.lk>
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.


Reply via email to