0

Not an event name problem

asked 2010-12-01 02:08:13 +0800

Meko gravatar image Meko
24

Hi. I am new on Zk and I stuck while using checkbox with onChek method. I have one .zul file as View and EventController.java class for controller class. I want to call method in EventController when I check chekbox but It gaves me Not an event name error. Here my .zul and java fıle

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>

<window id="win" title="To do list" width="1000px"  border="normal" apply="com.ercan.todolist.EventController">
	<listbox id="box" multiple="true"    rows="5" model="@{win$composer.AllProducts, load-after='add.onClick, delete.onClick, update.onClick , calculate.onClick'}" 
		selectedItem="@{win$composer.current}">
		<listhead>
			<listheader label="Product_Name" />
			<listheader label="Category" width="50px" />
			<listheader label="Quant" width="50px" />
			<listheader label="Date" width="90px" />
		</listhead>		
		<listitem self="@{each='event'}" value="@{event}">			
			<listcell label="@{event.name}" />
			<listcell label="@{event.cat}" />
			<listcell label="@{event.quant}" />
			<listcell label="@{event.date}" />
			
			

		</listitem>
	
	</listbox>
	
	<checkbox  id="a" label="deneme" forward="onCheck=win.doCheck"/>
	
		
	<groupbox>
		<caption label="Event" />
		Name: <textbox id="name" cols="25" value="@{win$composer.current.name}" />
		Category: <textbox id="cat" cols="25" value="@{win$composer.current.cat}" />
		Quant: <intbox id="quant" cols="1" value="@{win$composer.current.quant}" />
		Date: <datebox id="date" cols="8" value="@{win$composer.current.date}" />
		
		<button id="add" label="Add" width="36px" height="24px"/>
		<button id="update" label="Update" width="46px" height="24px"/>
		<button id="delete" label="Delete" width="46px" height="24px"/>
		<button id="calculate" label="Calculate" width="46px" height="24px"/>
	</groupbox>	
</window>

And EventController.java fıle

package com.ercan.todolist;

import java.util.List;
import java.util.UUID;

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.ForwardEvent;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.api.Checkbox;

public class EventController extends GenericForwardComposer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Product current = new Product();
	ProductEvent prodevt = new ProductEvent();
	Listbox box;

	public Product getCurrent() {
		return current;
	}

	public void setCurrent(Product current) {
		this.current = current;
	}

	public List getAllProducts() {

		return prodevt.showAll();

	}

	public void onClick$add() {
		System.out.println("called ADD");
		Product newProd = new Product(current.getName(), current.getCat(),
				current.getQuant(), current.getDate());
		prodevt.insert(newProd);
	}

	public void onClick$update() {
		System.out.println("called Update");
		if (box.getSelectedItem() != null) {

			prodevt.update((Product) box.getSelectedItem().getValue());

		}

	}

	public void onClick$delete() {

		if (box.getSelectedItem() != null) {

			prodevt.delete((Product) box.getSelectedItem().getValue());

		}

	}

	public void onClick$calculate() {

		if (box.getSelectedItem() != null) {
			System.out.println("calculating");
			prodevt.calculate(box.getItems());
			System.out.println("sendedt to calculate functýon ");

		}

	}

	public void doCheck(ForwardEvent event) {

		Event orig = event.getOrigin();
		System.out.println("here " + orig);

	}

}

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2010-12-08 12:37:13 +0800

twiegand gravatar image twiegand
1807 3

Meko,

Try doing your checkbox like this:

<zk>
	<zscript>
		import org.zkoss.zk.ui.util.GenericForwardComposer;
			
		public class EventController extends GenericForwardComposer {
			public void onCheckBox(Event event) {
				Object myObj = event.getOrigin().getTarget().isChecked();
				alert("Checkbox value = " + myObj);
			}
		}	
	</zscript>
	
	<window id="win" title="To do list" width="1000px"  border="normal" apply="EventController">
		
		<checkbox label="deneme" forward="onCheck=onCheckBox()" />
		
	</window>
</zk>

Maybe that will work better for you.

Todd

link publish delete flag offensive edit

answered 2011-01-26 05:14:34 +0800

SparkySpider gravatar image SparkySpider
444 1 3

Just make sure you call the method that you're calling onWhatever (starting with an on)...

link publish delete flag offensive edit

answered 2012-04-24 09:56:13 +0800

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

Hi Sparkeyspider

I had similar problem. Can you please look my new post

http://www.zkoss.org/forum/listComment/19336-Help-on-ZK-MVC-Made-Easy

So the event name should be always start on and then we have any words ?

Senthil M

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: 2010-12-01 02:08:13 +0800

Seen: 829 times

Last updated: Apr 24 '12

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