本文整理汇总了Java中javax.el.ValueReference类的典型用法代码示例。如果您正苦于以下问题:Java ValueReference类的具体用法?Java ValueReference怎么用?Java ValueReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValueReference类属于javax.el包,在下文中一共展示了ValueReference类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValueReference
import javax.el.ValueReference; //导入依赖的package包/类
@Override
public ValueReference getValueReference(EvaluationContext ctx) {
VariableMapper varMapper = ctx.getVariableMapper();
if (varMapper == null) {
return null;
}
ValueExpression expr = varMapper.resolveVariable(this.image);
if (expr == null) {
return null;
}
return expr.getValueReference(ctx);
}
示例2: testGetValueReference
import javax.el.ValueReference; //导入依赖的package包/类
@Test
public void testGetValueReference() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
ValueExpression var =
factory.createValueExpression(beanB, TesterBeanB.class);
context.getVariableMapper().setVariable("beanB", var);
ValueExpression ve = factory.createValueExpression(
context, "${beanB.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
assertEquals("Tomcat", result);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
示例3: getValueReference
import javax.el.ValueReference; //导入依赖的package包/类
@Override
public ValueReference getValueReference(EvaluationContext ctx) {
VariableMapper varMapper = ctx.getVariableMapper();
if (varMapper == null) {
return null;
}
ValueExpression expr = varMapper.resolveVariable(this.image);
if (expr == null) {
return null;
}
return expr.getValueReference(ctx);
}
示例4: getValueReference
import javax.el.ValueReference; //导入依赖的package包/类
public ValueReference getValueReference(ELContext elContext) {
InterceptingResolver resolver = new InterceptingResolver(elContext.getELResolver());
try {
expression.setValue(decorateELContext(elContext, resolver), null);
} catch (ELException ele) {
return null;
}
ValueReference reference = resolver.getValueReference();
if (reference != null) {
Object base = reference.getBase();
if (base instanceof CompositeComponentExpressionHolder) {
ValueExpression ve = ((CompositeComponentExpressionHolder) base)
.getExpression((String) reference.getProperty());
if (ve != null) {
this.expression = ve;
reference = getValueReference(elContext);
}
}
}
return reference;
}
示例5: testGetValueReference
import javax.el.ValueReference; //导入依赖的package包/类
@Test
public void testGetValueReference() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
ValueExpression var =
factory.createValueExpression(beanB, TesterBeanB.class);
context.getVariableMapper().setVariable("beanB", var);
ValueExpression ve = factory.createValueExpression(
context, "${beanB.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
assertEquals("Tomcat", result);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
示例6: getValueReference
import javax.el.ValueReference; //导入依赖的package包/类
/**
* @since EL 2.2
*/
@Override
public ValueReference getValueReference(EvaluationContext ctx) {
// Check this is a reference to a base and a property
if (this.children.length > 2 &&
this.jjtGetChild(2) instanceof AstMethodParameters) {
// This is a method call
return null;
}
Target t = getTarget(ctx);
return new ValueReference(t.base, t.property);
}
示例7: getValueReference
import javax.el.ValueReference; //导入依赖的package包/类
/**
* @since EL 2.2
*/
@Override
public ValueReference getValueReference(ELContext context) {
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
this.varMapper);
return this.getNode().getValueReference(ctx);
}
示例8: testGetValueReferenceVariable
import javax.el.ValueReference; //导入依赖的package包/类
@Test
public void testGetValueReferenceVariable() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
ValueExpression var =
factory.createValueExpression(beanB, TesterBeanB.class);
context.getVariableMapper().setVariable("beanB", var);
ValueExpression var2 = factory.createValueExpression(
context, "${beanB.name}", String.class);
context.getVariableMapper().setVariable("foo", var2);
ValueExpression ve = factory.createValueExpression(
context, "${foo}", ValueExpression.class);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
示例9: testBug49345
import javax.el.ValueReference; //导入依赖的package包/类
@Test
public void testBug49345() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanA beanA = new TesterBeanA();
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
beanA.setBean(beanB);
ValueExpression var =
factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("beanA", var);
ValueExpression ve = factory.createValueExpression(
context, "${beanA.bean.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
assertEquals("Tomcat", result);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
示例10: getValueReference
import javax.el.ValueReference; //导入依赖的package包/类
/**
* @since EL 2.2
*/
@Override
public ValueReference getValueReference(EvaluationContext ctx) {
// Check this is a reference to a base and a property
if (this.children.length > 2 && this.jjtGetChild(2) instanceof AstMethodParameters) {
// This is a method call
return null;
}
Target t = getTarget(ctx);
return new ValueReference(t.base, t.property);
}
示例11: readAnnotations
import javax.el.ValueReference; //导入依赖的package包/类
/**
* Which annotations are given to an object described by an EL expression?
*
* @param p_expression
* EL expression of the JSF bean attribute
* @return null if there are no annotations, or if they cannot be accessed
*/
public static Annotation[] readAnnotations(ValueExpression p_expression, UIComponent p_component) {
FacesContext context = FacesContext.getCurrentInstance();
ELContext elContext = context.getELContext();
try {
ValueReference valueReference = p_expression.getValueReference(elContext);
Object base;
if (null == valueReference) {
base = evaluteBaseForMojarra(elContext, p_expression);
} else {
base = valueReference.getBase();
}
if (null == base) {
return null;
}
Field declaredField = getField(base, p_expression.getExpressionString());
if (null != declaredField) {
return declaredField.getAnnotations();
}
Method getter = getGetter(base, p_expression.getExpressionString());
if (null != getter) {
return getter.getAnnotations();
}
} catch (PropertyNotFoundException ex) {
// this happens if a bean is null. That's a legal state, so suffice it to return no annotation.
}
return null;
}
示例12: setValue
import javax.el.ValueReference; //导入依赖的package包/类
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
if (base != null && property != null) {
context.setPropertyResolved(true);
valueReference = new ValueReference(base, property.toString());
}
}
示例13: testBug49345
import javax.el.ValueReference; //导入依赖的package包/类
@Test
public void testBug49345() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanA beanA = new TesterBeanA();
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
beanA.setBean(beanB);
ValueExpression var =
factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("beanA", var);
ValueExpression ve = factory.createValueExpression(
context, "${beanA.bean.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
assertEquals("Tomcat", result);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
示例14: getValueReference
import javax.el.ValueReference; //导入依赖的package包/类
/**
* @since EL 2.2
*/
@Override
public ValueReference getValueReference(EvaluationContext ctx) {
return null;
}