0

How to catch close event from of a modal child windows [closed]

asked 2010-05-03 03:59:17 +0800

apam gravatar image apam
24 1

Hi,
I'm trying to get back some return values from a modal windows opened
inside a main windows.
When, in the main windows, you press a button a new modal windows
is shown and you can choose some values
How can I get back these values to the main window then the modal
is closed ?
That is the suggested way to handle this situation ?
Thank you

Giuseppe

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by sjoshi
close date 2013-02-08 06:00:17

8 Replies

Sort by ยป oldest newest

answered 2010-06-11 18:45:19 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2013-02-04 09:28:21 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...
`<disable-event-thread>false</disable-event-thread>`

should suspend execution on calling doModal().

link publish delete flag offensive edit

answered 2010-05-03 05:06:46 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-05-03 05:14:26 +0800

Hi Giuseppe. For such a case we have written our InputConfirmBox

You can adapt it to your need. I.e. set the returnValue to object and Cast on the caller Side to your needed Type

call:

 
String str = InputConfirmBox.show(parentComponent, "This is a question that shows in the InputConfirmBox"));

InputConfirmBox.java

/**
 * This class creates a modal window as a dialog in which the user <br>
 * can input something. By onClosing this InputConfirmBox can return a value. <br>
 * In this useCase the returnValue is the same as the inputValue.<br>
 * 
 * @author bbruhns
 * @author sgerth
 */
public class InputConfirmBox extends Window {

	private static final long serialVersionUID = 8109634704496621100L;
	private static final Logger logger = Logger.getLogger(InputConfirmBox.class);

	private final String question;
	private final Textbox textbox;


	/**
	 * The Call method.
	 * 
	 * @param parent
	 *            The parent component
	 * @param anQuestion
	 *            The question that's to be confirmed.
	 * @return String from the input textbox.
	 */
	public static String show(Component parent, String anQuestion) {
		return new InputConfirmBox(parent, anQuestion).textbox.getText();
	}


	/**
	 * private constructor. So it can only be created with the static show()
	 * method
	 * 
	 * @param parent
	 * @param anQuestion
	 */
	private InputConfirmBox(Component parent, String anQuestion) {
		super();
		question = anQuestion;
		textbox = new Textbox();

		setParent(parent);

		createBox();
	}

	private void createBox() {

		setWidth("350px");
		setHeight("110px");
		setTitle(Labels.getLabel("message_Information"));
		setId("confBox");
		setVisible(true);
		setClosable(true);
		addEventListener("onOK", new OnCloseListener());

		Vbox vbox = new Vbox();
		vbox.setParent(this);

		Label label = new Label();
		label.setValue(question);
		label.setParent(vbox);

		Separator sp = new Separator();
		sp.setBar(true);
		sp.setParent(vbox);

		Hbox hbox = new Hbox();
		hbox.setParent(vbox);

		Separator sep = new Separator();
		sep.setParent(hbox);

		textbox.setType("password");
		textbox.setWidth("100px");
		textbox.setParent(hbox);

		try {
			doModal();
		} catch (SuspendNotAllowedException e) {
			logger.fatal("", e);
		} catch (InterruptedException e) {
			logger.fatal("", e);
		}
	}

	final class OnCloseListener implements EventListener {
		@Override
		public void onEvent(Event event) throws Exception {
			onClose();
		}
	}

}

best
Stephan

PS: all codes from the open Zksample2 project

link publish delete flag offensive edit

answered 2010-05-03 12:12:22 +0800

apam gravatar image apam
24 1

Hi Stephan

I'll study your code asap

At first look I didn't understand that
make possible to the caller class to wait
for the end of the popup/modal window

I'll study Zkexample2 project

thank a lot

link publish delete flag offensive edit

answered 2010-06-10 19:46:41 +0800

jvivas gravatar image jvivas
27

Hi,

I have a question. The above code of the class InputConfirmBox works under the libraries zk ver. 5.02?

I tried this code with the class InputConfirmBox with libraries zk 5.02 and I can not get it to work, but with the libraries of zk ver. 3.6 works well

do I have to add any aditional code, to make this class work with zk 5.05 libraries or I need to do anything else?

I hope you can help.

Thanks in advance.


Att. Julio Cesar Vivas Camargo

link publish delete flag offensive edit

answered 2010-06-11 03:00:01 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-06-11 03:01:04 +0800

Hi Julio,

add these lines to your zk.xml. because the default value have changed between 3.6.x and 5.x


zk.xm
l

     <system-config>
		<disable-event-thread>false</disable-event-thread>
     </system-config>

best
Stephan

link publish delete flag offensive edit

answered 2010-06-11 16:37:01 +0800

jvivas gravatar image jvivas
27

Thanks Stephan!!!!!

I tried the previous setting in an example and it works, but not in my project code. I'm using class ThreadLocalListener in my zk.xml file, could this interfere?.

I read the class documentation org.zkoss.zkplus.util.ThreadLocalListener and I do not know if I should do some extra configuration.

The version of the libraries is zk 5.02. I'm using de tag <aop:scoped-proxy /> to access spring beans.

is there any way to use modal windows in this context?

My zk.xml file is:

<zk>

    <system-config>
        <ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class>
	<disable-event-thread>false</disable-event-thread>
    </system-config>

    <listener>
        <description>ThreadLocal Synchronization Listener</description>
	<listener-class>org.zkoss.zkplus.util.ThreadLocalListener</listener-class>
    </listener>

    <preference>
        <name>ThreadLocal</name>
	 <value>
		org.springframework.web.context.request.RequestContextHolder=requestAttributesHolder,inheritableRequestAttributesHolder; 
	</value>
    </preference>
Source Code

</zk>



My aplicationContext.xml file is:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/aop 
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx 
           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <bean name="aqAlmacen" class="gnp.ae.presentacion.ventanaMarco.impl.AqAlmacenImpl"
     		init-method="init">
		<property name="smInfo2000" ref="smInfo2000"></property>
    </bean>

    <bean name="aqSistema" class="gnp.ae.presentacion.ventanaMarco.impl.AqSistemaImpl"
          	init-method="init" scope="session">
		<aop:scoped-proxy />
		<property name="aqAlmacen" ref="aqAlmacen" />
    </bean>

</beans>


I hope you can help.

Thanks in advance.

Att. Julio Cesar Vivas Camargo

link publish delete flag offensive edit

answered 2010-06-11 17:23:49 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Hmmm, i tested it yet with 5.0.2 without problems.
What is the false behaviour you mean?

We do it without the <aop:scoped-proxy /> since we let call the controllers with apply="${customerDialogCtrl}"

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context-3.0.xsd
		http://www.springframework.org/schema/aop
		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
		http://www.springframework.org/schema/tx
		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

  .  .  .

	<bean id="articleDialogCtrl" class="de.forsthaus.webui.article.ArticleDialogCtrl"
		parent="basisCtrl" scope="prototype">
		<property name="articleService" ref="articleService" />
	</bean>
   .  .  .


link publish delete flag offensive edit

answered 2010-06-11 18:05:23 +0800

jvivas gravatar image jvivas
27

Thanks for your reply Stephan!!!!!


The <disable-event-thread>false</disable-event-thread> behavior is that the modal window doesn't suspend execution and return inmediately on calling the doModal() method.


I apologize for any inconvenience caused.

Thanks in advance.

Att. Julio Cesar Vivas Camargo

link publish delete flag offensive edit

Question tools

Follow

RSS

Stats

Asked: 2010-05-03 03:59:17 +0800

Seen: 1,328 times

Last updated: Feb 04 '13

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