PDA

View Full Version : How to bind buttons to fields in FieldSet?



Blessed Geek
2 Apr 2012, 11:09 AM
My form has a few FieldSets.

Is the formbinding capable of binding fields in those FieldSets to a button?

Is the formbinding capable of binding fields of a certain FieldSet to a button?

Would like to know how. Thx.

Blessed Geek
10 Apr 2012, 8:28 AM
This is how I solved the deficiency. I am using gxt 2.2.5.


class FieldSetFriendlyFormPanel extends FormPanel
{
/**
* isValid is called by FormButtonBinding
* to dis/enable the fields in a form
* based on the validation of member fields
*/
@Override
public boolean isValid(boolean preventMark) {
boolean valid = true;
for (Field<?> f : getFields()) {
if (!f.isValid(preventMark)) {
valid = false;
}
}

for(Component c : getItems()) {
if (c instanceof FieldSet) {
validateFieldSet((FieldSet)c, preventMark, valid);
}
}

return valid;
}


protected boolean validateFieldSet(FieldSet fieldset, boolean preventMark, boolean valid) {
for(Component c : fieldset.getItems()) {
if (c instanceof Field) {
if (((Field)c).isValid(preventMark))
valid = false;
}
}

return valid;
}
}