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

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;
        }
}
分类:Java 时间:2010-03-29 人气:250
分享到:
blog comments powered by Disqus

相关文章

  • Java proxy mode (through public interface) 2010-06-16

    Java proxy mode (through public interface) Proxy pattern implementation of a common scheme is to define an interface or abstract class, and derive the target subclass (RealClass), and proxy subclass (ProxyClass). We have to operate in the target sub-

  • NVL (a, b) function if a = null, return b 2010-10-14

    NVL (a, b) function if a = null, return b

  • Project page type used in public 2010-03-29

    package jy.page.module; import org.hibernate.Query; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; public class PageManagerimple extends HibernateDaoSupport implements PageManager{ private PageModule pm = new PageModule(); pub

  • mysql.sqlserver.oracle pages, java unified interface page 2011-07-12

    Definition: pageStart start page, pageEnd end page, pageSize the page size oracle page: select * from (select mytable .*, rownum num from (the actual transfer of SQL) where rownum <= pageEnd) where num> = pageStart sqlServer Page: select * from (sel

  • The Enumeration interface, java 2010-10-17

    Enumeration Interface Enumeration interface itself is not a data structure. However, other data structure is very important. Enumeration interface defines a data structure obtained from the means of continuous data. For example, Enumeration defines a

  • Collections.newSetFromMap(Map E,Boolean map) 2013-12-07

    Collections提供了一种保证元素唯一性的Map实现,就是用一个Set来表示Map,它持有这个Map的引用,并且保持Map的顺序.并发和性能特征.这就是newSetFromMap方法: public static <E> Set<E> newSetFromMap(Map<E, Boolean> map) { return new SetFromMap<>(map); } 从Collections中可以看到,这里使用了一个内部类SetFromMap,它实

  • Bobo-Zoie the main interface, and inheritance 2010-11-29

    Bobo inheritance of the main package 1. BrowseService (Bobo): Inquiries, call the main browse, pass in BrowseRequest req, get BrowseResult. public interface BrowseService { BrowseResult browse(BrowseRequest req) throws BrowseException; void close() t

  • JNDI Naming and Directory Interface 2010-03-25

    JNDI is a Java Naming and Directory Interface (Java Naming and Directory Interface), is a Java platform, a standard extension provides a set of interfaces, classes and on the concept of namespaces. Like many other Java technologies, like, JDNI is a p

  • 2010.12.15 --- android listView display pictures 2010-12-16

    2010.12.15 --- android listView display pictures Requirements: display images inside the listView Idea: online see some examples listView generally inherited SimpleAdapter, SimpleAdapter but can not directly display images on the network so we only n

  • 2010.12.16 --- android listView display picture memory overflow 2010-12-16

    2010.12.16 --- android listView display picture memory overflow Wrote yesterday listView load, they would have reported a large number of images of memory exception In fact, wrote yesterday there are two problems: 1, memory overflow 2, loading images

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.411 (s). 13 q(s)