0

MVVM : How to use Clients.showNotification and Executions.sendRedirect in same action ?

asked 2013-06-13 10:50:13 +0800

Mychal gravatar image Mychal
151 3

We would like to click on a button in order to save a form. This submit button has to execute an insert or update via JPA.

At the end, we would like to show a notification with the result of operation then launch a redirection.

How to manage a Client.showNotification then a Executions.sendRedirect ? How can we waiting the end of notification before sendRedirect ?

Thank you.

delete flag offensive retag edit

Comments

I do implement the same way. But after save, will show the notification at the top and immediately it will be back to listing screen. Putting messagebox for saving it is not acceptable because they have click the ok button.

Senthilchettyin ( 2013-06-13 11:40:13 +0800 )edit

Yeah, messagebox is not ok for the client. I try to put the sendredirect but the notify action doesn't work. I try with a Thread.sleep but all are frozen....

Mychal ( 2013-06-13 13:28:00 +0800 )edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2013-07-16 10:56:18 +0800

Mychal gravatar image Mychal
151 3

So here my solution.

  1. Add a specific binder into zul (binder="@init(queueName='redirectQueue', queueScope='session')")
  2. Launch a Client.showNotification
  3. Create a new thread
  4. Lookup EventQueue (EventQueues.lookup("redirectQueue", Executions.getCurrent().getSession(), true))
  5. Pass it to the thread
  6. In the thread, launch a Thread.sleep then a new GlobalCommand on the EventQueue (with url in params)
  7. In GlobalCommand, realize the Executions.getCurrent().sendRedirect with url passed in args
link publish delete flag offensive edit
0

answered 2013-06-13 16:04:51 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

But works for me. Here is the sample piece of code

try {
        CRUDService.Save(this.selectedRecord);
        Infrastructure.showSuccessmessage();
        goBack();

public static void showSuccessmessage() {
    Clients.showNotification(Consts.SUCCESS_MESSAGE,
            Clients.NOTIFICATION_TYPE_INFO, null, "top_center", 4100);
}
/* Start: Auto Close Notification message box

/* ----------------------------------------------------------------------------------------------------------------------- */

/* Start: Auto Close Notification message box /* ----------------------------------------------------------------------------------------------------------------------- */ .z-notification .z-notification-cl,.z-notification .z-notification-cnt { height: 30px; width: 250px; }

.z-notification-info .z-notification-cl { background-color: #ADD8E6; }

.z-notification .z-notification-cl { color: white; }

.z-notification .z-notification-cnt { background: none repeat scroll 0 center transparent; font-size: 14px; font-weight: normal; margin: 0 !important; overflow: hidden; }

.z-notification-info .z-notification-cl { background-color: #da5867; }

link publish delete flag offensive edit

Comments

goBack = sendRedirect ? Are you with Zk 6, in MVVM architecture ? So, you can see the notification during 4s before the redirection ?

Mychal ( 2013-06-14 10:33:03 +0800 )edit
0

answered 2013-06-14 11:07:02 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Yes i am using zk 6 with MVVM. But not with redirect, instead of that Executions.createComponents.

You can see example here. Follow the steps

  1. Click this Link

  2. In the Top Menu, Click MVVM

  3. Next click CRUD Form.

  4. You can see "MVVM CRUD Without DB Connection". In the action column, you can download the source code, or you can run or you can look the documentation.

link publish delete flag offensive edit

Comments

Ok. But our real pb is to redirect the page after notify :p

Mychal ( 2013-06-14 15:25:51 +0800 )edit
-1

answered 2013-06-17 14:30:30 +0800

ryg78 gravatar image ryg78
29 2

updated 2013-06-17 14:32:32 +0800

Have you ever tried Clients.showNotification() methods with parameter duration (in ms)?

void org.zkoss.zk.ui.util.Clients.showNotification(String msg, String type, Component ref, int x, int y, int duration)

void org.zkoss.zk.ui.util.Clients.showNotification(String msg, String type, Component ref, int x, int y, int duration, boolean closable)

void org.zkoss.zk.ui.util.Clients.showNotification(String msg, String type, Component ref, String position, int duration)

maybe that can help.

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2013-06-13 10:50:13 +0800

Seen: 235 times

Last updated: Jul 16 '13

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