# Zk Textbox constraint fire only once

javiut
90 1 5

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 retag edit ## 1 Answer Sort by » oldest newest most voted answered 2014-10-11 12:56:36 +0800 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"?> <zk> <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"/>
</combobox>

<button id="btnRemove" label="Remove constraint" />
</window>
</zk>

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> { @Wire private Textbox testTxb; @Wire private Button btnAdd; @Wire private Button btnRemove; @Wire private Combobox constraintCmbx; @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); } public void onClick$btnAdd() {

testTxb.setConstraint("no empty");
}

public void onClick$btnRemove() { System.out.println("Remove"); testTxb.setConstraint(""); } public void onChange$constraintCmbx(Event event) {
System.out.println("Changed to " +constraintCmbx.getValue());

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

}

}

Best Regards,

Darksu

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

( 2014-10-13 13:00:43 +0800 )edit
[hide preview]

## Stats

Seen: 27 times

Last updated: Oct 11 '14

Support Options
• Email Support
• Training
• Consulting
• Outsourcing