1
GWT에 클라이언트 측으로 이동할 수없는 서버 측 객체가 있습니다 (예 : @GwtCompatible이 아님). 나는 그들을 페이지에서 사용하고 싶다. gwt를 사용하여 html로 렌더링하고 클라이언트에게 보낼 수 있습니까?GWT의 서버 측에서 html을 렌더링 할 수 있습니까?
GWT에 클라이언트 측으로 이동할 수없는 서버 측 객체가 있습니다 (예 : @GwtCompatible이 아님). 나는 그들을 페이지에서 사용하고 싶다. gwt를 사용하여 html로 렌더링하고 클라이언트에게 보낼 수 있습니까?GWT의 서버 측에서 html을 렌더링 할 수 있습니까?
글쎄, 확실히 서버에 HTML 스 니펫을 만들 수 있습니다. 이 같은 :
서버 측 :
public class MyServiceImpl extends RemoteServiceServlet implements MyService {
public String getHtmlSnippet(String param) {
String html = buildHtmlSnippetInASafeWay(param); // Use any (safe) HTML
// builder you like. (this
// is not GWT related!)
return html;
}
}
클라이언트 측 :
myService.getHtmlSnippet(myParam, new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
myParent.add(new HTML(result));
// or: myElem.setInnerHTML(result);
}
@Override
public void onFailure(Throwable caught) {
// ...
}
});
하지만 더 나은 솔루션 복사, 당신이 당신의 비 GwtCompatible에서 필요한 데이터를 간단한 데이터 객체를 생성하는 아마 클래스를 객체에 추가하고, 클라이언트로 전송 한 다음 평소와 같이 사용합니다.