hi
i use gwt ans struts
i would like to send server error to the client
i created a small project
the console error i get when i call the method who suppose to return
me the error
[code]
com.google.gwt.user.server.rpc.UnexpectedException: S
ervice method 'public java.lang.String
org.yournamehere.action.WebErrorAction.myMethod(java.lang.String)
throws org.yournamehere.client.ErrorManager'
threw an unexpected exception:
java.lang.reflect.InvocationTargetException
[/code]
my action
[code]
public class WebErrorAction extends RemoteServiceServlet implements
GWTService {
public WebErrorAction() {
}
public String myMethod(String s) throws ErrorManager {
GWTServiceImpl serviceImpl = new GWTServiceImpl();
return serviceImpl.myMethod(s);
}
}
[/code]
my error class
[code]
public class ErrorManager extends Exception implements IsSerializable
{
private String errorManager;
public ErrorManager() {
}
public ErrorManager(String errorManager) {
this.errorManager = errorManager;
}
public String getErrorManager() {
return this.errorManager;
}
}
[/code]
my service
[code]
public interface GWTService extends RemoteService{
public String myMethod(String s) throws ErrorManager;
}
[/code]
service async
[code]
public interface GWTServiceAsync {
public void myMethod(String s, AsyncCallback callback);
}
[/code]
client side, we call the service
[code]
public void callService(String s) {
GWTServiceAsync service = (GWTServiceAsync)
GWT.create(GWTService.class);
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
lblServerReply.setText((String) result);
}
public void onFailure(Throwable caught) {
String details = caught.getMessage();
if (caught instanceof ErrorManager) {
details = ((ErrorManager)
caught).getErrorManager() + " occured";
}
Window.alert("error " + details);
}
};
ServiceDefTarget endpoint = (ServiceDefTarget) service;
endpoint.setServiceEntryPoint("WebErrorAction.action");
service.myMethod(s, callback);
}
[/code]
implementation of the service method... i generate directely an error
to see if the server will send the error to the client...
[code]
public class GWTServiceImpl extends RemoteServiceServlet implements
GWTService {
public String myMethod(String s) throws ErrorManager {
throw new ErrorManager("error occured " + s);
}
}
[/code]
on the client side, onFailure is called
because i get this message
[code]
error: The call failed on the server; see server log for details
[/code]
it's like if ErrorManager would be unknow...
any idea?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---