Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Ext User
    Join Date
    Oct 2008
    Location
    Warsaw(PL)/Cottbus(GER)
    Posts
    215
    Vote Rating
    0
    EagleEye666666 is on a distinguished road

      0  

    Default CustomValidator with RPC

    CustomValidator with RPC


    Hej Guys,

    I need some help/thought/ideas.

    I have my user registration form with necessary account data. My problem is to implement some custom validation of the username field (it is a unique attribute), so i need to check if this username is already uses or not. To create a custom validator class which is implementing the validate() method of the Validator interface. I know that i cant add there any return inside the RPC call for the validate method, as well i can not also create just a variable, because it has to be final. Any idea how to implement this?

    Code:
    public class UsernameValidator implements Validator<String, Field<String>> {
    	
    	public String validate(Field<String> field, String value) {
    		UserServiceRemoteAsync userService = Registry.get("userService");
    		userService.isUsernameValid(new AsyncCallback<Boolean>(){
    			public void onSuccess(Boolean arg0) {
    				
    			}
    		});
    		return null;
    	}
    }
    Note: the onFailure is not needed at all, at least not for the real logic... so i left it out

    I know thats why it is asynchronous. One solution would be to not validate the field and later on submit() call just popup a Box that this username is used and avoid sending the RPC call to save the object. But it would be really nice to directly (or some seconds because RPC is asynchronous) see after typing and filling the field, (maybe using the setValidationDelay() of the TextField??) some validation error.

    Iam running out of ideas. Maybe iam just blind.

    kind regards

  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


    just set the field.forceInvalid(java.lang.String msg) to whatever in the onSuccess return

  3. #3
    Ext User
    Join Date
    Oct 2008
    Location
    Warsaw(PL)/Cottbus(GER)
    Posts
    215
    Vote Rating
    0
    EagleEye666666 is on a distinguished road

      0  

    Default


    Quote Originally Posted by gslender View Post
    just set the field.forceInvalid(java.lang.String msg) to whatever in the onSuccess return
    damn thanks, i thought about it like this as well, BUT i havent seen this method thanks for pointing it out.

    The RPC works like a charm. I just have next problem. When iam setting a valid username everything works fine RPC call etc. when changing the field value to another valid username the new RPC call is invoked.

    The problem have been that this method disable the invoking of any validation. I do not get the sense here. It is just more to implement to get it working.

    Here my code if somebody will face same problem:

    Code:
    public class UsernameValidator implements Validator<String, Field<String>> {
    	public String validate(final Field<String> field, String value) {
    		UserServiceRemoteAsync userService = Registry.get("userService");
    		userService.isUsernameValid(value, new AsyncCallback<Boolean>(){
    			public void onSuccess(Boolean result) {
    				if(!result)
    					field.forceInvalid("Username already exists!");
    			}
    			public void onFailure(Throwable arg0) {
    				GWT.log(arg0.getMessage(),null);
    			}
    		});
    		return null;
    	}
    }
    Because of that after one time calling the forcInvalid(). You have to clear the validation manually.
    For this you need a Listener on the Change Event.

    Code:
    login.setFieldLabel(Main.constants.label_username());
    login.setName("login");
    login.setAllowBlank(false);
    login.setTabIndex(1);
    login.setValidator(new UsernameValidator());
    login.addListener(Events.Change, new Listener<FieldEvent>(){
    	public void handleEvent(FieldEvent be) {
    		if(!be.field.isValid()){
    			be.field.clearInvalid();
    			be.field.validate();
    		}
    	}
    });
    Can somebody explain me why the validation is turned off??? I would like to discuss about that.

    It works so far ... just some form bug i guess when one time bad name, than a good one ... than a bad... there is appearing some scrollbar

    I dont know if it is a field/form bug.

    I hate that u are solving some problem and next appears

  4. #4
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

    Default


    same problem... rssss I will test you code example.. look http://www.extjs.com/forum/showthread.php?t=57767

Thread Participants: 2