String content,
Input customButton,
LabelResource labels,
boolean hasCloseButton,
boolean hasSubmitAndCancelButtons) {
Form form = new Form(action, Form.POST, Form.ENC_DEFAULT).setAcceptCharset(
environment.getCharsetWWW()).addElement(content);
// See if buttons are to be added to the bottom of the tab
if(hasCloseButton || hasSubmitAndCancelButtons ||
(customButton != null)) {
form.addElement(new HR());
form.addElement(new Input(Input.HIDDEN, ACTION, "1"));
TR buttonRow = new TR();
if(customButton != null) {
buttonRow.addElement(new TD().addElement(customButton));
}
if(hasCloseButton) {
Input closeButton = new Input(Input.BUTTON, "clb", labels.getLabel("close_button"));
closeButton.setOnClick("window.close()");
buttonRow.addElement(new TD().addElement(closeButton));
}
//hmmm, might cause tr without a single td... is it bad?
if(hasSubmitAndCancelButtons) {
Input okButton = new Input(Input.BUTTON, "okb", labels.getLabel("ok_button"));
okButton
.setOnClick("document.forms[0].action.value='1';document.forms[0].submit()");
Input cancelButton = new Input(Input.BUTTON, "cancelb", labels
.getLabel("cancel_button"));
cancelButton
.setOnClick("document.forms[0].action.value='0';document.forms[0].submit()");
buttonRow.addElement(new TD()
.setAlign(AlignType.RIGHT)
.addElement(okButton)
.addElement(Entities.NBSP)
.addElement(cancelButton));
}
form.addElement(new Table().setWidth("100%").addElement(buttonRow));
}
return form;
}