I'm getting an error when I'm trying to access server-side's GreetingServiceImpl class and try to use a function of it in client-side.
ERROR: No source code is available for type com.demo1.server.GreetingServiceImpl; did you forget to inherit a required module?
Here is the GreetingServiceImpl:
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {
public LinkedList<String> greetServer() throws IllegalArgumentException {
// Verify that the input is valid.
LinkedList<String> list = new LinkedList<String>();
try {
File file = getLog();
Parse parse = new Parse(file);
list = parse.callControlRequest();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
public File getLog() throws IOException {
//doing something
}
}
and I'm trying to use it in client-side like:
GreetingServiceImpl resultList = new GreetingServiceImpl(); //this is where I am getting error
greetingService.greetServer(new AsyncCallback>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
dialogBox
.setText("Remote Procedure Call - Failure");
dialogBox.center();
}
@Override
public void onSuccess(LinkedList<String> result) {
result=resultList.greetServer(); // this is where I am trying to get the output of it
}
});;
}
You cannot use classes from your server side on client side. To use GreetingService you should instantiate it's async part:
GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
then you could use greetingService variable to call methods in GreetingServiceImpl - you can't use or refer GreetingServiceImpl directly on client side, so line
GreetingServiceImpl resultList = new GreetingServiceImpl();
is illegal - remove it.
Also you can generate default gwt application and look how it's done there or look at DynaTable sample provided with gwt library: gwt-dir/samples/DynaTable.