本文整理匯總了Java中javax.el.VariableMapper.setVariable方法的典型用法代碼示例。如果您正苦於以下問題:Java VariableMapper.setVariable方法的具體用法?Java VariableMapper.setVariable怎麽用?Java VariableMapper.setVariable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.el.VariableMapper
的用法示例。
在下文中一共展示了VariableMapper.setVariable方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doStartTagInternal
import javax.el.VariableMapper; //導入方法依賴的package包/類
@Override
protected int doStartTagInternal() throws Exception {
CodeManager codeManager = getCodeManager();
T object = getObject(codeManager, codeName, value, plainLabel);
if (StringUtils.isNotEmpty(var)) {
VariableMapper vm = pageContext.getELContext().getVariableMapper();
if (vm != null) {
vm.setVariable(var, null);
}
pageContext.setAttribute(var, object, PageContext.PAGE_SCOPE);
}
if (doesEvalBody(codeManager, codeName, value, plainLabel)) {
return EVAL_BODY_INCLUDE;
} else {
return SKIP_BODY;
}
}
示例2: _restoreContextVariables
import javax.el.VariableMapper; //導入方法依賴的package包/類
/**
* Restore the variables backed up in the {@link #_backupContextVariables(VariableMapper)}
* function.
* @param vm the current variable mapper
*/
private void _restoreContextVariables(VariableMapper vm)
{
if (_var != null)
{
vm.setVariable(_var, _previousVarExpression);
pageContext.setAttribute(_var, _previousPageContextVarValue);
}
if (_varStatus != null)
{
vm.setVariable(_varStatus, _previousVarStatusExpression);
pageContext.setAttribute(_varStatus, _previousPageContextVarStatusValue);
}
}
示例3: _updateVars
import javax.el.VariableMapper; //導入方法依賴的package包/類
/**
* Sets up the variable mapper, exposing the var and the iteration status data to EL.
* @param vm the variable mapper to modify
*/
private void _updateVars(
VariableMapper vm)
{
if (_var != null)
{
if (_items != null)
{
// Expose the var to the user. The key is used instead of the index so that changes to the
// order of items in the collection will not cause the value expression to get out of sync
// with the collection resulting in corruputed component state. This expression will be
// used inside the variable mapper that is stored in each value expression that is created
// by JSP when components in the body of the for each tag are created.
KeyedValueExpression keyExpr = new KeyedValueExpression(_items,
_currentIterationStatus.getKey());
vm.setVariable(_var, keyExpr);
}
if (_itemsWrapper != null)
{
// Put the item onto the page context
Object item = _itemsWrapper.getValue(_currentIterationStatus.getIndex());
pageContext.setAttribute(_var, item);
}
}
if (_varStatus != null)
{
// Store a new var status value expression into the variable mapper
vm.setVariable(_varStatus, new VarStatusValueExpression(
_iterationUtils.getCurrentIterationId()));
// Put the value onto the page context
pageContext.setAttribute(_varStatus, _currentIterationStatus);
}
}
示例4: populateAttributes
import javax.el.VariableMapper; //導入方法依賴的package包/類
protected void populateAttributes(String scopeObjectName, Enumeration<String> attributes,
ExpressionFactory expressionFactory, VariableMapper variables, Function<String, Object> l) {
Map<String, Object> scopeObject = new HashMap<>();
while (attributes.hasMoreElements()) {
String attribute = attributes.nextElement();
Object value = l.apply(attribute);
if (value != null) {
variables.setVariable(attribute, expressionFactory.createValueExpression(value, value.getClass()));
scopeObject.put(attribute, value);
}
}
variables.setVariable(scopeObjectName, expressionFactory.createValueExpression(scopeObject, scopeObject.getClass()));
}
示例5: doStartTagInternal
import javax.el.VariableMapper; //導入方法依賴的package包/類
@Override
protected int doStartTagInternal() throws JspException {
Object bean = getBean(getRequestContext().getWebApplicationContext(), beanName, beanType);
VariableMapper vm = pageContext.getELContext().getVariableMapper();
if (vm != null) {
vm.setVariable(var, null);
}
pageContext.setAttribute(var, bean, PageContext.PAGE_SCOPE);
return SKIP_BODY;
}
示例6: populateVariables
import javax.el.VariableMapper; //導入方法依賴的package包/類
protected void populateVariables(ELContext context, ExpressionFactory expressionFactory, RenderSession session) {
VariableMapper variables = context.getVariableMapper();
variables.setVariable("request",
expressionFactory.createValueExpression(session.request, HttpServletRequest.class));
variables.setVariable("response",
expressionFactory.createValueExpression(session.response, HttpServletResponse.class));
// TODO: set output stream and writer
// variables.setVariable(
// "out",
// expressionFactory.createValueExpression(
// session.response.getWriter(), PrintWriter.class));
HttpSession httpSession = session.request.getSession(false);
if (httpSession != null)
variables.setVariable("session", expressionFactory.createValueExpression(httpSession, HttpSession.class));
variables.setVariable("application",
expressionFactory.createValueExpression(session.request.getServletContext(), ServletContext.class));
JspPageContextImpl pageContext = new JspPageContextImpl();
try {
pageContext.initialize(session.servlet, session.request, session.response, null, false, 0, false);
variables.setVariable("pageContext",
expressionFactory.createValueExpression(pageContext, JspPageContextImpl.class));
} catch (Exception e) {
throw new RuntimeException(e);
}
// TODO: check that servletConfig is spelled correctly
variables.setVariable("servletConfig",
expressionFactory.createValueExpression(session.servlet.getServletConfig(), ServletConfig.class));
// TODO: set page page attribute
// TODO: set exception page attribute
populateAttributes("contextScope", session.request.getServletContext().getAttributeNames(), expressionFactory,
variables, (attr) -> session.request.getServletContext().getAttribute(attr));
if (session.request.getSession() != null)
populateAttributes("sessionScope", session.request.getSession().getAttributeNames(), expressionFactory,
variables, (attr) -> session.request.getSession().getAttribute(attr));
populateAttributes("requestScope", session.request.getAttributeNames(), expressionFactory, variables,
(attr) -> session.request.getAttribute(attr));
populateAttributes("applicationScope", Collections.emptyEnumeration(), expressionFactory, variables,
null);
}