-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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..
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="btnAdd" label="Add constraint"/>
<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() {
System.out.println("Add");
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
Asked: 2014-10-10 14:46:16 +0800
Seen: 27 times
Last updated: Oct 11 '14
unwanted logging of custom WrongValueException
How to Disable Mandatory Constraint for email textbox
wrong valueException come in front of modal popup [closed]
Add dollar Sign ($) to textbox constraint.
How to restrict button click when textbox input violates the constraint
Problem showing textbox into tabbox tab
Java Script error zk.wpd in Explorer
textbox constraint="no empty", how to cancel ? [closed]