-1

Selectcomposer giving problem ! Please help me

asked 2013-02-06 02:55:40 +0800

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

Hi I followed this post. Based on that i have created a small example.

The problem here is if extends to Selectcomposer, the event is not triggered from the child window to the parent window(Event name is OnSaved)

But if i change to extends GenericForwardComposer, everything working fine. So where is the problem ?

Here is the code

Now if you run, the event onSaved in the ParentWindowController will not trigger.

Now we will change the ParentWindowController such as extends GenericForwardComposer as follows

package org.com.demo;

import java.util.HashMap;

import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.SuspendNotAllowedException; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventQueue; import org.zkoss.zk.ui.event.EventQueues; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zk.ui.select.annotation.Listen; import org.zkoss.zk.ui.select.annotation.Wire; import org.zkoss.zk.ui.util.GenericForwardComposer; import org.zkoss.zul.Messagebox; import org.zkoss.zul.Textbox; import org.zkoss.zul.Window;

@SuppressWarnings("serial") public class ParentWindowController extends GenericForwardComposer {

private Window parentWindow;
Textbox firstName;
Textbox lastName;

@SuppressWarnings({ "rawtypes", "unchecked" })
public void doAfterCompose(Window comp) throws Exception {
    super.doAfterCompose(comp); // wire variables and event listners

}

public void onClick$showWindow() {
    final HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("firstName", firstName.getValue());
    map.put("lastName", lastName.getValue());
    map.put("parentWindow", parentWindow);
    Executions.createComponents(
            "ChildWindow.zul", null, map);

}

/**
 * This method is actualy an event handler triggered only from the Child
 * window dialog and it is responsible to reflect the data changes
 * 
 */
public void onSaved(Event event) {
    Messagebox.show("OnSaved");
}

}

Now you can see that messagebox box onsaved.

Why it is not working with selectcomposer ?

Please help me

delete flag offensive retag edit

Comments

Please help me.

Senthilchettyin ( 2013-02-06 10:10:12 +0800 )edit

Any help please on this

Senthilchettyin ( 2013-02-06 11:21:44 +0800 )edit

So you will want to send data back to parent viewmodel from child viewmodel?

sjoshi ( 2013-02-06 11:41:47 +0800 )edit

Yes that's right answer

Senthilchettyin ( 2013-02-06 13:27:16 +0800 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2013-02-06 16:28:41 +0800

ivancace gravatar image ivancace
3

I do that from SelectorComposer.

First show child window

Window win2 = (Window) Executions.createComponents("tablasbasicas/usuariosedit.zul", winUsu, arg);
win2.addEventListener("onAceptar", new EventListener<Event>() {
    @Override
    public void onEvent(Event event) throws Exception {
        SeguUsuariosCTL.this.cargarListado(event.getData());
    }
});
win2.doModal();

When i close childwindow, in its selectorcomposer:

Event closeEvent = new Event("onAceptar", this.getSelf(), datos);
Events.sendEvent(closeEvent);
link publish delete flag offensive edit
-1

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

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

Sorry to re open this question.

Now the event is firing, but i am trying back to update the UI as shown here.

@Listen("onSaved = #parentWindow")
public void onSaved(Event event) {
    Messagebox.show("OnSaved" + event.getData());
    final HashMap<String, Object> map = (HashMap<String, Object>) event.getData();
    final Execution execution = Executions.getCurrent();
    Messagebox.show( " " +(String) map.get("firstName"));
    setFirstName((String) map.get("firstName"));
    setLastName((String) map.get("lastName"));


}

But it is updating the zul file ?

link publish delete flag offensive edit

Comments

final HashMap<String, Object> map = (HashMap<String, Object>) event.getData(); ??

terrytornado ( 2013-02-06 21:42:59 +0800 )edit
0

answered 2013-02-06 12:33:41 +0800

yaminglin1977 gravatar image yaminglin1977
36 2

updated 2013-02-06 12:35:09 +0800

selectcomposer is ok

in ParentWindowController.java add the following anotation to onSaved method:

@Listen("onSaved = #parentWindow")

so you should see the messagebox

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-02-06 02:55:40 +0800

Seen: 43 times

Last updated: Feb 06 '13

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