Package org.apache.click.control

Examples of org.apache.click.control.Form


    /**
     * Builds the user interface for users to change the tree options interactively.
     */
    public void buildOptionsUI() {
        //Form to handle user selected options
        optionsForm = new Form("optionForm");
        FieldSet fieldSet = new FieldSet("options", "Form Options");
        fieldSet.add(jsEnabled);
        fieldSet.add(rootNodeDisplayed);
        fieldSet.add(selectChildNodes);
        optionsForm.add(fieldSet);
View Full Code Here


     *
     * @return the form object
     */
    public Form getForm() {
        if (form == null) {
            form = new Form();
        }
        return form;
    }
View Full Code Here

     * and not when the Form is defined externally.
     *
     * @param buffer the StringBuffer to render to
     */
    protected void renderButtons(HtmlStringBuffer buffer) {
        Form form = getForm();

        List buttonList = form.getButtonList();
        if (!buttonList.isEmpty()) {
            buffer.append("<table cellpadding=\"0\" cellspacing=\"0\"");
            if (getAttribute("width") != null) {
                buffer.appendAttribute("width", getAttribute("width"));
            }
            buffer.append("><tr><td");
            buffer.appendAttribute("align", form.getButtonAlign());
            buffer.append(">\n");
            buffer.append("<table class=\"buttons\" id=\"");
            buffer.append(getId());
            buffer.append("-buttons\">\n");
            buffer.append("<tr class=\"buttons\">");
            for (int i = 0, size = buttonList.size(); i < size; i++) {
                buffer.append("<td class=\"buttons\"");
                buffer.appendAttribute("style", form.getButtonStyle());
                buffer.closeTag();

                Button button = (Button) buttonList.get(i);
                button.render(buffer);

View Full Code Here

*/
public class ControlHeadDemo extends BorderPage {

    public ControlHeadDemo() {

        Form form = new Form("form");

        StarRating rating = new StarRating("rating", 5, 2);
        form.add(rating);

        form.add(new Submit("submit"));

        addControl(form);
    }
View Full Code Here

    @Override
    public void render(HtmlStringBuffer buffer) {

        // Check that the link is attached to a Form and the onClick attribute
        // has not been set
        Form localForm = getForm();
        if (localForm != null && getOnClick() == null) {
            setOnClick(getSubmitScript(localForm.getId()));
        }

        super.render(buffer);
    }
View Full Code Here

     * Check that all input fields are retrieved from container.
     */
    public void testGetInputFields() {
        MockContext.initContext();
        // set up the form
        Form form = new Form("sample");

        // HiddenField should be included
        HiddenField hiddenField = new HiddenField("hidden", boolean.class);
        form.add(hiddenField);

        // TextField should be included
        TextField idField = new TextField("id");
        form.add(idField);

        // FieldSet should NOT be included
        FieldSet fieldset = new FieldSet("fieldset");
        form.add(fieldset);

        // Label should NOT be included
        Label label = new Label("name");
        form.add(label);

        // Button should NOT be included
        Button button = new Button("button");
        form.add(button);
       
        List<Field> fields = ContainerUtils.getInputFields(form);
       
        // Total should be 3 consisting of the fields "hidden", "id" and the
        // Forms internal HiddenField, "form_name".
View Full Code Here

        String price = "10.99";
        context.getMockRequest().setParameter("part.price", price);
        context.getMockRequest().setParameter("form_name", "form");

        // Setup form
        Form form = new Form("form");

        // Setup price field
        TextField priceField = new TextField("part.price");
        form.add(priceField);

        // Process form to bind request parameter to field
        form.onProcess();

        // Assert that the bound priceField value is equal to price
        assertEquals(price, priceField.getValue());

        Car car = new Car();
        form.copyTo(car);

        // Assert that the copied part price value is equal to the price
        assertEquals(price, Double.toString(car.getPart().getPrice()));
    }
View Full Code Here

        MockContext.initContext();

        Page page = new Page();

        // Add two controls named child1 and child2
        Form child1 = new Form("child1");
        Form child2 = new Form("child2");
        page.addControl(child1);
        page.addControl(child2);
        assertEquals(2, page.getModel().size());
        assertEquals(2, page.getControls().size());
        assertSame(child1, page.getControls().get(0));
        assertSame(child2, page.getControls().get(1));

        // Add another two controls named child1 and child2 and test that these
        // controls replaces the previous controls
        child1 = new Form("child1");
        child2 = new Form("child2");
        page.addControl(child1);
        page.addControl(child2);
        assertEquals(2, page.getModel().size());
        assertEquals(2, page.getControls().size());
        assertSame(child1, page.getControls().get(0));
View Full Code Here

    private FileField fileField = new FileField("fileField");

    @Override
    public void onInit() {
        Form form = new Form("form");
        form.add(fileField);
        addControl(form);
    }
View Full Code Here

    public FormProperties() {

        // Setup demonstration form

        form = new Form("form");

        FieldSet fieldSet = new FieldSet("demo", "<b>Demonstration Form</b>");
        form.add(fieldSet);

        nameField = new TextField("name");
        nameField.setRequired(true);
        nameField.setFocus(true);
        fieldSet.add(nameField);

        emailField = new EmailField("email");
        emailField.setRequired(true);
        fieldSet.add(emailField);

        investmentsField = new InvestmentSelect("investments");
        fieldSet.add(investmentsField);

        dateJoinedField = new DateField("dateJoined");
        fieldSet.add(dateJoinedField);

        form.add(new Submit("ok", "  OK  ", this, "onOkClick"));

        Submit cancel = new PageSubmit("cancel", HomePage.class);
        cancel.setCancelJavaScriptValidation(true);
        form.add(cancel);

        addControl(form);

        // Setup control form

        optionsForm = new Form("optionsForm");
        optionsForm.setColumns(3);
        optionsForm.setLabelAlign("right");
        optionsForm.setListener(this, "onApplyChanges");
        optionsForm.setLabelStyle("padding-left:2em;");
View Full Code Here

TOP

Related Classes of org.apache.click.control.Form

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.