本文整理汇总了Java中javax.el.ELContext类的典型用法代码示例。如果您正苦于以下问题:Java ELContext类的具体用法?Java ELContext怎么用?Java ELContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ELContext类属于javax.el包,在下文中一共展示了ELContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getELContext
import javax.el.ELContext; //导入依赖的package包/类
@Override
public ELContext getELContext() {
if (elContext == null) {
elContext = new ELContextWrapper(rootJspCtxt.getELContext(), this);
}
return elContext;
}
示例2: bug56185
import javax.el.ELContext; //导入依赖的package包/类
@Test
public void bug56185() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanC beanC = new TesterBeanC();
ValueExpression var =
factory.createValueExpression(beanC, TesterBeanC.class);
context.getVariableMapper().setVariable("myBean", var);
ValueExpression ve = factory.createValueExpression(context,
"${(myBean.int1 > 1 and myBean.myBool) or "+
"((myBean.myBool or myBean.myBool1) and myBean.int1 > 1)}",
Boolean.class);
assertEquals(Boolean.FALSE, ve.getValue(context));
beanC.setInt1(2);
beanC.setMyBool1(true);
assertEquals(Boolean.TRUE, ve.getValue(context));
}
示例3: setValueExpression
import javax.el.ELContext; //导入依赖的package包/类
@Override
public void setValueExpression(String name,
ValueExpression expression)
{
if (name == null)
throw new NullPointerException();
if ((expression != null) && expression.isLiteralText())
{
ELContext context =
FacesContext.getCurrentInstance().getELContext();
getAttributes().put(name, expression.getValue(context));
}
else
{
PropertyKey key = getPropertyKey(name);
getFacesBean().setValueExpression(key, expression);
}
}
示例4: setValue
import javax.el.ELContext; //导入依赖的package包/类
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) throws NullPointerException,
PropertyNotFoundException, PropertyNotWritableException,
ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context
.getContext(JspContext.class);
int scope = page.getAttributesScope(key);
if (scope != 0) {
page.setAttribute(key, value, scope);
} else {
page.setAttribute(key, value);
}
}
}
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:25,代码来源:ScopedAttributeELResolver.java
示例5: setValue
import javax.el.ELContext; //导入依赖的package包/类
public void setValue(ELContext context, Object base, Object property,
Object value) throws NullPointerException,
PropertyNotFoundException, PropertyNotWritableException,
ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
throw new PropertyNotWritableException(
"Legacy VariableResolver wrapped, not writable");
}
if (!context.isPropertyResolved()) {
getDefaultResolver().setValue(context, base, property, value);
}
}
示例6: Comp
import javax.el.ELContext; //导入依赖的package包/类
public Comp(
ELResolver resolver,
ELContext context,
Locale locale,
String property,
SortStrength sortStrength)
{
_resolver = resolver;
_context = context;
// use Collator as comparator whenever locale or strength is available,
// so sorting is natural to that locale.
if (locale != null || sortStrength != null)
{
if (locale != null)
_collator = Collator.getInstance(locale);
else
_collator = Collator.getInstance();
if (sortStrength != null)
_collator.setStrength(sortStrength.getStrength());
}
else
{
_collator = null;
}
_prop = property;
}
示例7: doAction
import javax.el.ELContext; //导入依赖的package包/类
public String doAction()
{
String value = _action;
if (value != null)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ELContext context = facesContext.getELContext();
MethodExpression methodExpression =
expressionFactory.createMethodExpression(context, value,
String.class, new Class<?>[]
{});
value = (String) methodExpression.invoke(context, null);
}
// Post me as the selected Node for the request
postSelectedNode(this);
return value;
}
示例8: validateEL
import javax.el.ELContext; //导入依赖的package包/类
/**
* Allow node to validate itself
*
* @param ef
* @param ctx
* @throws ELException
*/
public void validateEL(ExpressionFactory ef, ELContext ctx)
throws ELException {
if (this.el != null) {
// determine exact type
ValueExpression ve = ef.createValueExpression(ctx, this.value,
String.class);
}
}
示例9: isReadOnly
import javax.el.ELContext; //导入依赖的package包/类
@Override
public boolean isReadOnly(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
return true;
}
return elResolver.isReadOnly(context, base, property);
}
示例10: getType
import javax.el.ELContext; //导入依赖的package包/类
@Override
public Class<?> getType(ELContext context, Object base,
Object property)
{
if (base == null)
{
Object o = getValue(context, base, property);
if (o == null)
return null;
return o.getClass();
}
else
{
if (_isIndexed(base))
return _pr.getType(base, _getIndex(property));
else
return _pr.getType(base, property);
}
}
示例11: getELContext
import javax.el.ELContext; //导入依赖的package包/类
public ELContext getELContext() {
// instead decorate!!!
return this.invokingJspCtxt.getELContext();
/*
if (this.elContext != null) {
JspFactory jspFact = JspFactory.getDefaultFactory();
ServletContext servletContext = this.getServletContext();
JspApplicationContextImpl jspCtx = (JspApplicationContextImpl) jspFact
.getJspApplicationContext(servletContext);
this.elContext = jspCtx.createELContext(this);
}
return this.elContext;
*/
}
示例12: actionListener
import javax.el.ELContext; //导入依赖的package包/类
public void actionListener(ActionEvent event)
{
String value = _actionListener;
if (value != null)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ELContext context = facesContext.getELContext();
MethodExpression methodExpression =
expressionFactory.createMethodExpression(context, value, Void.TYPE,
new Class<?>[]
{ ActionEvent.class });
methodExpression.invoke(context, new Object[]
{ event });
}
}
示例13: isReadOnly
import javax.el.ELContext; //导入依赖的package包/类
public boolean isReadOnly(ELContext context, Object base, Object property)
{
FacesContext fc = FacesContext.getCurrentInstance();
if (base == null)
{
// Can't handle this case - don't set "property resolved"
return false;
}
else
{
if (property != null)
{
context.setPropertyResolved(true);
if (property instanceof Number)
return _pr.isReadOnly(base, ((Number) property).intValue());
return _pr.isReadOnly(base, property);
}
}
return false;
}
示例14: isReadOnly
import javax.el.ELContext; //导入依赖的package包/类
@Override
public boolean isReadOnly(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
if (idx >= 0) {
context.setPropertyResolved(true);
return true;
}
}
return false;
}
示例15: testJavaKeyWordIdentifier
import javax.el.ELContext; //导入依赖的package包/类
@Test
public void testJavaKeyWordIdentifier() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanA beanA = new TesterBeanA();
beanA.setInt("five");
ValueExpression var =
factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("this", var);
// Should fail
Exception e = null;
try {
factory.createValueExpression(context, "${this}", String.class);
} catch (ELException ele) {
e = ele;
}
assertNotNull(e);
}