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

📄 example11validationdelegate.java

📁 典型实用的利用tapstry、spring、hibernate、框架的实例
💻 JAVA
字号:
/*
 * Created on 2004-10-30
 * 
 * http://www.open-v.com 提供代码的维护工作
 */
package com.openv.spring.tapestry;

import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.valid.IValidator;
import org.apache.tapestry.valid.ValidationDelegate;

/**
 *Tapestry Delegate
 * 
 */
public class Example11ValidationDelegate extends ValidationDelegate {

    public void writeLabelPrefix(IFormComponent component,
            IMarkupWriter writer, IRequestCycle cycle) {
        if (isInError(component)) {
            writer.begin("span");
            writer.attribute("class", "label-error");
        }
    }

    public void writeLabelSuffix(IFormComponent component,
            IMarkupWriter writer, IRequestCycle cycle) {
        if (isInError(component)) {
            writer.end();
        }
    }

    public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
            IFormComponent component, IValidator validator) {
        if (isInError())
            writer.attribute("class", "field-error");
    }

    public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
            IFormComponent component, IValidator validator) {
        if (validator != null && validator.isRequired()) {
            writer.printRaw(" ");
            writer.begin("span");
            writer.attribute("class", "required-marker");
            writer.print("*");
            writer.end();
        }

        if (isInError()) {
            writer.printRaw(" ");
            writer.beginEmpty("img");
            writer.attribute("src", "images/field-error.png");
            writer.attribute("width", 16);
            writer.attribute("height", 16);
        }
    }

}

⌨️ 快捷键说明

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