本文整理了Java中org.apache.tiles.request.Request.getAvailableScopes
方法的一些代码示例,展示了Request.getAvailableScopes
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getAvailableScopes
方法的具体详情如下:
包路径:org.apache.tiles.request.Request
类名称:Request
方法名:getAvailableScopes
[英]Returns all available scopes. The scopes are ordered according to their lifetime, the innermost, shorter lived scope appears first, and the outermost, longer lived scope appears last. Besides, the scopes "request" and "application" always included in the list.
[中]返回所有可用的作用域。作用域是根据其生存期排序的,最里面的、寿命较短的作用域最先出现,最外面的、寿命较长的作用域最后出现。此外,范围“请求”和“应用”始终包含在列表中。
代码示例来源:origin: org.apache.tiles/tiles-request-api
/** {@inheritDoc} */
public List<String> getAvailableScopes() {
return context.getAvailableScopes();
}
}
代码示例来源: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-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-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-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();
}
代码示例来源:origin: org.apache.tiles/tiles-template
/**
* Executes the model.
*
* @param name The name of the attribute to import. If it is
* <code>null</code>, all the attributes will be imported.
* @param scope The scope into which the attribute(s) will be imported. If
* <code>null</code>, the import will go in page scope.
* @param toName The name of the attribute into which the attribute will be
* imported. To be used in conjunction to <code>name</code>. If
* <code>null</code>, the value of <code>name</code> will be used.
* @param ignore If <code>true</code>, if the attribute is not present, the
* problem will be ignored.
* @param request The request.
*/
public void execute(String name, String scope, String toName, boolean ignore, Request request) {
Map<String, Object> attributes = getImportedAttributes(
name, toName, ignore, request);
if (scope == null) {
scope = request.getAvailableScopes().get(0);
}
request.getContext(scope).putAll(attributes);
}
代码示例来源:origin: org.apache.tiles/tiles-el
/**
* Finds an object in request, session or application scope, in this order.
*
* @param context The context to use.
* @param property The property used as an attribute name.
* @return The found bean, if it exists, or <code>null</code> otherwise.
* @since 2.2.1
*/
protected Object findObjectByProperty(ELContext context, Object property) {
Object retValue = null;
Request request = (Request) context
.getContext(Request.class);
String prop = property.toString();
String[] scopes = request.getAvailableScopes().toArray(new String[0]);
int i = 0;
do {
retValue = getObject(request.getContext(scopes[i]), prop);
i++;
} while (retValue == null && i < scopes.length);
return retValue;
}
代码示例来源:origin: org.apache.tiles/tiles-el
/** {@inheritDoc} */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
Object base) {
if (base != null) {
List<FeatureDescriptor> retValue = Collections.emptyList();
return retValue.iterator();
}
List<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
Request request = (Request) context
.getContext(Request.class);
for (String scope : request.getAvailableScopes()) {
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setDisplayName(scope + "Scope");
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setName(scope + "Scope");
descriptor.setPreferred(true);
descriptor.setShortDescription("");
descriptor.setValue("type", Map.class);
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
return list.iterator();
}
内容来源于网络,如有侵权,请联系作者删除!