SmartGwt and RestDataSource

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

SmartGwt and RestDataSource

Postby lazinskip » Sun Oct 03, 2010 4:32 am

Hi, I have tried GwtDesigner with SmartGWt 2.3 and I have few questions.
How can I share one Restdatasource between 2 components (e.g. Grid and DynamicForm) ? There is no dataSource property. Common pattern for DataSource reusing is to create static reference for it.
Code: Select all

private static MyDataSource ds;
public static MyDataSource getInstance(){
  if (ds==null){
    ds= new MyDataSource();
  }
  return ds;
}

but GwtDesigner creates code another way
How to use Restdatasources whithout getting messages about property beeing changed after component creation (e.g. id for datasource)? I think one way is choosing lazy initialisation pattern for code generation but I am not sure of it
thanks for any help
lazinskip
 
Posts: 20
Joined: Fri Oct 01, 2010 10:23 pm

Re: SmartGwt and RestDataSource

Postby Eric Clayberg » Thu Oct 07, 2010 4:52 am

Give this a try using the latest GWT Designer build...

http://code.google.com/webtoolkit/tools ... -beta.html

DataSource is now supported as a non visual object.

The "dataSource" property is now available in DynamicForm, ListGrid and others.
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: SmartGwt and RestDataSource

Postby lazinskip » Thu Oct 07, 2010 1:20 pm

I did and it works fine !!!
What about those messages: "cannot change configuration property xxxxx after component ..."
lazinskip
 
Posts: 20
Joined: Fri Oct 01, 2010 10:23 pm

Re: SmartGwt and RestDataSource

Postby asablin » Thu Oct 07, 2010 10:24 pm

Can you provide a reproducible test case with this message?
asablin
Moderator
 
Posts: 19
Joined: Thu Sep 23, 2010 3:07 am

Re: SmartGwt and RestDataSource

Postby lazinskip » Fri Oct 08, 2010 1:30 am

ok I will try but it will take some time. This message not always appear and it comes from SmartGwt
lazinskip
 
Posts: 20
Joined: Fri Oct 01, 2010 10:23 pm

Re: SmartGwt and RestDataSource

Postby Eric Clayberg » Fri Oct 08, 2010 4:41 am

lazinskip wrote:ok I will try but it will take some time. This message not always appear and it comes from SmartGwt

If the message is coming from SmartGWT (which explains why we are unfamiliar with it), you should ask the SmartGWT provider what it means or how to avoid it.
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: SmartGwt and RestDataSource

Postby lazinskip » Fri Oct 08, 2010 12:53 pm

Ok Ithink I got it
I have restDataSource and I changed its id property. When I bind this datasource to a component like ligrid or dynamicform I get those messages. Pattern when those massages will not apper is when all fields and properties are added or changed in creation time (in constructor) As I recall SmartGwt forum thread when you are trying to change those properties when object is already created you will get those messages. The proper pattern according to this thread (aswer from isomorphic guys) is to destroy datasource and create it again with new values of those properties. I think GWT Designer is now generating code in way which will couse those problems.
lazinskip
 
Posts: 20
Joined: Fri Oct 01, 2010 10:23 pm

Re: SmartGwt and RestDataSource

Postby Eric Clayberg » Fri Oct 08, 2010 1:37 pm

Please provide an example of how the code it is generated now and how you propose to change it.
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: SmartGwt and RestDataSource

Postby lazinskip » Sat Oct 09, 2010 1:03 am

Hi Eric, I am afraid Iam not so much experienced programmer to give you valuable clues. Problem we are talking about concerns not only datasources but all components in SmartGwt. Some properties cannot be changed after component creation or to be more specific after component was drawn (in case of datasources this means that component with datasource attached to it was drawn). I think it could be general issue GwtDesigner with SmartGwt because proper usage of this framework requires smart and ordered right property setting and GwtDesigner by its nature keeps and manage the code. I have no idea how to solve this problem. Isomorphic guys has their own drag&drop tools for screen creation but as you probably know it not generates java code. There were plans to give programmers tool which can generate java code but so far isomorphic guys stands that "visualbuilder" is rather for analyst and designers.
lazinskip
 
Posts: 20
Joined: Fri Oct 01, 2010 10:23 pm

Re: SmartGwt and RestDataSource

Postby lazinskip » Sat Oct 09, 2010 4:39 am

Maybe solution to this problem will be inner class of the component which extends e.g DataSource class. The only purpose of this class is to deliver constructor where those critical properties can be set (if you could provide a list of those properties - but from SmartGwt forum I know that list of props can change) I have noticed that some components have "contructor" properties where I can set values for constructor properties. Maybe if in this property I could check what properties should be set in costructor (not their values but which property should be set via constructor). Then this property will be added to constructor code.
In example the fields property cannot be changed after component creation which means it should be checkable in constructor property and after that any field added to this datasource should created and specified via setFields mathod in constructor not by addfield method. I do not know if those propositions are right but i think it is worth to try.
lazinskip
 
Posts: 20
Joined: Fri Oct 01, 2010 10:23 pm

Re: SmartGwt and RestDataSource

Postby lazinskip » Sat Oct 09, 2010 1:46 pm

And here is my proposition how code could be generated:
Code: Select all
package pl.com.intuicja.client;

import com.smartgwt.client.data.OperationBinding;
import com.smartgwt.client.data.RestDataSource;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourcePasswordField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSOperationType;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.form.DynamicForm;

public class WndInnerClass extends Window {
   private final VLayout layout = new VLayout();
   private final ListGrid listGrid = new ListGrid();
   private final DynamicForm dynamicForm = new DynamicForm();
   private static UserDS ds;
   public class UserDS extends RestDataSource{
      UserDS(String id){
         setID(id);
         OperationBinding fetchOB= new OperationBinding();
         fetchOB.setOperationType(DSOperationType.FETCH);
         OperationBinding addOB= new OperationBinding();
         addOB.setOperationType(DSOperationType.ADD);
         OperationBinding removeOB = new OperationBinding();
         removeOB.setOperationType(DSOperationType.REMOVE);
         OperationBinding updateOB = new OperationBinding();
         updateOB.setOperationType(DSOperationType.UPDATE);
         setOperationBindings(fetchOB,updateOB,removeOB,addOB);
         DataSourceIntegerField dsifUserId = new DataSourceIntegerField("userId");
         DataSourceTextField dstfUserLogin = new DataSourceTextField("userLogin");
         DataSourcePasswordField dspfUserPasswd = new DataSourcePasswordField("userPasswd");
         DataSourceTextField dstfUserDesc = new DataSourceTextField("userDesc");
         setFields(dsifUserId, dstfUserLogin, dspfUserPasswd, dstfUserDesc);
         
         
      }
   }
   public UserDS getDataSourceInstance(){
      if (ds == null){
         ds = new UserDS("UserDS");
      }
      return ds;
   }

   public WndInnerClass() {
      setTitle("New window");
      resizeTo(350, 200);
      listGrid.setDataSource(this.getDataSourceInstance());
      layout.addMember(listGrid);
      dynamicForm.setDataSource(this.getDataSourceInstance());
      layout.addMember(dynamicForm);
      
      addItem(layout);
      
   }

}

lazinskip
 
Posts: 20
Joined: Fri Oct 01, 2010 10:23 pm

Re: SmartGwt and RestDataSource

Postby Eric Clayberg » Mon Oct 11, 2010 1:53 pm

lazinskip wrote:What about those messages: "cannot change configuration property xxxxx after component ..."

Give this a try using the latest GWT Designer build...

http://code.google.com/webtoolkit/tools ... -beta.html
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: SmartGwt and RestDataSource

Postby lazinskip » Wed Oct 20, 2010 2:20 pm

Hi, sorry for the delay but I was very busy :)
I have tried new beta version and I can't see difference in code generation in GwtDesigner but messages about trying to change property after component ... are gone. Could you tell me what change was made ?
One other thing - I have seen error message about adding fields to datatsource after creation but right now I am not able to reproduce it. I will keep trying
lazinskip
 
Posts: 20
Joined: Fri Oct 01, 2010 10:23 pm

Re: SmartGwt and RestDataSource

Postby asablin » Wed Oct 20, 2010 8:46 pm

lazinskip wrote:Hi, sorry for the delay but I was very busy :)
messages about trying to change property after component ... are gone. Could you tell me what change was made ?

We correct background life-cycle for DataSources. :-)
asablin
Moderator
 
Posts: 19
Joined: Thu Sep 23, 2010 3:07 am

Re: SmartGwt and RestDataSource

Postby asablin » Wed Oct 20, 2010 10:37 pm

lazinskip wrote:I have tried new beta version and I can't see difference in code generation in GwtDesigner

Sorry, GWTDesigner do not support inner and anonymous classes.
asablin
Moderator
 
Posts: 19
Joined: Thu Sep 23, 2010 3:07 am

Next

Return to GWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest

cron