View Full Version : RPC with gwt1.5M2
companioncabinet
05-08-2008, 01:04 PM
Has anyone gotten rpc calls to work using gwt1.5M2? Can you provide and example for both front and back end?
Thanks
Grandiosa
05-09-2008, 02:28 AM
Hi,
I have been using M1 and M2 for a couple of months allready and the code is allready solid in my experience, and RPC works fine. Exactly what kind of problems do you experience?
If you're problems are strictly GWT related you might also want to try a GWT user group instead.
companioncabinet
05-09-2008, 08:49 AM
Can you post an example of your server side code and web.xml etc working with the PagingTableViewerPage.java?
darrellmeyer
05-09-2008, 10:05 AM
Have you looked at the PagingTableViewer page in the Explorer Demo? It uses RPC and includes the server side code. Also, take a look at the rpc unit tests.
companioncabinet
05-14-2008, 08:00 AM
Morning,
I am able to run the TablePagingPage example and the rpc calls to ExplorerServiceImpl work fine. But when we separate out the service into another project and are trying to use gwt-sl as the glue for spring and session management etc, but cant get it to work just right with the 1.5M2. Can you offer any recommendations on how to integrate with spring, sessions, etc?
darrellmeyer
05-14-2008, 09:22 AM
Can you offer any recommendations on how to integrate with spring, sessions, etc?
I don't think I can be much help here. I do not have any experience with gwt-sl. Are you able to run you server in debug mode? You can slap in some break points and trace execution. If not, you can use logging to do the same thing. You can also use Firebug to monitor requests to and from the browser.
Grandiosa
05-15-2008, 03:43 AM
Hi,
For Spring integration i use this approach. (http://adminsight.de/2008/02/14/non-invasive-gwt-and-spring-integration/)
This approach doesn't require the DispatcherServlet.
Just copy the annotation and the class from the article into your project and use the AutoInject annotation to inject your DAOs or Service objects into your GWT service objects, works great.
As commented in the article one issue with this approach concerns how to set the context parameter for GWT hosted mode as this mode doesn't allow init parameters in the web.xml file. But there are workarounds for that, depending on your development environment.
Of course, you can also use the -noserver hosted mode option to get full control of your server environment
companioncabinet
05-15-2008, 09:37 AM
Thanks for the advice! We got the data flowing now, but the data returned by the rpc does seem to be populating the table columns. I took you PagingTablePage code and modified to use our own rpc service. I checked firefox and this is the data being return by our rpc service. Is there any way to find out why the data is not being populated in the columns?
//OK[0,1,0,0,1000110,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,3,1,2,1,0,1,["com.extjs.gxt.ui.client.data.BasePagingLoadResult/496878394","java.util.ArrayList/3821976829","com.companioncabinet.ccs.dto.JobDTO/4206218594","com.companioncabinet.ccs.dto.CustomerDTO/3114489196","java.lang.Integer/3438268394"],0,3]
companioncabinet
05-15-2008, 10:11 AM
This is the format of my class:
public abstract class BaseDTO extends BaseModel
{
private Integer id;
public BaseDTO()
{
visible = true;
}
public BaseDTO(Integer id, Integer parentId, String description, boolean visible, Integer childSequence,
Integer parentSequence)
{
super();
this.id = id;
this.parentId = parentId;
this.description = description;
this.visible = visible;
this.childSequence = childSequence;
this.parentSequence = parentSequence;
}
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
Does it have to follow this format instead in order to work with the columns and tables?
public class Stock extends BaseModel {
public Stock() {
}
public Stock(String name, String symbol, double open, double last) {
set("name", name);
set("symbol", symbol);
set("open", open);
set("last", last);
set("date", new Date());
set("change", last - open);
}
public Date getLastTrans() {
return (Date) get("date");
}
public String getName() {
return (String) get("name");
}
companioncabinet
05-15-2008, 01:10 PM
I changed our class using the set("date", new Date()) & get("date") and that did the trick!
Another question is if our object is parentObject.childObject.childProperty, how can I map a column to the childProperty? By just using
columns.add(new TableColumn("childProperty", "Some Child Property", 150));
companioncabinet
05-15-2008, 01:44 PM
please see attached screenshot...
darrellmeyer
05-15-2008, 02:17 PM
The column id should match the model property name.
companioncabinet
05-15-2008, 09:05 PM
So if I have this object:
JobDTO and it has this child object CustomerDTO and I want to map a property of CustomerDTO (ie JobDTO.CustomerDTO.customerName) to a column, then I would use this?
columns.add(new TableColumn("customerName", "Customer Name", 150));
or
columns.add(new TableColumn("CustomerDTO.customerName", "Customer Name", 150));
darrellmeyer
05-16-2008, 02:48 AM
If you are using a Store, then the column's id needs to equal the property of your ModelData instance. The table code will access the data for each column using the get method of the model. It has no knowledge that the model is a JobDTO or that it has a CustomerDTO child.
You will either need to adapt your DTO to the ModelData interface or use one of the concrete BaseModel* class and store your data in the internal map with get and set.
Both of your examples would not work unless JobDTO is or implements BaseModel and get("customerName") or get("CustomerDTO.customerName") returns the correct value. There is no support for nested objects and properties at this time. However, that would be a nice feature, especially when we get to form binding :).
companioncabinet
05-16-2008, 08:08 AM
Hi Darrell,
Hopefully this will be my last post on this subject :)
Below is the code for my objects...
public class JobDTO extends BaseDTO
{
public String getJobName()
{
return (String) get("jobName");
}
public void setJobName(String jobName)
{
set("jobName", jobName);
}
public CustomerDTO getCustomerDTO()
{
return (CustomerDTO) get("customerDTO");
}
public void setCustomerDTO(CustomerDTO customerDTO)
{
set("customerDTO", customerDTO);
}
}
public class CustomerDTO extends BaseDTO
{
public String getName()
{
return (String) get("name");
}
public void setName(String name)
{
set("name", name);
}
}
public abstract class BaseDTO extends BaseModel
{
}
below is the code to hook up the table
List<TableColumn> columns = new ArrayList<TableColumn>();
columns.add(new TableColumn("name", "Customer Name", 150));
TableColumnModel cm = new TableColumnModel(columns);
Table table = new Table(cm);
RpcProxy proxy = new RpcProxy()
{
@Override
public void load(Object loadConfig, AsyncCallback callback)
{
jobRemoteSvcAsync.getJobs((PagingLoadConfig) loadConfig, callback);
}
};
BasePagingLoader loader = new BasePagingLoader(proxy);
ListStore<JobDTO> store = new ListStore<JobDTO>(loader);
store.setRemoteSort(true);
new TableBinder<JobDTO>(table, store);
final PagingToolBar toolBar = new PagingToolBar(50);
toolBar.bind(loader);
loader.load(0, 50);
ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setCollapsible(true);
panel.setAnimCollapse(false);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setIconStyle("icon-table");
panel.setHeading("Paging TableViewer");
panel.setLayout(new FitLayout());
panel.add(table);
panel.setSize(600, 450);
panel.setBottomComponent(toolBar);
add(panel);
is this line of code correct for the mapping of the customerDTO.name property? I tried this but it reports as null in the table.
columns.add(new TableColumn("name", "Customer Name", 150));
what do you suggest in order to display the customerDTO.name property in the table?
p.s. You've done a nice job on gtx thus far!
darrellmeyer
05-16-2008, 11:03 AM
Ok, I have hadded nested property support to BaseModelData for both get and set. Here is the test code:
public void testNesting() {
ModelData outer = new BaseModelData();
ModelData inner = new BaseModelData();
inner.set("name", "Darrell");
outer.set("inner", inner);
assertEquals("Darrell", outer.get("inner.name"));
outer.set("inner.name", "Maro");
assertEquals("Maro", outer.get("inner.name"));
}So with the latest code, you can do:
columns.add(new TableColumn("CustomerDTO.customerName", "Customer Name", 150));Change is in SVN. Take a look at let me know it works for you.
companioncabinet
05-16-2008, 11:37 AM
You rock! I will get the latest version and test right away. Thanks!
companioncabinet
05-16-2008, 02:10 PM
It worked! Thanks for your help!
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.