0

How to post a user event after page loaded

asked 2011-12-14 14:34:02 +0800

54patman gravatar image 54patman
13 3

There is the issue I have. I have a login page that handles authentication, this works, then it forwards to my main page which displays the page and this works. The problem I have is that under certain circumstances I need to ask the user a question and when I show the dialog I get “doModal must be called in an event listener”.
Here is a sample of the code:

public class MainWindowController extends AbstractZKController {
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
Messagebox.show("My question");//will cause the error
}


I need a way to post an event automatically after my main page loads in order to have the event listeners fired and my dialog opened to ask the user a question.

Thanks

delete flag offensive retag edit

1 Reply

Sort by » oldest newest

answered 2011-12-28 14:18:40 +0800

dastultz gravatar image dastultz
797 9

You could use a Timer:

Timer timer = new Timer(0);
timer.setRepeats(false);
timer.setPage(page);
timer.addEventListener("onTimer", new EventListener() {
	public void onEvent(Event event) throws Exception {
		// ask question
	}
});

/Daryl

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-12-14 14:34:02 +0800

Seen: 204 times

Last updated: Dec 28 '11

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