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
    Mar 2009
    Posts
    4
    Vote Rating
    0
    Pandakopanda is on a distinguished road

      0  

    Default Question about form binding and validating

    Question about form binding and validating


    Hi, I've got two questions:

    1. Is it possible to run an event after a model has been bound to the form? I want to do a selectAll() on the first textfield in the form; this will need to occur after the form has been bound to the model so the form contains the text to be selected. The binding happens asynchronously (using DeferredCommand) so I can't just place selectAll call after the bind call in the code.

    2. Is it possible to (temporarily) disable validation on a form, so the form does not immediately validate after binding? To let the user enter a new employee (instead of an existing one), I bind the form to an BeanModel with an empty employee bean. But then the form immediately validates and most of the fields are invalid (because they are empty). I want the validation to happen after the user clicks the "save" button for the first time.

    Thanks,
    Jaap.

  2. #2
    Sencha User
    Join Date
    Oct 2008
    Posts
    2
    Vote Rating
    0
    Peter Brantschen is on a distinguished road

      0  

    Default


    I had the same problem with the validation of an empty model.

    I just cleared the invalid-state of the fields after the binding. But you have to do it in a DeferredCommand, because the setting of the validation-message is also done in such a command.

    Code:
    binding.bind(model);

    DeferredCommand.addCommand(new Command() {
    field.clearInvalid();
    });

  3. #3
    Ext User
    Join Date
    Jun 2008
    Posts
    365
    Vote Rating
    0
    sdc is on a distinguished road

      0  

    Default


    I also had some problems with deferred binding. In next release, Ext team will fire an event when bind is over : http://extjs.com/forum/showthread.ph...746#post293746

  4. #4
    Sencha User
    Join Date
    Oct 2008
    Posts
    2
    Vote Rating
    0
    Peter Brantschen is on a distinguished road

      0  

    Default


    We 'improved' our solution for the unsetting of the error-messages.

    We extended the FieldMapping by overwriting the bind()-Method. After the super-call to bind(), we can easily get the field and invalid all the errors.

    public void bind(ModelData model) {
    super.bind(model);
    getField().clearInvalid();
    }

    So, you don't have to be aware on doing everything in DeferredCommands. It will just be done in the same command like the binding.

  5. #5
    Ext User
    Join Date
    Jun 2008
    Posts
    365
    Vote Rating
    0
    sdc is on a distinguished road

      0  

    Default


    I've overriden FormBinding and add an immediateBind method, but I would not recommend this solution because each time you upgrade Ext GWT, you'll have to check consistency.

    Code:
        protected static class InternalFormBinding extends FormBinding {
            public InternalFormBinding(final FormPanel panel, final boolean autoBind) {
                super(panel, autoBind);
            }
    
            /**
             * Should be the same than {@link FormBinding#bind(ModelData)} but do not use a DeferredCommand
             */
            public void immediateBind(final ModelData model) {
                if (this.model != null) {
                    unbind();
                }
                this.model = model;
                for (FieldBinding binding : bindings.values()) {
                    binding.bind(model);
                }
                for (FieldBinding b : getBindings()) {
                    b.setStore(store);
                }
            }
       }

  6. #6
    Ext User
    Join Date
    Mar 2009
    Posts
    4
    Vote Rating
    0
    Pandakopanda is on a distinguished road

      0  

    Default


    Thanks for the replies. For now, I've overriden the FormBinding class. I realize the disadvantages of that approach, but it was the easiest way of both clearing the invalid status and getting the first text field to have focus after the binding.

    Code:
    public class InternalFormBinding extends FormBinding {
        public InternalFormBinding(FormPanel panel) {
            super(panel);
        }
    
        public InternalFormBinding(FormPanel panel, boolean autoBind) {
            super(panel, autoBind);
        }
    
        @Override
        public void bind(final ModelData modelData) {
            DeferredCommand.addCommand(new Command() {
                @SuppressWarnings("unchecked")
                public void execute() {
                    if (model != null) {
                        unbind();
                    }
                    model = modelData;
                    for (FieldBinding binding : bindings.values()) {
                        binding.bind(modelData);
                        binding.getField().clearInvalid();
                    }
                    
                    for (Field field : panel.getFields()) {
                        if (field instanceof TextField) { 
                            field.focus();
                            ((TextField) field).selectAll();
                            break;
                        }
                    }
                    
                }
            });
    
            for (FieldBinding b : getBindings()) {
                b.setStore(store);
            }
        }
    }

Thread Participants: 2