1. #1
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    2
    gslender is on a distinguished road

      0  

    Default [FIXED] B5 - multifield validator bugs

    [FIXED] B5 - multifield validator bugs


    Few things wrong with multifield custom validator...

    1) Implementation is messy and no real value can be obtained from validate() method (refactoring or passing of some value should be done to make sense of the generics used)

    2) Even when working, no field value changes are correcting the isvalid status for the field - seems some notification for value change needs to fire a isvalid check to remove valid cross circle flag...

    code below can be used to show problems...

    Code:
    package com.mycompany.gxt.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;
    
    import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
    import com.extjs.gxt.ui.client.event.ComponentEvent;
    import com.extjs.gxt.ui.client.event.SelectionListener;
    import com.extjs.gxt.ui.client.widget.ContentPanel;
    import com.extjs.gxt.ui.client.widget.Info;
    import com.extjs.gxt.ui.client.widget.LayoutContainer;
    import com.extjs.gxt.ui.client.widget.Viewport;
    import com.extjs.gxt.ui.client.widget.button.Button;
    import com.extjs.gxt.ui.client.widget.form.CheckBox;
    import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
    import com.extjs.gxt.ui.client.widget.form.Field;
    import com.extjs.gxt.ui.client.widget.form.FormPanel;
    import com.extjs.gxt.ui.client.widget.form.TextField;
    import com.extjs.gxt.ui.client.widget.form.Validator;
    import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
    import com.extjs.gxt.ui.client.widget.layout.CenterLayout;
    
    public class MultiFieldValidatorTest implements EntryPoint {
    
    	public void onModuleLoad() {
    
    		ContentPanel cp = new ContentPanel();
    		cp.setHeading("Test");
    		cp.setSize(600, 400);
    
    		LoginContainer lc = new LoginContainer();
    		cp.add(lc);
    
    		final Viewport vp = new Viewport();
    		vp.add(cp);
    		vp.layout();
    
    		RootPanel.get().add(vp);
    	}
    
    	public class LoginContainer extends LayoutContainer {
    		public LoginContainer() {
    			super();
    			setLayout(new CenterLayout());
    
    			final FormPanel panel = new FormPanel();
    			panel.setHeading("Validator test");
    			panel.setFrame(true);
    			panel.setFieldWidth(100);
    			panel.setLabelWidth(80);
    			panel.setLabelAlign(LabelAlign.RIGHT);
    			panel.setButtonAlign(HorizontalAlignment.RIGHT);
    			panel.setWidth(250);
    
    			final TextField<String> userTxtFld = new TextField<String>();
    			userTxtFld.setFieldLabel("Username");
    			userTxtFld.setEmptyText("Username");
    			userTxtFld.setAllowBlank(false);
    			userTxtFld.setSelectOnFocus(true);
    			panel.add(userTxtFld);
    
    			final CheckBoxGroup accepttermsChkBoxGrp = new CheckBoxGroup();
    			accepttermsChkBoxGrp.setFieldLabel("Agreement");
    			accepttermsChkBoxGrp.setValidator(new Validator<Boolean, Field<Boolean>>() {
    				public String validate(Field<Boolean> field, String value) {
    					if (new Boolean(accepttermsChkBoxGrp.get(0).getRawValue())) return null;
    					return "You must agree ";
    				}
    			});
    			CheckBox accepttermsChkBox = new CheckBox();
    			accepttermsChkBox.setBoxLabel("I accept");
    			accepttermsChkBoxGrp.add(accepttermsChkBox);
    			panel.add(accepttermsChkBoxGrp);
    
    			final Button isvalidBtn = new Button("Check");
    			panel.addButton(isvalidBtn);
    
    			SelectionListener<ComponentEvent> listener = new SelectionListener<ComponentEvent>() {
    				public void componentSelected(ComponentEvent be) {
    					if (panel.isValid()) Info.display("isValid", "is true??");
    				}
    			};
    			isvalidBtn.addSelectionListener(listener);
    
    			add(panel);
    
    		}
    	}
    }

  2. #2
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    2
    gslender is on a distinguished road

      0  

    Default


    bump

  3. #3
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,241
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    1) Implementation is messy and no real value can be obtained from validate() method (refactoring or passing of some value should be done to make sense of the generics used)
    The multi field itself is passed to the validate method.


    2) Even when working, no field value changes are correcting the isvalid status for the field - seems some notification for value change needs to fire a isvalid check to remove valid cross circle flag...
    This is fixed.

  4. #4
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    2
    gslender is on a distinguished road

      0  

    Default


    Thanks Darrell

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar