|
Re: Page templates [message #1402875 is a reply to message #1402861] |
Fri, 18 July 2014 05:38 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
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...).
.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03086 seconds