package com.corejsf.util;
import java.io.Serializable;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.webapp.UIComponentTag;
public class Tags {
public static void setString(UIComponent component, String attributeName,
String attributeValue) {
if (attributeValue == null)
return;
if (UIComponentTag.isValueReference(attributeValue))
setValueBinding(component, attributeName, attributeValue);
else
component.getAttributes().put(attributeName, attributeValue);
}
public static void setInteger(UIComponent component,
String attributeName, String attributeValue) {
if (attributeValue == null) return;
if (UIComponentTag.isValueReference(attributeValue))
setValueBinding(component, attributeName, attributeValue);
else
component.getAttributes().put(attributeName,
new Integer(attributeValue));
}
public static void setDouble(UIComponent component,
String attributeName, String attributeValue) {
if (attributeValue == null) return;
if (UIComponentTag.isValueReference(attributeValue))
setValueBinding(component, attributeName, attributeValue);
else
component.getAttributes().put(attributeName,
new Double(attributeValue));
}
public static void setBoolean(UIComponent component,
String attributeName, String attributeValue) {
if (attributeValue == null) return;
if (UIComponentTag.isValueReference(attributeValue))
setValueBinding(component, attributeName, attributeValue);
else
component.getAttributes().put(attributeName,
new Boolean(attributeValue));
}
public static void setValueBinding(UIComponent component, String attributeName,
String attributeValue) {
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
ValueBinding vb = app.createValueBinding(attributeValue);
component.setValueBinding(attributeName, vb);
}
public static void setActionListener(UIComponent component, String attributeValue) {
setMethodBinding(component, "actionListener", attributeValue,
new Class[] { ActionEvent.class });
}
public static void setValueChangeListener(UIComponent component,
String attributeValue) {
setMethodBinding(component, "valueChangeListener", attributeValue,
new Class[] { ValueChangeEvent.class });
}
public static void setValidator(UIComponent component,
String attributeValue) {
setMethodBinding(component, "validator", attributeValue,
new Class[] { FacesContext.class, UIComponent.class, Object.class });
}
public static void setAction(UIComponent component, String attributeValue) {
if (attributeValue == null) return;
if (UIComponentTag.isValueReference(attributeValue))
setMethodBinding(component, "action", attributeValue,
new Class[] {});
else {
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
MethodBinding mb = new ActionMethodBinding(attributeValue);
component.getAttributes().put("action", mb);
}
}
public static void setMethodBinding(UIComponent component, String attributeName,
String attributeValue, Class[] paramTypes) {
if (attributeValue == null)
return;
if (UIComponentTag.isValueReference(attributeValue)) {
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
MethodBinding mb = app.createMethodBinding(attributeValue, paramTypes);
component.getAttributes().put(attributeName, mb);
}
}
public static String eval(String expression) {
if (expression == null) return null;
if (UIComponentTag.isValueReference(expression)) {
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
return "" + app.createValueBinding(expression).getValue(context);
}
else return expression;
}
public static Integer evalInteger(String expression) {
if (expression == null) return null;
if (UIComponentTag.isValueReference(expression)) {
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
Object r = app.createValueBinding(expression).getValue(context);
if (r == null) return null;
else if (r instanceof Integer) return (Integer) r;
else return new Integer(r.toString());
}
else return new Integer(expression);
}
public static Double evalDouble(String expression) {
if (expression == null) return null;
if (UIComponentTag.isValueReference(expression)) {
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
Object r = app.createValueBinding(expression).getValue(context);
if (r == null) return null;
else if (r instanceof Double) return (Double) r;
else return new Double(r.toString());
}
else return new Double(expression);
}
public static Boolean evalBoolean(String expression) {
if (expression == null) return null;
if (UIComponentTag.isValueReference(expression)) {
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
Object r = app.createValueBinding(expression).getValue(context);
if (r == null) return null;
else if (r instanceof Boolean) return (Boolean) r;
else return new Boolean(r.toString());
}
else return new Boolean(expression);
}
private static class ActionMethodBinding
extends MethodBinding implements Serializable {
private String result;
public ActionMethodBinding(String result) { this.result = result; }
public Object invoke(FacesContext context, Object params[]) {
return result;
}
public String getExpressionString() { return result; }
public Class getType(FacesContext context) { return String.class; }
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
JSF分页组件
共24个文件
jar:9个
class:5个
java:4个
需积分: 10 6 下载量 115 浏览量
2008-08-21
11:14:58
上传
评论
收藏 1.75MB ZIP 举报
温馨提示
JSF分页组件,JSF分页组件
资源详情
资源评论
资源推荐
收起资源包目录
page.zip (24个子文件)
page
WEB-INF
pager.tld 817B
web.xml 618B
faces-config.xml 697B
lib
commons-logging.jar 31KB
commons-digester.jar 107KB
commons-beanutils.jar 116KB
jstl.jar 21KB
jsf-api.jar 356KB
jsf-impl.jar 682KB
mm.mysql-2.0.14-bin.jar 123KB
commons-collections.jar 167KB
standard.jar 355KB
classes
com
corejsf
PagerTag.java 1KB
BackingBean.class 395B
PagerTag.class 1KB
PagerRenderer.java 6KB
BackingBean.java 162B
PagerRenderer.class 5KB
util
Tags.class 4KB
Tags$ActionMethodBinding.class 762B
Tags.java 7KB
index.jsp 770B
index.html 238B
styles.css 55B
共 24 条
- 1
xsglovelgx
- 粉丝: 1
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 高等数学第一章第二节数列的极限
- Python 版冒泡排序算法源代码
- tensorflow-gpu-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-2.7.3-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-2.7.2-cp39-cp39-manylinux2010-x86-64.whl
- Python版本快速排序源代码
- Python 语言版的快速排序算法实现
- 450815388207377安卓_base.apk
- 超微主板 X9DRE-TF+ bios 支持 nvme启动
- 基于Python通过下载气象数据和插值拟合离散数据曲线实现对寒潮过程的能量分析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0