Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Accessing the Table Page from an Abstract Menu
Accessing the Table Page from an Abstract Menu [message #1124372] Thu, 03 October 2013 13:20 Go to next message
Alex Schroeder is currently offline Alex SchroederFriend
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland
Member

MyTablePage has a menu:

    @Order(20.0)
    public class NewMenu extends AbstractNewMenu {
      @Override
      MyTablePage getTablePage() {
        return MyTablePage.this;
      }
      @Override
      String getProduktCode() {
        return "A7000";
      }
      @Override
      protected String getConfiguredText() {
        return TEXTS.get("NewItemCodeA7000");
      }
    }


The AbstractNewClass I have contains:

  @Override
  protected void execAction() throws ProcessingException {
    MyForm form = new MyForm();
    // some setup elided
    form.startNew();
    form.waitFor();
    if (form.isFormStored()) {
      getTablePage().reloadPage();
    }
  }

  MyTablePage getTablePage() {
    return null;
  }


The problem is that for this single call of reloadPage, I need to add the method getTablePage to every instance of my new menu.

At first, I thought I could simply call MyTablePage.this.reloadPage() or MyTablePage.Table.this.reloadPage() or MyTablePage.(Table.this).reloadPage() ... but it was not to be.

Help my Java-fu: how can I save four lines of code for every instance of my new menu?
Re: Accessing the Table Page from an Abstract Menu [message #1124430 is a reply to message #1124372] Thu, 03 October 2013 14:29 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 818
Registered: October 2011
Senior Member
Alex Schroeder wrote on Thu, 03 October 2013 15:20

The problem is that for this single call of reloadPage, I need to add the method getTablePage to every instance of my new menu.


I do not see how you can do it in an other way... Because your template (AbstractNewMenu) is not aware that it will be included in a TablePage... I could be used everywhere.

In my templates, when I need something like that, I named the accessing method (getTablePage in your case) provideXxxxx() and I declare it abstract. This way I am sure that the developer using my template will pass the required Xxxxx instance.
Re: Accessing the Table Page from an Abstract Menu [message #1124441 is a reply to message #1124430] Thu, 03 October 2013 14:40 Go to previous message
Alex Schroeder is currently offline Alex SchroederFriend
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland
Member

Thank you for spotting that I had forgotten to make getTablePage in my template abstract.

I guess I was just disappointed to learn that getParent() returns IMenu and no getParentPage() exists... Smile

[Updated on: Thu, 03 October 2013 14:40]

Report message to a moderator

Previous Topic:Problem after deploying to tomcat
Next Topic:How to find resource files in server?
Goto Forum:
  


Current Time: Sat Dec 20 20:12:46 GMT 2014

Powered by FUDForum. Page generated in 0.01963 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software