📄 utilvalidationdelegate.java
字号:
package com.common.util;
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;
/**
* description: ValidationDelegate的子类,当调用的分页页面出错时,报出准确的出错信息
*
* Created on 2005-8-01
* @author WuQiaoYun
*/
public class UtilValidationDelegate extends ValidationDelegate {
/**
* 调用该方法把属性值写入writer对象的标签中。
*/
public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component, IValidator validator) {
if (isInError(component)) {
writer.begin("span");
writer.attribute("class", "field-error");
}
}
/**
* Default implementation; 如果当前领域出错的话,则调用该方法,把相关的错误信息给出。
* 例如: <code>&nbsp;<font color="red">**</font></code>.
*/
public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
IValidator validator)
{
//System.out.println("aaa=========="+cycle);
/* if (isInError())
{
writer.printRaw(" ");
writer.begin("font");
writer.attribute("color", "red");
writer.print("");
// writer.print(PropertyLoader.getPptValue(Constants.RES_SECURITY_MESSAGE_FILENAME,"resource_UtilValidationDelegate_001"));
writer.end();
}*/
}
/**
* If the form component is in error, places a <font color="red"< around it.
* Note: this will only work on the render phase after a rewind, and will be confused
* if components are inside any kind of loop.
*
*/
public void writeLabelPrefix(IFormComponent component,
IMarkupWriter writer, IRequestCycle cycle) {
//System.out.println("--------------writeLabelPrefix................");
if (isInError(component)) {
writer.begin("span");
writer.attribute("class", "label-error");
}
}
/**
* Closes the <font> element,started by
* {@link #writeLabelPrefix(IFormComponent,IMarkupWriter,IRequestCycle)},
* if the form component is in error.
*
*/
public void writeLabelSuffix(IFormComponent component,
IMarkupWriter writer, IRequestCycle cycle) {
if (isInError(component)) writer.end();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -