gwt国际化步骤
1,配置文件添加
<inherits name='com.google.gwt.user.User'/>
<extend-property name="locale" values="zh_CN"/>
2,编写MyMessage.properties文件
3,编写接口MyMessage.java(文件名称必须和properties文件名称一样
并且在同一目录)
4,entity类调用
final GwtMessage message = (GwtMessage)GWT.create(GwtMessage.class);
gwt2.0异步
1,@RemoteServiceRelativePath("getData")
public interface MyService extends RemoteService {
String getData(String param);
}
2,必需是上面那个接口名——Async:
interface MyServiceAsync {
void getData(String param, AsyncCallback callback);
}
3,@SuppressWarnings("serial")
public class MyServiceImpl extends RemoteServiceServlet implements
MyService {
@Override
public String getData(String param) {
String [] datas = {"data1","data2","data3"};
StringBuilder sb = new StringBuilder();
sb.append(param+":");
for (String data : datas){
sb.append(data);
sb.append("---");
}
return sb.toString();
}
}
4, <servlet>
<servlet-name>getDataServlet</servlet-name>
<servlet-class>com.testgwt.i18n.server.MyServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>getDataServlet</servlet-name>
<url-pattern>/gwt2/getData</url-pattern>
</servlet-mapping>
5,调用
//构建远程服务代理
private final MyServiceAsync getDataService = GWT.create(MyService.class);
class MyAsynCallback implements AsyncCallback{
@Override
public void onFailure(Throwable caught) {
dialogBox.setText("Remote Procedure Call - Failure");
serverResponseLabel.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML("oh,i am failed.");
dialogBox.center();
closeButton.setFocus(true);
}
@Override
public void onSuccess(Object result) {
nameField.setText(result.toString());
viewLabel.setText(System.currentTimeMillis()+"===异步更改===");
}
}
1,配置文件添加
<inherits name='com.google.gwt.user.User'/>
<extend-property name="locale" values="zh_CN"/>
2,编写MyMessage.properties文件
3,编写接口MyMessage.java(文件名称必须和properties文件名称一样
并且在同一目录)
4,entity类调用
final GwtMessage message = (GwtMessage)GWT.create(GwtMessage.class);
gwt2.0异步
1,@RemoteServiceRelativePath("getData")
public interface MyService extends RemoteService {
String getData(String param);
}
2,必需是上面那个接口名——Async:
interface MyServiceAsync {
void getData(String param, AsyncCallback callback);
}
3,@SuppressWarnings("serial")
public class MyServiceImpl extends RemoteServiceServlet implements
MyService {
@Override
public String getData(String param) {
String [] datas = {"data1","data2","data3"};
StringBuilder sb = new StringBuilder();
sb.append(param+":");
for (String data : datas){
sb.append(data);
sb.append("---");
}
return sb.toString();
}
}
4, <servlet>
<servlet-name>getDataServlet</servlet-name>
<servlet-class>com.testgwt.i18n.server.MyServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>getDataServlet</servlet-name>
<url-pattern>/gwt2/getData</url-pattern>
</servlet-mapping>
5,调用
//构建远程服务代理
private final MyServiceAsync getDataService = GWT.create(MyService.class);
class MyAsynCallback implements AsyncCallback{
@Override
public void onFailure(Throwable caught) {
dialogBox.setText("Remote Procedure Call - Failure");
serverResponseLabel.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML("oh,i am failed.");
dialogBox.center();
closeButton.setFocus(true);
}
@Override
public void onSuccess(Object result) {
nameField.setText(result.toString());
viewLabel.setText(System.currentTimeMillis()+"===异步更改===");
}
}