Use the FormPanel.submit() for this.
I do exactly what you want: I use iText in the background and use a
servlet that generates the pdf.
The FormPanel.submit() is used to submit the required info to the
servlet.
The submit() works like a Form submit.
I build a FormBuilder class that makes things a bit easier.
I included it below:
----
public final class FormBuilder {
private FormPanel formPanel;
public FormBuilder() {
}
public FormBuilder(final Method method, final String action, final
String target) {
setMethod(method);
setAction(action);
setTarget(target);
}
public void submit() {
try {
RootPanel.get().add(getEnsureFormPanel());
getEnsureFormPanel().submit();
}
finally {
RootPanel.get().remove(getEnsureFormPanel());
}
}
public void setAcceptedCharset(final String charsets) {
getEnsureFormPanel().getElement().setAttribute("accept-charset",
charsets);
}
public void setAction(final String action) {
getEnsureFormPanel().setAction(action);
}
public void setMethod(final Method method) {
getEnsureFormPanel().setMethod(method.getValue());
}
public void setTarget(final String target) {
getEnsureFormPanel().getElement().setAttribute("target",
target);
}
public void addValue(final String name, final String value) {
final InputElement el = Document.get().createTextInputElement();
getEnsureFormPanel().getElement().appendChild(el);
el.setName(name);
el.setValue(value);
}
public void removeAllValues() {
final int size =
getEnsureFormPanel().getElement().getChildCount();
if (size > 0) {
for (int i = size - 1; i >= 0; i--) {
getEnsureFormPanel().getElement().getChild(i).removeFromParent();
}
}
}
//
//
private FormPanel getEnsureFormPanel() {
if (this.formPanel == null) {
this.formPanel = new FormPanel();
this.formPanel.getElement().getStyle().setDisplay(Display.NONE);
}
return this.formPanel;
}
/**
*/
public enum Method {
POST("POST"), GET("GET");
private final String value;
private Method(final String methodName) {
this.value = methodName;
}
public String getValue() {
return this.value;
}
}
--
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.