Hi,

the problem is in setHeadline in Purchase - it must be:

public void setHeadline(String headline){
  this.headline = headline;
}

Best regards,
Basdl

On Feb 13, 12:14 am, Bastian <[email protected]> wrote:
> Hello,
>
> I hope everyone is fine. I have started to use RPC’s with GWT. I have
> worked through the examples and tutorials and I believe understand how
> it works. Now, I have created my own class to serialize and use in an
> asynchronous callback so that the client can receive data about a
> purchase from a server. Everything compiles properly and the onSuccess
> method gets executed, but when I try to read the received data, it
> only is “Null”. Does anyone have an idea what might be wrong with my
> code?
>
> Thanks a lot.
>
> Best regards,
>
> Bastian
>
> Here is my code:
>
> Class to store the data in client package:
>
> import java.io.Serializable;
>
> @SuppressWarnings("serial")
> public class Purchase implements Serializable {
>
>           private String username;
>           private String headline;
>           private String description;
>
>           public Purchase()
>           {
>
>           }
>
>           public String getUsername(){
>                 return username;
>           }
>
>           public String getHeadline(){
>                   return this.headline;
>           }
>
>           public String getDescription(){
>                   return description;
>           }
>
>           public void setUsername(String username){
>                   this.username = username;
>           }
>
>           public void setHeadline(String headline){
>                   this.username = headline;
>           }
>
>           public void setDescription(String description){
>                   this.description = description;
>           }
>
> }
>
> Service Interface in client package:
>
> import com.google.gwt.user.client.rpc.RemoteService;
> import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
>
> @RemoteServiceRelativePath("collectivePurchase")
> public interface CollectivePurchaseService extends RemoteService {
>   Purchase getCollectivePurchase(String username);
>
> }
>
> Async Interface in the client package:
>
> import com.google.gwt.user.client.rpc.AsyncCallback;
>
> public interface CollectivePurchaseServiceAsync {
>
>   void getCollectivePurchase(String username, AsyncCallback<Purchase>
> callback);
>
> }
>
> Server implementation:
>
> import com.google.gwt.user.server.rpc.RemoteServiceServlet;
>
> @SuppressWarnings("serial")
> public class CollectivePurchaseServiceImpl extends
> RemoteServiceServlet implements CollectivePurchaseService {
>
> public Purchase getCollectivePurchase(String username) {
>
> com.biddrocket.secretrocket.client.Purchase collective = new
> com.biddrocket.secretrocket.client.Purchase();
>                 collective.setUsername("brian");
>                 collective.setHeadline("motor bike");
>                 collective.setDescription("most amazing bike");
>
>                 return collective;
>
>         }
>
> }
>
> Client entry point:
>
> CollectivePurchaseServiceAsync collectivePurchaseService =
> (CollectivePurchaseServiceAsync)
> GWT.create(CollectivePurchaseService.class);
>
> collectivePurchaseService.getCollectivePurchase("brian ley", new
> AsyncCallback<Purchase>() {
>                                                 public void 
> onFailure(Throwable caught) {
>                                                         
> Window.alert(caught.getLocalizedMessage());
>                                                 }
>                                                 @Override
>                                                 public void 
> onSuccess(Purchase result) {
>                                                          update(result);
>
>                                                 }
>                                         });
>
>                   //Make the call to the RPC to get the headline for the 
> gallery
> showcase
>                   //collectivePurchaseService.getHeadline("brian", callback);
>           }
>           public void update(Purchase collective){
>                   Window.alert(collective.getHeadline());
>           }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to