简体   繁体   中英

Scout Eclipse TablePage Template

I want to create AbstractTemplatePageWithTable as template.

My problem is that when you create template :

 MyPageTemplateTablePage
           |
           ---> MyTable Extends AbstractTable

or in code

public abstract class MyPageTemplateTablePage extends AbstractExtensiblePageWithTable<MyTable> {

  @Override
  protected String getConfiguredTitle() {

    return TEXTS.get("bla bla");
  }


  public abstract class MyTable extends AbstractExtensibleTable {


  }
}

But When I create Page from this template it create "only" page.

 @PageData(MyPageTablePageData.class)
 public class MyPageTablePage extends MyPageTemplateTablePage {

   @Override
   protected String getConfiguredTitle() {

     return TEXTS.get("MyPage");
    }
  }

What I would want is that it is created :

@PageData(MyPageTablePageData.class)
 public class MyPageTablePage extends MyPageTemplateTablePage {

   @Override
   protected String getConfiguredTitle() {

     return TEXTS.get("MyPage");
    }

    @Order(10.0)
    public class table extends MyPageTemplateTablePage.MyTable {


    }
  }

Because when you create template, it should be user-friendly and provide table. Is there some annotation or something to convince scout-eclipse creator of class to create this table to.

It is really hard to have wizards that suit all needs in the Scout SDK. Since Scout is plain Java you can organize the code as you like. There are 2 classes: Table and TablePage having the Table as inner class of the TablePage is convenient but not mandatory especially if you are preparing templates.

If you have logic on your table (like common methods or inner classes for menus or columns) I recommend you to create a first Table template:

public abstract class AbstractMyTable extends AbstractTable {
  //some custom logic.
}

Then you can define a TablePage template using Generic. You can even restrict the table to be from type AbstractMyTable

public abstract class AbstractMyTablePage<T extends AbstractMyTable> extends AbstractPageWithTable<T> {
  //some custom logic.
}

You might lose some of the SDK support using this pattern, but when you create a new table page you can modify your code to use your table template and your table page template:

@PageData(XxxxTablePageData.class)
public class XxxxTablePage extends AbstractMyTablePage<Table> {

  @Order(1000.0)
  public class Table extends AbstractMyTable {

  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM