0

noob question: button click is not triggering

asked 2012-07-26 08:11:33 +0800

flflfl gravatar image flflfl
51

Hey,

I'm new to zk and I've my first problem. I've defined a button in index.zul:

<window apply="test.events.Test" id="index" sclass="embedded" title="test">
	<button
		id="TestBtn" label="Test" dir="reverse" width="200px" />
	<button
</window>

And in Test.java

public void onClick$TestBtn() {
	System.out.println("Hello World");
}

When I click on my Button, the function onClick$TestBtn is never called. Whats wrong here?

Thanks flo :)

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2012-07-26 08:42:47 +0800

glados gravatar image glados
24

Hi

Does your class Test.java extends from some Composer?, for example:


public class TestComposer extends GenericForwardComposer{

	public void onClick$btn(Event e) throws InterruptedException{
		Messagebox.show("Hello World");
	}
}


link publish delete flag offensive edit

answered 2012-07-26 08:44:09 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

what is your test.events.Test class extending? GenericForwardComposer right? if so - it should work as my copy&paste from your snippet did :)

link publish delete flag offensive edit

answered 2012-07-26 09:01:14 +0800

flflfl gravatar image flflfl
51

yes it extends GenericForwardComposer. i changed

public void onClick$TestBtn() {
to
public void onClick$btn(Event e) throws InterruptedException{
but the button is still not triggering :\

Here is the full source:

package test.events;


import org.zkoss.zhtml.Messagebox;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;

public class Test extends GenericForwardComposer {

	private static final long serialVersionUID = 1L;

	public final void doAfterCompose(Component comp) {
			System.out.println("Hello Test ");
	}

	public void onClick$TestBtn(Event e) throws InterruptedException{
		Messagebox.show("Hello World");
	}

}

<zk>
	<window apply="test.events.Test" id="index"
		sclass="embedded" title="Test">
		<button
			id="TestBtn" label="Test" dir="reverse" width="200px" />
	</window>
</zk>

link publish delete flag offensive edit

answered 2012-07-26 09:18:59 +0800

glados gravatar image glados
24

Hi,

You need to add into doAfterCompose method a call to parent method:

super.doAfterCompose(compo)

or just dont overwrite the method.



	public final void doAfterCompose(Component comp)  throws Exception {
          		super.doAfterCompose(comp);
			System.out.println("Hello Test ");
	}

link publish delete flag offensive edit

answered 2012-07-26 09:35:35 +0800

flflfl gravatar image flflfl
51

it works :) many thanks!

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: 2012-07-26 08:11:33 +0800

Seen: 88 times

Last updated: Jul 26 '12

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