⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkboxmultiplepropertyselectionrenderer.java

📁 spring struts hibernate
💻 JAVA
字号:
package org.appfuse.webapp.tapestry;

import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.contrib.form.IMultiplePropertySelectionRenderer;
import org.apache.tapestry.contrib.form.MultiplePropertySelection;
import org.apache.tapestry.form.IPropertySelectionModel;

/**
 *  Implementation of {@link IMultiplePropertySelectionRenderer} that
 *  produces checkbox (<input type=checkbox>) elements with ids
 *  on the labels.
 *
 *  @author Matt Raible
 *
 **/
public class CheckBoxMultiplePropertySelectionRenderer
    implements IMultiplePropertySelectionRenderer {
    /**
     *  Writes the <table> element.
     *
     **/
    public void beginRender(MultiplePropertySelection component,
                            IMarkupWriter writer, IRequestCycle cycle) {
    }

    /**
     *  Closes the <table> element.
     *
     **/
    public void endRender(MultiplePropertySelection component,
                          IMarkupWriter writer, IRequestCycle cycle) {
    }

    public void renderOption(MultiplePropertySelection component,
                             IMarkupWriter writer, IRequestCycle cycle,
                             IPropertySelectionModel model, Object option,
                             int index, boolean selected) {
        writer.begin("input");
        writer.attribute("type", "checkbox");
        writer.attribute("name", component.getName());

        String id = component.getName() + "." + model.getValue(index);
        writer.attribute("id", id);
        writer.attribute("value", model.getValue(index));

        if (component.isDisabled()) {
            writer.attribute("disabled", "disabled");
        }

        if (selected) {
            writer.attribute("checked", "checked");
        }

        writer.end();

        writer.println();

        //writer.printRaw(" ");
        writer.begin("label");
        writer.attribute("for", id);
        writer.print(model.getLabel(index));
        writer.end(); // <label>

        //writer.printRaw("&nbsp;");

        writer.println();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -