TOPIC: Display a controller inside a book window
#987
Display a controller inside a book window 2 Years, 12 Months ago
Hi, there is a way to call a Controller class from the code of another Controller that is embedded in a Suneido book, in a way that the Controller window appears inside the book, and not in a separated window?

For example, let's suppose that I have defined a Controller class 'MyController1' and that a link in my book calls MyController1(). When I click on this link in the book, the window of MyController1 appears inside the book itself. But in MyController1 I have a button that calls MyController2(). If i press this button, a new window appears on the screen, for MyController2. It is possible to open MyController2 inside the book window itself, as for the link in the book for MyController1?
 
 
Mauro
 
#989
Re:Display a controller inside a book window 2 Years, 12 Months ago
.Window should be BookControl, and it has a Goto method, so you should be able to do something like:

.Window.Goto("suneido://mybook/mypage")

But I have not tried it...
 
 
andrew
 
#991
Re:Display a controller inside a book window 2 Years, 12 Months ago
Mmmh... I have tried (in the code of a controller) but Suneido doesn't find 'Goto' method of '.Window'... I think that .Window is not a BookControl.
 
 
Mauro
 
#994
Re:Display a controller inside a book window 2 Years, 12 Months ago
Sorry, .Window will be a Window, the BookControl will be .Window.Ctrl

So it would be .Window.Ctrl.Goto

One way to figure this out is to put Inspect(this) into your button method and then find what you are looking for.
 
 
andrew
 
#997
Re:Display a controller inside a book window 2 Years, 12 Months ago
Hi Andrew, you are right, it was '.Window.Ctrl'. Thanks for the Inspect(this) suggestion. It is very useful.

The Goto now works but I have another problem: I need to pass some arguments to the controller I want to call... The Goto will call a link in the book that, in turn, will call my controller, but how can I pass some arguments to it? Do you think it is possible?
 
 
Mauro
 
#998
Re:Display a controller inside a book window 2 Years, 12 Months ago
I can not think of a direct way to pass arguments.

The obvious (but ugly) way is to put the arguments into the global Suneido object.

Or if the page has changed by the time the Goto returns (I am not sure about this) then you might be able to call a method on the new controller to pass the arguments.
 
 
andrew
 
#999
Re:Display a controller inside a book window 2 Years, 11 Months ago
Ok, thank you. The global Suneido object could be an option.
 
 
Mauro