First of all I did not make this code and I am not a java programmer, I just modified this from a "feedback form" page into a "request form" page. My goal here is to disable the submit button and alert the user that it is required to tick the checkbox and/or prevent it from submitting data if the checkbox is unchecked. As much as possible, I want to avoid using javascript.
Here's a snippet of the code:
public Serializable getKey() {
String email = parameters.getParameter("email", "");
String message = parameters.getParameter("message", "");
String page = parameters.getParameter("page", "unknown");
return HashUtil.hash(email + "-" + message + "-" + page);
}
/**
* Generate the cache validity object.
*/
public SourceValidity getValidity() {
return NOPValidity.SHARED_INSTANCE;
}
public void addPageMeta(PageMeta pageMeta) throws SAXException,
WingException, SQLException, IOException,
AuthorizeException {
pageMeta.addMetadata("title").addContent(T_title);
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
pageMeta.addTrail().addContent(T_trail);
}
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException {
// Build the item viewer division.
Division ill = body.addInteractiveDivision("ill-form",
contextPath + "/ill", Division.METHOD_POST, "primary");
ill.setHead(T_head);
ill.addPara(T_para1);
List form = ill.addList("form", List.TYPE_FORM);
Text email = form.addItem().addText("email");
email.setAutofocus("autofocus");
email.setLabel(T_email);
email.setHelp(T_email_help);
email.setValue(parameters.getParameter("email", ""));
TextArea message = form.addItem().addTextArea("message");
message.setLabel(T_message);
message.setValue(parameters.getParameter("message", ""));
CheckBox copyright = form.addItem().addCheckBox("accept");
String selected = !parameters.getParameter("accept", "true").equalsIgnoreCase("false") ? "true" : "false";
copyright.setOptionSelected(selected);
copyright.addOption("accept", T_copyright_agree);
copyright.setLabel(T_copyright_label);
copyright.setHelp(T_copyright);
form.addItem().addButton("submit").setValue(T_submit);
ill.addHidden("page").setValue(parameters.getParameter("page", "unknown"));
}
}
Thanks in advance for the help.