Package org.apache.click.control

Examples of org.apache.click.control.Form


    public void demo2() {
        // Create a submit link which includes parameters.
        final SubmitLink paramLink = new SubmitLink("paramLink");

        Form form = new Form("demo2");
        addControl(form);

        FieldSet fieldSet = new FieldSet("fieldSet");
        form.add(fieldSet);

        fieldSet.add(new TextField("name"));

        // Add some parameters to the parametrized submit link
        paramLink.setValue("myValue");
View Full Code Here


    public void demo4() {
        // Create a submit link
        final SubmitLink confirmationLink = new SubmitLink("confirmationLink");

        Form form = new Form("demo4");
        addControl(form);

        FieldSet fieldSet = new FieldSet("fieldSet");
        form.add(fieldSet);

        fieldSet.add(new TextField("name"));

        // Add the submit link to the FieldSet
        fieldSet.add(confirmationLink);

        // Set custom JavaScript for the onclick event. The confirmSubmit function
        // is defined in the page template -> submit-link-demo.htm
        String clickEvent = "return confirmSubmit(this, '" + form.getName() + "', 'Are you sure?');";
        confirmationLink.setOnClick(clickEvent);

        // The Parametrized SubmitLink action listener
        confirmationLink.setActionListener(new ActionListener() {
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 static final long serialVersionUID = 1L;

    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

    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

        // Check imports using an external Form Control
        page = new Page();
        pageImports = new PageImports(page);

        Form form = new Form("form");
        table = new FormTable("table", form);
        form.add(table);

        pageImports.processControl(form);
        headElements = pageImports.getHeadElements();
        jsElements = pageImports.getJsElements();
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("><tbody><tr><td");
            buffer.appendAttribute("align", form.getButtonAlign());
            buffer.append(">\n");
            buffer.append("<table class=\"buttons\" id=\"");
            buffer.append(getId());
            buffer.append("-buttons\"><tbody>\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

    /**
     * Initialize the FormTable.
     */
    private void init() {
        Form form = getForm();

        // TODO: this wont work, as table control links have unique name
        form.add(new HiddenField(PAGE, String.class));
        form.add(new HiddenField(COLUMN, String.class));
        form.add(new HiddenField(ASCENDING, String.class));

        // If Form is internal add it to table
        if (useInternalForm) {
            add(form);
        }
View Full Code Here

     */
    public void render(HtmlStringBuffer buffer) {

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

        super.render(buffer);
    }
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.