I am trying to pass the login details from the login view to the next view.
I found a tutorial and followed it however I am stuck. I am able to store
the login data on the server side but an unable to retrieve it.
The server side code is:
private ViewData viewData = new ViewData();
public ViewData setViewData(String accountId, String accountLevel, StringymId
) {
System.out.println("accountId = " + accountId);
ViewData viewData = new ViewData();
viewData.setaccountId(accountId);
viewData.setaccountLevel(accountLevel);
viewData.setymId(ymId);
System.out.println("setViewData viewData.getaccountId() = " + viewData.
getaccountId());
return null;
}
public ViewData getViewData(String accountId, String accountLevel, StringymId
) {
//viewData = new ViewData(viewData.getaccountId(),
viewData.getaccountLevel(), viewData.getymId());
viewData = new ViewData();
System.out.println("getViewData viewData.getaccountId() = " + viewData.
getaccountId());
System.out.println("getViewData accountId = " + accountId);
return viewData;
}
public ViewData getViewData() {
return viewData;
}
getViewData is called by:
verticalPanel.addAttachHandler(new Handler() {
public void onAttachOrDetach(AttachEvent event) {
//On load of page get the Account Level and ID.
Window.alert("SelectPersonView vertical panel attached.");
AsyncCallback<ViewData> callback = new ViewDataHandler<ViewData
>(SelectPersonView.this);
rpc.getViewData(null, null, null, callback);
When I call setViewData the two System.out.println display 7 and 7 which is
correct.
When I call getViewData the two System.out.println display null and null is
returned to the calling view.
}
});
class ViewDataHandler<T> implements AsyncCallback<ViewData> {
SelectPersonView view;
public ViewDataHandler(SelectPersonView view) {
this.view = view;
}
public void onFailure(Throwable ex) {
Window.alert("RPC call failed.");
}
public void onSuccess(ViewData result) {
//Store the view data
ViewData viewData = result;
accountId = viewData.getaccountId();
accountLevel = viewData.getaccountLevel();
ymId = viewData.getymId();
Window.alert("accountId = " + accountId + " accountLevel = "
+accountLevel
+ " ymId = " + ymId);
}
}
The asynchronous version of the interface is:
//View data
public void setViewData(String accountId, String accountLevel, String ymId,
AsyncCallback<ViewData> callback);
public void getViewData(String accountId, String accountLevel, String ymId,
AsyncCallback<ViewData> callback);
The class that represent the data model is:
package org.AwardTracker.client;
import java.io.Serializable;
public class ViewData implements Serializable {
private static final long serialVersionUID = 1L;
private String accountId;
private String accountLevel;
private String ymId;
//@SuppressWarnings("unused")
public ViewData() {
//just here because GWT wants it.
}
// public ViewData(String accountId, String accountLevel, String ymId) {
// this.accountId = accountId;
// this.accountLevel = accountLevel;
// this.ymId = ymId;
// }
public String getaccountId() {
return accountId;
}
public void setaccountId(String accountId) {
this.accountId = accountId;
}
public String getaccountLevel() {
return accountLevel;
}
public void setaccountLevel(String accountLevel) {
this.accountLevel = accountLevel;
}
public String getymId() {
return ymId;
}
public void setymId(String ymId) {
this.ymId = ymId;
}
}
As stated above, when I call setViewData the two System.out.println display
7 and 7 which is correct. However, is the code correct (i.e., is the data
actually being stored)?
If not then how should I code to store the data from the Login view to be
retrieved by the next view?
If the code is correct and the data is stored then what changes do I need
to make to retrieve the data using getViewData by the calling view.
I am doing this for my Scout Group and have been working on the project for
over 12 months and this is the final hurdle I need to complete the project.
So your help would be greatly appreciated.
Regards,
Glyn
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.