Gwtext-based data binding to create applications (2) Event Interceptor

sponsored links
The event interceptor is Dataset object ties being bound by the event interceptor data binding
public interface DatasetInterceptor {
        public boolean doBeforeIntercept(Dataset dataset, String action, Object[] params);
        
        public void onIntercept(Dataset dataset, String action, Object[] params);
        
        public void doAfterIntercept(Dataset dataset, String action, Object[] params, int resultCode);
}


A simple data binding TextField, when the Dataset occurs ACTION_MOVE (the current log line change) event to dynamically modify the binding field contents, as follows:
public class DatasetText extends TextField implements DatasetFormField {
        private Dataset dataset;
        private DatasetField field;
        
        private DatasetInterceptor interceptor;
        
        public DatasetText(Dataset dataset, DatasetField field) {
                this.dataset = dataset;
                this.field = field;
                this.init();
                this.bind();
        }
        
        public DatasetText(DatasetField field) {
                this(null, field);
        }
        
        private void init() {
                setFieldLabel(field.getTitle());
                setName(field.getName());
                setWidth(field.getEditWidth());
                if(dataset != null) {
                        
                        this.addListener(new TextFieldListenerAdapter(){

                                @Override
                                public void onBlur(Field field) {
                                        dataset.set(field.getName(), DatasetText.this.getText());
                                }

                                @Override
                                public void onFocus(Field field) {
                                        DatasetText.this.selectText();
                                }
                                
                        });
                }
        }

        @Override
        public void bind() {
                if(this.dataset == null) return;
                if(this.interceptor == null)
                        this.interceptor = new DatasetInterceptorFormAdapter(Constants.ACTION_MOVE){
                                @Override
                                public void doAction(Dataset dataset, Object params) {
                                        Record rec = dataset.getRecordAtCursor();
                                        if(rec != null)
                                                DatasetText.this.setValue(rec.getAsString(field.getName()));
                                }
                        };
                this.dataset.addInterceptor(this.interceptor);
                Record rec = dataset.getRecordAtCursor();
                if(rec != null)
                        this.setValue(rec.getAsString(field.getName()));
        }

        @Override
        public void unbind() {
                if(this.dataset == null) return;
                this.dataset.removeInterceptor(this.interceptor);
        }

        @Override
        public Dataset getDataset() {
                return this.dataset;
        }

        @Override
        public DatasetField getField() {
                return this.field;
        }
}
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Gwtext-based data binding to create applications (2) Event Interceptor

  • hibernate (jpa) composite primary key annotation statement Ways

    In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,

  • Hibernate Inteceptor

    The end of the project stage, the client suddenly put forward a very troublesome but normal demand, the system records all changes must be carried out. Formats such as: 2004.1.1 12:30 Ikuya wind orders Sales Order Date 2004.1.2-> 2004.1.3 The firs ...

  • jboss ejb3 Message Driven Bean

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri

  • Application of spring struts2.0 hibernate HQL

    Therefore, in the development of statistical inquiry system, as far as possible through the use of select statement to write the required query property way back relational data, and avoid using the first query return persistent object (in this way are in

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Great collection of java interview topics

    1, object-oriented features of what has 1. Abstract: Abstract is that it has overlooked a subject has nothing to do with the current goal of those aspects in order to more fully with the current objectives of the attention-related aspects. Abstract does n

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries