|
Re: Page templates [message #1402875 is a reply to message #1402861] |
Fri, 18 July 2014 01:38   |
Eclipse User |
|
|
|
Dennis Geesen wrote on Thu, 17 July 2014 23:29So, I extracted an AbstractUserPage (like a template) and used it as the superclass for the four pages and each page overrides the execLoadTableData to load its appropriate data. This seems to work, but now I cannot change the table/columns of AbstractUserPage (to get all changes also for the four implementations) within the scout explorer.
Is this the right approach for page templates or is there another possibility, so I have the full scout explorer support? I think it is very similar to form field templates, but for pages
I think this is a brilliant idea. It is consistent with the pattern used for fields.
I am afraid that every possibility offered by the java language and supported by Scout RT is not always supported by the Scout perspective.
You should open a enhancement request Bug in bugzilla.
I really like you "template" and class overriding approach, but you asked if there is an other possibility.
Some applications I know are using a "presentation type" approach.
@PageData(UsersTablePageData.class)
public class UsersTablePage extends AbstractPageWithTable<Table> {
public enum PresentationType {
ALL_USERS,
ONLY_ACTIVE_USERS,
FEMALE_USERS,
MALE_USERS
}
private final PresentationType m_presentationType;
/**
* @param presentationType
*/
public UsersTablePage(PresentationType presentationType) {
super(presentationType.toString());
m_presentationType = presentationType;
}
@Override
protected void execLoadData(SearchFilter filter) throws ProcessingException {
UsersTablePageData pageData;
IStandardOutlineService service = SERVICES.getService(IStandardOutlineService.class);
switch (m_presentationType) {
case ALL_USERS:
//import page data for all users:
pageData = service.getAllUsers();
break;
case ONLY_ACTIVE_USERS:
//import page data for active users:
pageData = service.getActiveUsers();
break;
case FEMALE_USERS:
//import page data for female users:
pageData = service.getFemaleUsers();
break;
case MALE_USERS:
//import page data for male users:
pageData = service.getMaleUsers();
break;
default:
throw new IllegalStateException("Unexpected presentation type");
}
importPageData(pageData);
}
//...
}
Notice that the userPreferenceContext will be set by calling super(String) in the constructor. This is important because otherwise, Scout RT will not have enough information to distinguish the page instances especially if they are in the same NodePage (for bookmarks, table preferences...).
.
|
|
|
|
|
Re: Page templates [message #1402943 is a reply to message #1402913] |
Fri, 18 July 2014 10:54  |
Eclipse User |
|
|
|
ok, that is what I thought too, because it is also a nice approach.
However, I have used it as follows:
The main class for all Users:
public class UsersTablePage extends AbstractPageWithTable<Table>{
...
protected PresentationType getPresentationType(){
return PresentationType.ALL_USERS;
}
...
}
the getPresentationType is used in the execLoadTableData to
Then i derived from this class and override the method:
public class ActiveUsersTablePage extends UsersTablePage{
...
@Override
protected PresentationType getPresentationType(){
return PresentationType.ACTIVE_USERS;
}
...
}
There are two benefits:
1) you can edit the UsersTablePage class via the SDK and you get all changes also in the derived pages.
2) you can override and set other configuration data (e.g. like title, icon id and so on) using the SDK. The table is the only thing that is missing.
|
|
|
Powered by
FUDForum. Page generated in 0.04790 seconds