2

Problem in zk validation

asked 2013-01-17 12:45:16 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

updated 2013-01-17 12:55:54 +0800

Hi all,
I'm using validation with zk constraint when click on save button it trigger but it's doing save operation with null value.

I want to do when it's trigger, the save operation must be stop.

<intbox id="priority"	value="@bind(vm.priority)" maxlength="3"  constraint="no empty" ></intbox>

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-01-17 13:14:03 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

updated 2013-01-17 13:24:10 +0800

Hi all,

Another issue in zk.
zk allowing % in Intbox. but it should not allow this character in intbox.

please find demo code here.

you enter some garbage data inside date box and see validation.
how can i detect this validation in my java code when oncCick on save button.

validation.zul

 
<zk>
	<window width="100%" height="100%"
		apply="org.zkoss.bind.BindComposer"
		viewModel="@id('vm') @init('com.test.Validation')">

		<toolbar id="listToolbarProcess" sclass="vista" height="20px"
			align="start">

			<toolbarbutton label="Save" onClick="@command('doSave')" ></toolbarbutton>

		</toolbar>

		<vlayout sclass="vertical-scroll" vflex="1">

			<intbox id="priority" value="@bind(vm.value)" maxlength="3"
				constraint="no empty" ></intbox>
				<datebox value="@bind(vm.date)"></datebox>
		</vlayout>

	</window>


</zk>

Validation.java

package com.test;

import java.sql.Timestamp;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.zk.ui.Component;

public class Validation {

	/**
	 * @author Himanshu
	 */
	Integer value;

	public Integer getValue() {
		return value;
	}

	public void setValue(Integer value) {
		this.value = value;
	}
Timestamp date;
	public Timestamp getDate() {
	return date;
}

public void setDate(Timestamp date) {
	this.date = date;
}

	@AfterCompose
	public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {

	}

	@Command
	public void doSave() {
		
		System.out.println(" value =" + value);
		System.out.println(" Date Value =" + date);
	}

}

link publish delete flag offensive edit

Comments

What version of ZK you used?

paowang ( 2013-11-18 02:11:09 +0800 )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

RSS

Stats

Asked: 2013-01-17 12:45:16 +0800

Seen: 59 times

Last updated: Jan 17 '13

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