AbstractPageWithNodes with default page [message #1738844] |
Mon, 25 July 2016 12:16 |
Andreas Christ Messages: 32 Registered: April 2016 |
Member |
|
|
I have some AbstractPageWithNodes in the lefthand menu. And as soon as I click on an item, there will be a list of all child nodes in the main frame. (see screenshot)
Well, I'd like to have the first child of that list opened instead of that redundant child list - which will be displayed in the menu anyhow.
How can i tweak the menu to display the first child in the list?
[Updated on: Mon, 25 July 2016 12:17] Report message to a moderator
|
|
|
Re: AbstractPageWithNodes with default page [message #1739526 is a reply to message #1738844] |
Tue, 02 August 2016 16:46 |
|
What you describe is the default behavior of Scout. Each node in the outline tree on the left is linked to a specific content on the right. A page with sub-nodes does not display any content of the sub-nodes by default, because it usually is not semantically appropriate. It is also not easy to tell which is the "first" node, because the child nodes might be ordered or filtered in a special way. For example, when you have a "Persons" folder with "Alice", "Bob" and "Charlie" as child nodes, you don't see Alice's data when you click on "Persons". Instead you see a list of persons, possibly with a search form.
What exactly is your intention? When you select "Baubarkeit", would you like to see the content of "Baubarkeit modifizieren"? Is the number of child nodes of "Baubarkeit" dynamic? Can you have more than one? If you just want to switch between a "view mode" and an "edit mode" of an item, the usual pattern would be to have a detail form with a "read only" form handler on the node page, including an "edit" menu that opens the same form again with a "modify" form handler.
Another possibility is that you want to automatically select the "Baubarkeit modifizieren" node as soon as the user selects "Baubarkeit". This could be achieved by overriding "execPageActivated()" in your node page and programmatically changing the selected node in the outline tree.
If you need further assistance, I suggest that you elaborate the goal you are trying to achieve, and maybe post some code.
Regards,
Beat
|
|
|
|
Re: AbstractPageWithNodes with default page [message #1739936 is a reply to message #1739886] |
Fri, 05 August 2016 18:23 |
|
Andreas,
I'm not quite sure if I understood your intentions. I have made an example of what I think you are trying to achieve:
public class BaubarkeitForm extends AbstractForm {
public GroupBox getGroupBox() {
return getFieldByClass(GroupBox.class);
}
public class MainBox extends AbstractGroupBox {
@Order(1000)
@ClassId("f8727d17-a92c-4a48-ac66-e9c198578a67")
public class GroupBox extends AbstractGroupBox {
// ...
}
}
public void startView() {
startInternal(new ViewHandler());
}
public void startModify() {
startInternal(new ModifyHandler());
}
public class ViewHandler extends AbstractFormHandler {
@Override
protected void execLoad() {
getGroupBox().setLabel("View data");
}
}
public class ModifyHandler extends AbstractFormHandler {
@Override
protected void execLoad() {
getGroupBox().setLabel("Modify data");
}
}
}
public class BaubarkeitPage extends AbstractPageWithNodes {
@Override
protected String getConfiguredTitle() {
return "Baubarkeit";
}
// *** Not necessary if child page is activated automatically: ***
//
// @Override
// protected Class<? extends IForm> getConfiguredDetailForm() {
// return BaubarkeitForm.class;
// }
//
// @Override
// protected void startDetailForm() {
// ((BaubarkeitForm) getDetailForm()).startView();
// }
@Override
protected void execCreateChildPages(List<IPage<?>> pageList) {
pageList.add(new BaubarkeitModifyPage());
}
@Override
protected void execPageActivated() {
setExpanded(true);
// Schedule automatic child selection to allow the current selection to be fully completed
ModelJobs.schedule(new IRunnable() {
@Override
public void run() {
getTree().selectNode(getChildNode(0));
}
}, ModelJobs.newInput(ClientRunContexts.copyCurrent()));
}
}
public class BaubarkeitModifyPage extends AbstractPageWithNodes {
@Override
protected String getConfiguredTitle() {
return "Baubarkeit modifizieren";
}
@Override
protected boolean getConfiguredLeaf() {
return true;
}
@Override
protected Class<? extends IForm> getConfiguredDetailForm() {
return BaubarkeitForm.class;
}
@Override
protected void startDetailForm() {
((BaubarkeitForm) getDetailForm()).startModify();
}
}
When I tried this example I found that changing the tree selection during execPageActivated() does not work. The reason is that the selection of the "Baubarkeit" node has not been fully completed. execPageActivated() is in fact called before the corresponding selection event is fired. Because of that odd behavior, the new selection is always overwritten. I will investigate this issue further and probably make a bug report.
As a workaround, I wrapped the selection code inside a new "model job". This construct is similar to JavaScript's setTimeout() and schedules the inner code for execution as soon as the current action has been fully completed.
I hope that helps.
Regards,
Beat
|
|
|
|
Powered by
FUDForum. Page generated in 0.04835 seconds