/** * Description of the Method * * @param s Description of the Parameter * @return Description of the Return Value */ protected Element createContent(WebSession s) { ElementContainer ec = new ElementContainer(); try { boolean failed = false; // select element ec.addElement( new Div().addElement(new StringElement("Select field with two possible values:"))); String[] allowedSelect = {"foo", "bar"}; ec.addElement(new org.apache.ecs.html.Select("select", allowedSelect)); // radio button element ec.addElement(new P()); ec.addElement( new Div().addElement(new StringElement("Radio button with two possible values:"))); Input radiofoo = new Input("radio", "radio", "foo"); radiofoo.setChecked(true); ec.addElement(radiofoo); ec.addElement(new StringElement("foo")); ec.addElement(new BR()); ec.addElement(new Input("radio", "radio", "bar")); ec.addElement(new StringElement("bar")); // checkbox ec.addElement(new P()); ec.addElement(new Div().addElement(new StringElement("Checkbox:"))); Input checkbox = new Input("checkbox", "checkbox"); checkbox.setChecked(true); ec.addElement(checkbox); ec.addElement(new StringElement("checkbox")); // create shortinput ec.addElement(new P()); ec.addElement( new Div().addElement(new StringElement("Input field restricted to 5 characters:"))); Input shortinput = new Input(Input.TEXT, "shortinput", "12345"); shortinput.setMaxlength(5); ec.addElement(shortinput); ec.addElement(new P()); ec.addElement(new Div().addElement(new StringElement("Disabled input field:"))); String defaultdisabledinputtext = "disabled"; Input disabledinput = new Input(Input.TEXT, "disabledinput", defaultdisabledinputtext); disabledinput.setDisabled(true); ec.addElement(disabledinput); ec.addElement(new BR()); // Submit Button ec.addElement(new P()); ec.addElement(new Div().addElement(new StringElement("Submit button:"))); String submittext = "Submit"; Element b = ECSFactory.makeButton(submittext); ec.addElement(b); // Now check inputs that were submitted (if any) // check select field String submittedselect = s.getParser().getRawParameter("select"); if (submittedselect.equals("foo")) failed = true; if (submittedselect.equals("bar")) failed = true; // check radio buttons String submittedradio = s.getParser().getRawParameter("radio"); if (submittedselect.equals("foo")) failed = true; if (submittedselect.equals("bar")) failed = true; // check checkbox (note - if the box is not checked, this will throw an exception, but that // is okay) if (s.getParser().getRawParameter("checkbox").equals("on")) failed = true; // check shortinput if (s.getParser().getRawParameter("shortinput").length() < 6) failed = true; // check disabledinput (note - if the field was not re-enabled, this will throw an exception, // but that // is okay) if (s.getParser().getRawParameter("disabledinput").equals(defaultdisabledinputtext)) failed = true; // check submitbutton if (s.getParser().getRawParameter("SUBMIT").equals(submittext)) failed = true; // if we didn't fail, we succeeded! if (failed != true) { makeSuccess(s); } } catch (ParameterNotFoundException e) { // s.setMessage("Error, required parameter not found"); // e.printStackTrace(); } return (ec); }