Zk Textbox constraint fire only once

asked 2014-10-10 14:46:16 +0800

javiut gravatar image javiut flag of Venezuela, Bolivarian Republic of
90 1 5

updated 2014-10-10 14:46:38 +0800

i have a simple textbox like this in a window which needs to be constrained i got the problem that when the validator getValue() is called the first time the constraint is fired correctly the problem arises when i have another combobox whichs tells me whether or not i should validate the textbox if there is some selection on the combobox index!=-1 it will validate this is done on myConstraint implementation the problem is the textbox value is not change!!! and in the second time the getValue on the textbox is called not constraint is fired... it works if the second time i modify something on the textbox...... how can i do to the second getValue fires the constraint even is not change was made on it..

<combobox width="120px"/>
<textbox width="120px" constraint="${myConstraint}"/>

any help is hugely appreciate..

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-10-11 12:56:36 +0800

Darksu gravatar image Darksu
1991 1 4

Hello javiut,

I created the following example which can be used in order to set and remove a constraint using a combobox, or buttons:

The zul file:

<?page title="constraint test" contentType="text/html;charset=UTF-8"?>
  <window border="normal" title="constraint test" apply="pkg$.TestConstraint">

    <textbox id="testTxb"/>

    <combobox id="constraintCmbx" width="120px">
        <comboitem value="1" label="Set Constraint"/>
        <comboitem value="2" label="Remove Constraint"/>

    <button id="btnAdd" label="Add constraint"/>        
    <button id="btnRemove" label="Remove constraint" />

And the java controller:

package pkg$;

import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zk.ui.ext.*;
import org.zkoss.zk.au.*;
import org.zkoss.zk.au.out.*;
import org.zkoss.zul.*;
import org.zkoss.zk.ui.select.*;
import org.zkoss.zk.ui.select.annotation.*;
import java.util.*;

public class TestConstraint extends GenericForwardComposer<Component> {

  private Textbox testTxb;

  private Button btnAdd;

  private Button btnRemove;

  private Combobox constraintCmbx;

  public void doAfterCompose(Component comp) throws Exception {

  public void onClick$btnAdd() {

      testTxb.setConstraint("no empty");

  public void onClick$btnRemove() {


  public void onChange$constraintCmbx(Event event) {
      System.out.println("Changed to " +constraintCmbx.getValue());

      if (constraintCmbx.getValue().equals("Set Constraint")) {
          testTxb.setConstraint("no empty");
      } else {



Best Regards,


link publish delete flag offensive edit


hello Darksu i need that the texbox constraint fires in even when the textbox value is not change

javiut ( 2014-10-13 13:00:43 +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

1 follower



Asked: 2014-10-10 14:46:16 +0800

Seen: 27 times

Last updated: Oct 11 '14

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