本文整理了Java中org.apache.tiles.request.Request.getContext
方法的一些代码示例,展示了Request.getContext
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getContext
方法的具体详情如下:
包路径:org.apache.tiles.request.Request
类名称:Request
方法名:getContext
[英]Returns a context map, given the scope name. This method always return a map for all the scope names returned by getAvailableScopes(). That map may be writable, or immutable, depending on the implementation.
[中]返回给定作用域名称的上下文映射。此方法始终为getAvailableScopes()返回的所有作用域名称返回一个映射。该映射可能是可写的,也可能是不可变的,具体取决于实现。
代码示例来源:origin: spring-projects/spring-framework
@Override
public ViewPreparer getPreparer(String name, Request context) {
WebApplicationContext webApplicationContext = (WebApplicationContext) context.getContext("request").get(
DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
if (webApplicationContext == null) {
webApplicationContext = (WebApplicationContext) context.getContext("application").get(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
if (webApplicationContext == null) {
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
}
}
return getPreparer(name, webApplicationContext);
}
代码示例来源:origin: org.springframework/spring-webmvc
@Override
public ViewPreparer getPreparer(String name, Request context) {
WebApplicationContext webApplicationContext = (WebApplicationContext) context.getContext("request").get(
DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
if (webApplicationContext == null) {
webApplicationContext = (WebApplicationContext) context.getContext("application").get(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
if (webApplicationContext == null) {
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
}
}
return getPreparer(name, webApplicationContext);
}
代码示例来源:origin: org.apache.tiles/tiles-request-api
/** {@inheritDoc} */
public Map<String, Object> getContext(String scope) {
return context.getContext(scope);
}
代码示例来源:origin: org.springframework.webflow/spring-webflow
tilesRequest.getContext("request").put(ServletRequest.FORCE_INCLUDE_ATTRIBUTE_NAME, true);
代码示例来源:origin: org.apache.tiles/tiles-core
/**
* Returns the map with custom definitions for the current request.
*
* @param request The current request.
* @return A map that connects a definition name to a definition.
*/
@SuppressWarnings("unchecked")
private Map<String, Definition> getDefinitions(
Request request) {
return (Map<String, Definition>) request.getContext("request")
.get(definitionsAttributeName);
}
代码示例来源:origin: org.apache.tiles/tiles-ognl
@Override
public Object getProperty(@SuppressWarnings("rawtypes") Map context, Object target, Object name) {
Request request = (Request) target;
String scope = (String) name;
if (scope.endsWith("Scope")) {
String scopeName = scope.substring(0, scope.length() - SCOPE_SUFFIX_LENGTH);
return request.getContext(scopeName);
}
return null;
}
代码示例来源:origin: spring-projects/spring-framework-issues
public ViewPreparer getPreparer(String name, Request context) {
WebApplicationContext webApplicationContext = (WebApplicationContext) context.getContext("request").get(
DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
if (webApplicationContext == null) {
webApplicationContext = (WebApplicationContext) context.getContext("application").get(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
if (webApplicationContext == null) {
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
}
}
return getPreparer(name, webApplicationContext);
}
代码示例来源:origin: org.apache.tiles/tiles-core
/**
* Returns a map of type "definition name -> definition" and, if it has not
* been defined before, creates one.
*
* @param request The current request.
* @return A map that connects a definition name to a definition.
*/
@SuppressWarnings("unchecked")
private Map<String, Definition> getOrCreateDefinitions(
Request request) {
Map<String, Definition> definitions =
(Map<String, Definition>) request.getContext("request").get(definitionsAttributeName);
if (definitions == null) {
definitions = new HashMap<String, Definition>();
request.getContext("request")
.put(definitionsAttributeName, definitions);
}
return definitions;
}
代码示例来源:origin: org.apache.tiles/tiles-api
/**
* Sets the current container to use in web pages.
*
* @param request The request to use.
* @param container The container to use as the current container.
* @since 2.1.0
*/
public static void setCurrentContainer(Request request,
TilesContainer container) {
if (container != null) {
request.getContext("request").put(CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
} else {
throw new NullPointerException("The container cannot be null");
}
}
代码示例来源:origin: org.apache.tiles/tiles-el
/** {@inheritDoc} */
@Override
public Object getValue(ELContext context, Object base, Object property) {
if (base != null) {
return null;
}
Object retValue = null;
String propertyString = (String) property;
if (property instanceof String && propertyString.endsWith("Scope")) {
Request request = (Request) context
.getContext(Request.class);
retValue = request.getContext(propertyString.substring(0,
propertyString.length() - SUFFIX_LENGTH));
}
if (retValue != null) {
context.setPropertyResolved(true);
}
return retValue;
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public ViewPreparer getPreparer(String name, Request context) {
WebApplicationContext webApplicationContext = (WebApplicationContext) context.getContext("request").get(
DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
if (webApplicationContext == null) {
webApplicationContext = (WebApplicationContext) context.getContext("application").get(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
if (webApplicationContext == null) {
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
}
}
return getPreparer(name, webApplicationContext);
}
代码示例来源:origin: org.apache.tiles/tiles-template
/**
* Returns the current compose stack, or creates a new one if not present.
*
* @param request The request.
* @return The compose stack.
* @since 3.0.0
*/
@SuppressWarnings("unchecked")
public static Deque<Object> getComposeStack(Request request) {
Map<String, Object> requestScope = request.getContext("request");
Deque<Object> composeStack = (Deque<Object>) requestScope
.get(COMPOSE_STACK_ATTRIBUTE_NAME);
if (composeStack == null) {
composeStack = new LinkedList<Object>();
requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
}
return composeStack;
}
}
代码示例来源:origin: org.apache.tiles/tiles-ognl
@Override
public Object getProperty(@SuppressWarnings("rawtypes") Map context, Object target, Object name) {
Request request = (Request) target;
String attributeName = (String) name;
for (String scopeName : request.getAvailableScopes()) {
Map<String, Object> scope = request.getContext(scopeName);
if (scope.containsKey(attributeName)) {
return scope.get(attributeName);
}
}
return null;
}
代码示例来源:origin: org.apache.tiles/tiles-ognl
@Override
public void setProperty(@SuppressWarnings("rawtypes") Map context, Object target, Object name,
Object value) {
Request request = (Request) target;
String attributeName = (String) name;
String[] availableScopes = request.getAvailableScopes().toArray(new String[0]);
for (String scopeName : availableScopes) {
Map<String, Object> scope = request.getContext(scopeName);
if (scope.containsKey(attributeName)) {
scope.put(attributeName, value);
return;
}
}
if (availableScopes.length > 0) {
request.getContext(availableScopes[0]).put(attributeName, value);
}
}
代码示例来源:origin: org.apache.tiles/tiles-core
/** {@inheritDoc} */
public Locale resolveLocale(Request request) {
Locale retValue = null;
Map<String, Object> session = request.getContext("session");
if (session != null) {
retValue = (Locale) session.get(DefaultLocaleResolver.LOCALE_KEY);
}
if (retValue == null) {
retValue = request.getRequestLocale();
}
return retValue;
}
}
代码示例来源:origin: org.apache.tiles/tiles-request-mustache
protected Map<String,Object> buildScope(Request request) {
Map<String,Object> scope = new HashMap<String,Object>();
List<String> availableScopes = request.getAvailableScopes();
for (int i = availableScopes.size() -1; i >= 0; --i) {
scope.putAll(request.getContext(availableScopes.get(i)));
}
return scope;
}
代码示例来源:origin: org.apache.tiles/tiles-ognl
@Override
public String getSourceAccessor(OgnlContext context, Object target,
Object index) {
Request request = (Request) target;
String attributeName = (String) index;
for (String scopeName : request.getAvailableScopes()) {
Map<String, Object> scope = request.getContext(scopeName);
if (scope.containsKey(attributeName)) {
return ".getContext(\"" + scopeName + "\").get(index)";
}
}
return null;
}
代码示例来源:origin: org.apache.tiles/tiles-ognl
@Override
public String getSourceSetter(OgnlContext context, Object target,
Object index) {
Request request = (Request) target;
String attributeName = (String) index;
String[] availableScopes = request.getAvailableScopes().toArray(new String[0]);
for (String scopeName : availableScopes) {
Map<String, Object> scope = request.getContext(scopeName);
if (scope.containsKey(attributeName)) {
return ".getContext(\"" + scopeName + "\").put(index, target)";
}
}
return ".getContext(\"" + availableScopes[0] + "\").put(index, target)";
}
代码示例来源:origin: org.apache.tiles/tiles-api
/**
* Returns the current container that has been set, or the default one.
*
* @param request The request to use.
* @return The current Tiles container to use in web pages.
* @since 2.1.0
*/
public static TilesContainer getCurrentContainer(Request request) {
ApplicationContext context = request.getApplicationContext();
Map<String, Object> requestScope = request.getContext("request");
TilesContainer container = (TilesContainer) requestScope.get(CURRENT_CONTAINER_ATTRIBUTE_NAME);
if (container == null) {
container = getContainer(context);
requestScope.put(CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
}
return container;
}
}
代码示例来源:origin: org.apache.tiles/tiles-el
/** {@inheritDoc} */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
Object base) {
List<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
Request request = (Request) context
.getContext(Request.class);
for (String scope : request.getAvailableScopes()) {
collectBeanInfo(request.getContext(scope), list);
}
return list.iterator();
}
内容来源于网络,如有侵权,请联系作者删除!