本文整理了Java中org.apache.tiles.Definition
类的一些代码示例,展示了Definition
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Definition
类的具体详情如下:
包路径:org.apache.tiles.Definition
类名称:Definition
[英]A definition, i.e. a template with (completely or not) filled attributes. Attributes of a template can be defined with the help of this class.
It can be used as a data transfer object used for registering new definitions with the Container.
[中]定义,即具有(完全或不完全)填充属性的模板。模板的属性可以在此类的帮助下定义。
它可以用作数据传输对象,用于向容器注册新定义。
代码示例来源:origin: org.apache.tiles/com.springsource.org.apache.tiles.core
/**
* Creates a definition given its representation with wildcards.
*
* @param d The definition to replace.
* @param name The name of the definition to be created.
* @param vars The variables to be substituted.
* @return The definition that can be rendered.
* @since 2.1.0
*/
protected Definition replaceDefinition(Definition d, String name,
Map<Integer, String> vars) {
Definition nudef = new Definition();
nudef.setExtends(replace(d.getExtends(), vars));
nudef.setName(name);
nudef.setPreparer(replace(d.getPreparer(), vars));
nudef.setTemplateAttribute(replaceVarsInAttribute(d
.getTemplateAttribute(), vars));
Set<String> localAttributeNames = d.getLocalAttributeNames();
if (localAttributeNames != null && !localAttributeNames.isEmpty()) {
for (String attributeName : localAttributeNames) {
Attribute attr = d.getLocalAttribute(attributeName);
Attribute nuattr = replaceVarsInAttribute(attr, vars);
nudef.putAttribute(replace(attributeName, vars), nuattr);
}
}
return nudef;
}
代码示例来源:origin: org.springframework.webflow/spring-webflow
if (definition.getLocalAttributeNames() != null) {
attributeNames.addAll(definition.getLocalAttributeNames());
if (definition.getCascadedAttributeNames() != null) {
attributeNames.addAll(definition.getCascadedAttributeNames());
Attribute attribute = definition.getAttribute(attributeName);
if (attribute.getValue() == null || !(attribute.getValue() instanceof String)) {
continue;
代码示例来源:origin: org.apache.tiles/tiles-core
Set<String> alreadyResolvedDefinitions) {
if (!definition.isExtending()
|| alreadyResolvedDefinitions.contains(definition.getName())) {
return;
definition.getName(), definition.getExtends());
alreadyResolvedDefinitions.add(definition.getName());
Definition parent = definitions.get(definition.getExtends());
if (parent == null) { // error
String msg = "Error while resolving definition inheritance: child '"
+ definition.getName()
+ "' can't find its ancestor '"
+ definition.getExtends()
+ "'. Please check your description file.";
alreadyResolvedDefinitions);
definition.inherit(parent);
代码示例来源:origin: stackoverflow.com
Definition d = new Definition();
d.setCategory(GrammaticalCategory.ADJECTIVE);
d.setDefinition("testdefinition");
JAXB.marshal(d, new File("out.xml"));
代码示例来源:origin: org.apache.tiles/tiles-core
/** {@inheritDoc} */
@Override
public void register(Definition definition, Request request) {
Map<String, Definition> definitions = getOrCreateDefinitions(request);
if (definition.getName() == null) {
definition.setName(getNextUniqueDefinitionName(definitions));
}
if (definition.isExtending()) {
this.resolveInheritance(definition, request);
}
definitions.put(definition.getName(), definition);
}
代码示例来源:origin: org.apache.tiles/tiles-template
/**
* Creates the definition to store.
*
* @param name The name of the definition to create. If not specified, an
* anonymous definition will be created.
* @param template The template of this definition.
* @param role A comma-separated list of roles. If present, the definition
* will be rendered only if the current user belongs to one of the roles.
* @param extendsParam The definition name that this definition extends.
* @param preparer The preparer to use to invoke before the definition is
* rendered.
* @return The created definition.
*/
private Definition createDefinition(String name, String template,
String role, String extendsParam, String preparer) {
Definition definition = new Definition();
definition.setName(name);
Attribute templateAttribute = Attribute
.createTemplateAttribute(template);
templateAttribute.setRole(role);
definition.setTemplateAttribute(templateAttribute);
definition.setExtends(extendsParam);
definition.setPreparer(preparer);
return definition;
}
代码示例来源:origin: org.apache.tiles/com.springsource.org.apache.tiles.core
/** {@inheritDoc} */
public Definition getDefinition(String name,
TilesRequestContext tilesContext) {
Definition retValue;
Locale locale = null;
if (tilesContext != null) {
locale = localeResolver.resolveLocale(tilesContext);
}
retValue = definitionDao.getDefinition(name, locale);
if (retValue != null) {
retValue = new Definition(retValue);
String parentDefinitionName = retValue.getExtends();
while (parentDefinitionName != null) {
Definition parent = definitionDao.getDefinition(
parentDefinitionName, locale);
if (parent == null) {
throw new NoSuchDefinitionException("Cannot find definition '"
+ parentDefinitionName + "' ancestor of '"
+ retValue.getName() + "'");
}
retValue.inherit(parent);
parentDefinitionName = parent.getExtends();
}
}
return retValue;
}
代码示例来源:origin: org.springframework.webflow/spring-js
Map<String, Attribute> resultMap, Definition compositeDefinition, HttpServletRequest request,
HttpServletResponse response) {
Iterator<String> iterator = compositeDefinition.getAttributeNames();
while (iterator.hasNext()) {
String attributeName = iterator.next();
Attribute attribute = compositeDefinition.getAttribute(attributeName);
if (attribute.getValue() == null || !(attribute.getValue() instanceof String)) {
continue;
代码示例来源:origin: org.apache.tiles/com.springsource.org.apache.tiles.core
/**
* Validates a custom definition.
*
* @param definition The definition to validate.
*/
private void validate(Definition definition) {
Set<String> names = definition.getLocalAttributeNames();
if (names != null) {
for (String name : names) {
Attribute attribute = definition.getLocalAttribute(name);
if (attribute.getValue() == null) {
throw new IllegalArgumentException(
"Attribute '" + name + "' value not defined");
}
}
}
names = definition.getCascadedAttributeNames();
if (names != null) {
for (String name : names) {
Attribute attribute = definition.getCascadedAttribute(name);
if (attribute.getValue() == null) {
throw new IllegalArgumentException(
"Attribute '" + name + "' value not defined");
}
}
}
}
代码示例来源:origin: org.apache.tiles/com.springsource.org.apache.tiles
/**
* Add an attribute to this definition.
* <p/>
* This method is used by Digester to load definitions.
*
* @param attribute Attribute to add.
* @deprecated Use {@link Definition#putAttribute(String, Attribute)}.
*/
@Deprecated
public void addAttribute(Attribute attribute) {
putAttribute(attribute.getName(), attribute);
}
代码示例来源:origin: org.apache.tiles/tiles-core
/** {@inheritDoc} */
@Override
public void begin(String namespace, String name, Attributes attributes) {
Definition definition = (Definition) digester.peek(0);
if (definition.getName() == null) {
definition.setName(getNextUniqueDefinitionName(definitions));
}
Attribute attribute = (Attribute) digester.peek(1);
attribute.setValue(definition.getName());
attribute.setRenderer("definition");
}
}
代码示例来源:origin: org.apache.tiles/tiles-core
/**
* Adds a new <code>Definition</code> to the internal Map or replaces
* an existing one.
*
* @param definition The Definition object to be added.
*/
public void addDefinition(Definition definition) {
String name = definition.getName();
if (name == null) {
throw new DigesterDefinitionsReaderException(
"A root definition has been defined with no name");
}
definitions.put(name, definition);
}
代码示例来源:origin: org.apache.tiles/tiles-core
/**
* Copies the definition map to be passed to a higher level of customization
* key.
*
* @param localeDefsMap The map of definition to be copied.
* @return The copy of the definition map. This particular implementation
* deep-copies the <code>localeDefsMap</code> into a {@link LinkedHashMap}.
* @since 2.1.4
*/
@Override
protected Map<String, Definition> copyDefinitionMap(
Map<String, Definition> localeDefsMap) {
Map<String, Definition> retValue = new LinkedHashMap<String, Definition>(
localeDefsMap.size());
for (Map.Entry<String, Definition> entry : localeDefsMap.entrySet()) {
Definition definition = new Definition(entry.getValue());
retValue.put(entry.getKey(), definition);
}
return retValue;
}
}
代码示例来源:origin: org.apache.tiles/com.springsource.org.apache.tiles
/**
* Checks whether the <code>key</code> attribute has been set.
*
* @param key The attribute key to check.
* @return <code>true</code> if the attribute has a value.
* @deprecated Check if the {@link AttributeContext#getAttribute(String)}
* returns null.
*/
@Deprecated
public boolean hasAttributeValue(String key) {
return getAttribute(key) != null;
}
代码示例来源:origin: spring-projects/spring-webflow
public void testRenderFragment_InheritCascadedAttribute() throws Exception {
ApplicationContext tilesAppContext = new WildcardServletApplicationContext(servletContext);
Request tilesRequest = new ServletRequest(tilesAppContext, request, response);
BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(tilesAppContext);
Definition definition = container.getDefinitionsFactory().getDefinition("search.body", tilesRequest);
definition.setPreparer(AttributeTestingPreparer.class.getName());
setupStaticWebApplicationContext();
request.addHeader("Accept", DefaultAjaxHandler.AJAX_ACCEPT_CONTENT_TYPE);
request.addParameter("fragments", "body");
ajaxTilesView.setUrl("search");
ajaxTilesView.afterPropertiesSet();
ajaxTilesView.renderMergedOutputModel(new HashMap<>(), request, response);
assertTrue(AttributeTestingPreparer.invoked);
}
代码示例来源:origin: org.apache.tiles/com.springsource.org.apache.tiles.core
/** {@inheritDoc} */
@Override
public void begin(String namespace, String name, Attributes attributes)
throws Exception {
Definition definition = (Definition) digester.peek();
definition.setName(attributes.getValue("name"));
definition.setPreparer(attributes.getValue("preparer"));
definition.setExtends(attributes.getValue("extends"));
String template = attributes.getValue("template");
Attribute attribute = Attribute.createTemplateAttribute(template);
attribute.setExpression(attributes.getValue("templateExpression"));
attribute.setRole(attributes.getValue("role"));
String templateType = attributes.getValue("templateType");
if (templateType != null) {
attribute.setRenderer(templateType);
}
definition.setTemplateAttribute(attribute);
}
}
代码示例来源:origin: org.apache.tiles/tiles-core
retValue = new Definition(retValue);
String parentDefinitionName = retValue.getExtends();
while (parentDefinitionName != null) {
Definition parent = definitionDao.getDefinition(
throw new NoSuchDefinitionException("Cannot find definition '"
+ parentDefinitionName + "' ancestor of '"
+ retValue.getName() + "'");
retValue.inherit(parent);
parentDefinitionName = parent.getExtends();
代码示例来源:origin: org.thymeleaf.extras/thymeleaf-extras-tiles2-spring4
final HttpServletRequest request, final HttpServletResponse response) {
final Iterator<String> iterator = compositeDefinition.getAttributeNames();
final Attribute attribute = compositeDefinition.getAttribute(attributeName);
代码示例来源:origin: org.apache.tiles/com.springsource.org.apache.tiles.core
/**
* Adds a definition to the set of custom ones.
*
* @param definition The definition to add.
* @param request The current request.
* @throws org.apache.tiles.definition.DefinitionsFactoryException If
* something goes wrong during the addition.
*/
public void addDefinition(Definition definition,
TilesRequestContext request) {
Map<String, Definition> definitions = getOrCreateDefinitions(request);
if (definition.getName() == null) {
definition.setName(getNextUniqueDefinitionName(definitions));
}
validate(definition);
if (definition.isExtending()) {
this.resolveInheritance(definition, request);
}
definitions.put(definition.getName(), definition);
}
代码示例来源:origin: org.apache.tiles/com.springsource.org.apache.tiles
/**
* Put an attribute in template definition.
* Attribute can be used as content for tag get.
*
* @param name Attribute name
* @param content Attribute value
* @param role Determine if content is used by get tag. If user is in role, content is used.
* @deprecated Use {@link AttributeContext#putAttribute(String, Attribute)}
* or {@link AttributeContext#putAttribute(String, Attribute, boolean)}.
*/
@Deprecated
public void put(String name, Object content, String role) {
Attribute attribute = new Attribute(content, null, role, (String) null);
putAttribute(name, attribute);
}
内容来源于网络,如有侵权,请联系作者删除!