Documentation for GXT Data Binding

GWT Designer allows you to quickly create the modules, composites, panels, remote services and other elements that comprise Google Web Tookit applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Documentation for GXT Data Binding

Postby robnauticus » Thu May 20, 2010 9:36 pm

Hello I am eager to test out and possibly implement the Data Binding feature of the Designer 7.5.

I am unable to find any specific docs on the subject. I took a look at the Swing version of data binding but the translation from Swing to GXT is not 100% clear to me.

Any help would be great!
Wonderful product,
Rob
robnauticus
 
Posts: 6
Joined: Thu Jul 23, 2009 5:21 am

Re: Documentation for GXT Data Binding

Postby Eric Clayberg » Fri May 21, 2010 6:44 am

We will be adding some docs for that soon.

In the mean time, you should refer to the GXT site for info about how to use their Data Binding API.

I have attached a GXT Data Binding example that you can start with. Note that the file does not include the GXT jars (to keep the file size smaller), so you will need to add those to the project yourself.
Attachments
GXT-Bindings-Example.zip
GXT Data Binding Example (does not include GXT jars)
(956.47 KiB) Downloaded 259 times
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Documentation for GXT Data Binding

Postby robnauticus » Fri May 21, 2010 12:27 pm

Thank you Eric! I will get cracking... :)

Maybe the impedance I am getting is from using BeanModel. I am wrapping my POJO's in a BeanModelMarker.
robnauticus
 
Posts: 6
Joined: Thu Jul 23, 2009 5:21 am

Re: Documentation for GXT Data Binding

Postby Eric Clayberg » Tue May 25, 2010 12:08 pm

We support BeanModel.

AFAIK, GXT bindings (Bindings, FormBinding, FieldBinding) only work with BeanModel.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Documentation for GXT Data Binding

Postby Eric Clayberg » Tue Jun 01, 2010 10:09 am

I have attached a more detailed GXT Data Binding example illustrating both basic bindings and grid bindings.

Note that the file does not include the GXT jars (to keep the file size smaller), so you will need to add those to the project yourself.
Attachments
GXT-Bindings-Example.zip
(545.96 KiB) Downloaded 263 times
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Documentation for GXT Data Binding

Postby NecroSado » Wed Dec 29, 2010 10:46 am

Eric Clayberg wrote:We support BeanModel.

AFAIK, GXT bindings (Bindings, FormBinding, FieldBinding) only work with BeanModel.


Hi,

binding seems to work with ModelData, which is the BeanModel interface.
It is possible to implement the interface on our home-made beans to link the overridens get() and set() method so they call our own accessors without storing datas in a map.

However, i don't find a way to use the Databinding screen to bind my data if i don't use BeanModel.
Is there a way to do so?
NecroSado
 
Posts: 4
Joined: Wed Dec 29, 2010 10:33 am

Re: Documentation for GXT Data Binding

Postby Eric Clayberg » Mon Jan 03, 2011 8:07 am

You would need to do this manually. We only plan to support BeanModel subclasses.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Documentation for GXT Data Binding

Postby NecroSado » Tue Jan 04, 2011 8:56 am

This is not really the java philosophy... you should always use the interface for loose coupling.
In the BeanModel javadoc, it says it's the default implementation of ModelData.
I never seen a tool only supporting the default implementation of a functionality.

Are you using reflexion/introspection to find out the BeanModel's property? Knowing that could help us to "mock" the BeanModel and wrap our POJO so their property finally appears.
NecroSado
 
Posts: 4
Joined: Wed Dec 29, 2010 10:33 am

Re: Documentation for GXT Data Binding

Postby Eric Clayberg » Tue Jan 04, 2011 10:57 am

We support ModelData only in "autoBind" mode. This requires that each field on a form must have a 'name' property corresponding to the bean property with same name. For custom field-to-property binding we can only support beans based on BaseModel. This is due to the fact that in the general case we can not get a property list for arbitrary ModelData (we are not creating bean instances). For a BaseModel we visit its compilation unit (if available) for collecting its property list. In BaseModel compilation units we are using various invocations of com.extjs.gxt.ui.client.data.BaseModel.set(String, <T>) to gather information about the existing bean properties (the existence of these invocations is guaranteed by BaseModel but not guaranteed by ModelData).

Once the core WindowBuilder engine is open sourced through Eclipse.org, we would expect the GXT vendor to take over support and development for any GXT-related extensions to GWT Designer (as would be the case for any 3rd party library vendor). If they wish to enhance the GXT data binding support to handle ModelData, we would be happy to point them in the right direction.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Documentation for GXT Data Binding

Postby NecroSado » Thu Jan 06, 2011 8:20 am

Thanks for the explanation.
With these infos, i've finally been able to bind our home-made POJO with the binding screen, displaying our properties.
For future usage, i'll soon post an example of well formed implementation of ModelData that shows the properties in the screen.
NecroSado
 
Posts: 4
Joined: Wed Dec 29, 2010 10:33 am

Re: Documentation for GXT Data Binding

Postby Eric Clayberg » Fri Jan 07, 2011 1:13 pm

Sounds good.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Documentation for GXT Data Binding

Postby NecroSado » Tue Jan 11, 2011 7:55 pm

Here's an example of a ModelData working with the binding screen.
It's based on modeldata projet's (http://code.google.com/p/unitt/wiki/modeldata) output, but using the for loop in getProperties() makes the binding screen not working.


Code: Select all
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.extjs.gxt.ui.client.data.ModelData;

public class POJO implements ModelData{

   /**
    * POJO Attributes
    */
   private String strProp;
   private Integer intProp;
   
   /**
    * POJO Accessors
    * @param strProp
    */
   
   public void setStrProp(String strProp) {
      this.strProp = strProp;
   }

   public String getStrProp() {
      return strProp;
   }

   public void setIntProp(Integer intProp) {
      this.intProp = intProp;
   }

   public Integer getIntProp() {
      return intProp;
   }

   
   /**
    * ModelData Implementation
    */
   
   @Override
   public <X> X get(String property) {
      
      if("strProp".equals(property)){
         return (X)getStrProp();
      }else if("intProp".equals(property)){
         return (X)getIntProp();
      }
      
      return null;
   }

   @Override
   public Map<String, Object> getProperties() {
      Map<String, Object> toReturn = new HashMap<String, Object>();
      
      //Working
      toReturn.put("strProp", get("strProp"));
      toReturn.put("intProp", get("intProp"));
      
      /*
      Not working
      
      for (String property : getPropertyNames())
        {
         toReturn.put(property, get(property));
        }
        */
      return toReturn;
   }

   @Override
   public Collection<String> getPropertyNames() {
      Collection<String> toReturn = new ArrayList<String>();
      toReturn.add("strProp");
      toReturn.add("intProp");
      return toReturn;
   }

   @Override
   public <X> X remove(String property) {
      return set(property, null);
   }

   @Override
   public <X> X set(String property, X value) {
      X toReturn = get(property);
      
      if("strProp".equals(property)){
         setStrProp((String)value);
      }else if("intProp".equals(property)){
         setIntProp((Integer)value);
      }
      
      return toReturn;
   }

}
NecroSado
 
Posts: 4
Joined: Wed Dec 29, 2010 10:33 am

Re: Documentation for GXT Data Binding

Postby Eric Clayberg » Wed Jan 12, 2011 5:57 am

Thanks for the example.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to GWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest