0

Executions.SendRedirect in the @Init [closed]

asked 2014-07-03 10:41:40 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

Hi all,

I I have a zul where I must have a valid query param at that page. For the moment the code is like(simplified for readability) this :

@Init
public void init(@ContextParam(ContextType.PAGE) Page page, @QueryParam("catalog") String catalog) {
    if (null == catalog) {
        redirectToHomePage();
    }
    page.setTitle(catalog);
    try {
        checkValidCatalog(catalog);
    } catch (CatalogNotValidException e) {
        redirectToHomePage();
    }
}

private void redirectToHomePage () {
    Executions.sendRedirect("index.zul");
}

The problem is that the sendRedirect is never called.
I did also try :

  • Executions.getCurrent().sendRedirect();
  • change the index.zul to /index.zul to ./index.zul

I'm 100% sure that the code is triggered buut the method keep on going and I get a severe error on the page.

For the ones who want more info of the error, I set a viewmodel dynamicly and get this error :

org.zkoss.zk.ui.UiException: view model of 'vm' is null at.

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by chillworld
close date 2015-03-26 16:47:38

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-07-03 11:10:21 +0800

vincentjian gravatar image vincentjian
2245 6

Hi, I will suggest using initiator or ExecutionInit to do the validation before init the view model.

link publish delete flag offensive edit

Comments

thx vincent, that helped me a lot.

chillworld ( 2014-07-04 08:07:24 +0800 )edit
0

answered 2014-07-04 02:16:38 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

when you using initiator or ExecutionInit to do the validation, you can use Executions.forward(String)

link publish delete flag offensive edit

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-07-03 10:41:40 +0800

Seen: 53 times

Last updated: Jul 04 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More