THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
In this example the action "Hello" will return the string passed to it. Remember, the returned object is not the regular Struts result, it is the object that you will receive on the client side. The method can have any name.
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
public class Hello { public String executehello(String text) { return text; } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="example" extends="gwt-default">
<action name="Hello" class="example.Hello" method="hello">
<interceptor-ref name="gwt"/>*
<result type="void"/>*
</action>
</package>
</struts>
|
...
Code Block | ||||
---|---|---|---|---|
| ||||
public interface MyService extends RemoteService { public String executehello(String s); } public interface MyServiceAsync { public void executehello(String s, AsyncCallback callback); } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
MyServiceAsync service = (MyServiceAsync) GWT.create(MyService.class); AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) { Window.alert(result.toString()); } public void onFailure(Throwable caught) { Window.alert(caught.toString()); } }; ServiceDefTarget endpoint = (ServiceDefTarget) service; endpoint.setServiceEntryPoint("Hello.action"); service.executehello("HelloHi There!", callback); |
Installation
...