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);
        optionsForm.add(fieldSet);

View Full Code Here


        super.onInit();

        // The checkbox tree needs to be placed inside a form so all the
        // checkbox values can be submitted to the server when we submit
        // the form.
        form = new Form("form");

        //Create the tree and tree model and add it to the page
        tree = buildTree();
        tree.addListener(this);
View Full Code Here

    /**
     * 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

        field.setName(getName() + "_" + rowIndex);

        if (getTable() instanceof FormTable) {
            FormTable formTable = (FormTable) getTable();
            Form form = formTable.getForm();

            if (formTable.getRenderSubmittedValues()
                && form.isFormSubmission()) {

                field.onProcess();

                if (field.getError() != null) {
                    field.setTitle(field.getError());
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

    /**
     * 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) {
            addControl(form);
        }
View Full Code Here

     * Sanity checks for ClickUtils.copyFormToObject.
     */
    public void testCopyFormToObject() {

      // set up the form
        Form form = new Form("sample");
       
        TextField idField = new TextField("id");
        form.add(idField);

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

        TextField nameField = new TextField("name");
        fieldset.add(nameField);

        TextField dateField = new TextField("dateOfBirth");
        fieldset.add(dateField);
       
        TextField intField = new TextField("int");
        form.add(intField);

        TextField doubleField = new TextField("double");
        form.add(doubleField);
              
        Checkbox checkBox = new Checkbox("boolean");
        form.add(checkBox)
       
        TextField telephoneField = new TextField("telephone");
        form.add(telephoneField);
       
        HiddenField hidden = new HiddenField("hidden", String.class);
        form.add(hidden);
       
        // Populate fields
        idField.setValueObject(ID);
        nameField.setValue(NAME);
        dateField.setValueObject(DATE_OF_BIRTH);
        intField.setValue(String.valueOf(INT));
        doubleField.setValue(String.valueOf(DOUBLE));
        checkBox.setChecked(BOOLEAN);
        telephoneField.setValue(TELEPHONE);

        // copy form to object
        SampleObject sampleObject = new SampleObject();
        ClickUtils.copyFormToObject(form, sampleObject, true);

        // has the object been configured correctly?
        assertEquals(new Integer(idField.getValue()), sampleObject.getId());
        assertEquals(nameField.getValue(), sampleObject.getName());
       
        //NOTE the dateField was NOT copied to the sampleObject's Date property.
        //Use org.apache.click.extras.control.DateField in the extras project, to
        //copy a Date property.
        assertEquals(null, sampleObject.getDateOfBirth());
        assertEquals(telephoneField.getValueObject().toString(), sampleObject.getTelephone());
        assertTrue(sampleObject.getInt() == new Integer(intField.getValue()).intValue());
        assertTrue(sampleObject.getDouble() == new Double(doubleField.getValue()).doubleValue());
        assertTrue(sampleObject.isBoolean() == checkBox.isChecked());
       
        // Test object path copying
       
        User user = new User();
        user.setAddress(new Address());
        user.getAddress().setState(new State());
       
        form = new Form();
        TextField codeField = new TextField("address.state.code");
        codeField.setValue("NSW");
        form.add(codeField);
        form.copyTo(user, true);
        assertEquals("NSW", user.getAddress().getState().getCode());
    }
View Full Code Here

    /**
     * Sanity checks for ClickUtils.copyObjectToForm.
     */
    public void testCopyObjectToForm() {
        // set up the form
        Form form = new Form("sample");
       
        TextField idField = new TextField("id");
        form.add(idField);

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

        TextField nameField = new TextField("name");
        fieldset.add(nameField);
       
        TextField dateField = new TextField("dateOfBirth");
        fieldset.add(dateField);
       
        TextField intField = new TextField("int");
        form.add(intField);
               
        TextField doubleField = new TextField("double");
        form.add(doubleField);
              
        Checkbox checkBox = new Checkbox("boolean");
        form.add(checkBox);
       
        HiddenField hidden = new HiddenField("hidden", String.class);
        form.add(hidden);
       
        // Populate object
        SampleObject sampleObject = new SampleObject();
        sampleObject.setId(ID);
        sampleObject.setName(NAME);
        sampleObject.setDateOfBirth(DATE_OF_BIRTH);
        sampleObject.setInt(INT);
        sampleObject.setDouble(DOUBLE);
        sampleObject.setBoolean(BOOLEAN);

        // copy object to form
        ClickUtils.copyObjectToForm(sampleObject, form, true);

        // has the form been configured correctly?
        assertEquals(sampleObject.getId(), new Integer(idField.getValue()));
        assertEquals(sampleObject.getName(), nameField.getValue());
        assertEquals(sampleObject.getDateOfBirth().toString(), dateField.getValue());
        assertTrue(sampleObject.getInt() == new Integer(intField.getValue()).intValue());
        assertTrue(sampleObject.getDouble() == new Double(doubleField.getValue()).doubleValue());
        assertTrue(sampleObject.isBoolean() == checkBox.isChecked());

        // Test object path copying

        User user = new User();
        user.setAddress(new Address());
        user.getAddress().setState(new State());
        user.getAddress().getState().setCode("NSW");
       
        form = new Form();
        TextField codeField = new TextField("address.state.code");
        form.add(codeField);
        form.copyFrom(user, true);
        assertEquals("NSW", codeField.getValueObject());
       
        Map map = new HashMap();
        map.put("name", "malcolm");
        form = new Form();
        TextField nameField2 = new TextField("name");
        form.add(nameField2);
        form.copyFrom(map, true);
        assertEquals("malcolm", nameField2.getValue());
    }
View Full Code Here

        map.put("age", age);
        map.put("address.street", street);
        map.put("address.state.code", stateCode);

        // Setup the form and fields
        Form form = new Form("form");
        TextField idField = new TextField("id");
        form.add(idField);

        // Create fieldset
        FieldSet fieldset = new FieldSet("fieldset");
        form.add(fieldset);
        TextField nameField = new TextField("name");
        fieldset.add(nameField);

        TextField ageField = new TextField("age");
        form.add(ageField);
        TextField streetField = new TextField("address.street");
        form.add(streetField);
        TextField stateCodeField = new TextField("address.state.code");
        form.add(stateCodeField);

        // Copy the map values into the fields
        form.copyFrom(map, true);

        // Test that values were copied
        assertEquals(id, new Integer(idField.getValue()));
        assertEquals(name, nameField.getValue());
        assertEquals(age, new Integer(ageField.getValue()));
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.