Author: apetrelli
Date: Thu Feb 26 21:01:16 2009
New Revision: 748298
URL: http://svn.apache.org/viewvc?rev=748298&view=rev
Log:
TILESSB-7
Finished writing Tiles2Tool.
Moved tools.xml under tiles-velocity resources.
Added:
tiles/sandbox/trunk/tiles-velocity/src/main/resources/tools.xml
- copied, changed from r747725,
tiles/sandbox/trunk/tiles-test-sandbox/src/main/webapp/WEB-INF/tools.xml
Removed:
tiles/sandbox/trunk/tiles-test-sandbox/src/main/webapp/WEB-INF/tools.xml
Modified:
tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java
tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java
Modified:
tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java?rev=748298&r1=748297&r2=748298&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java
(original)
+++
tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java
Thu Feb 26 21:01:16 2009
@@ -37,9 +37,34 @@
private static final String TILES_VELOCITY_REPOSITORY_KEY =
"org.apache.tiles.velocity.TilesVelocityRepository";
- private BodyExecutable currentBodyExecutable;
+ private BodyExecutable currentExecutable;
private TilesVelocityRepository repository;
+
+ public Tiles2Tool addAttribute(Map<String, Object> params) {
+ execute(getRepository().getAddAttribute(), params);
+ return this;
+ }
+
+ public Tiles2Tool addAttribute() {
+ currentExecutable = getRepository().getAddAttribute();
+ return this;
+ }
+
+ public Tiles2Tool addListAttribute() {
+ currentExecutable = getRepository().getAddListAttribute();
+ return this;
+ }
+
+ public Tiles2Tool definition(Map<String, Object> params) {
+ execute(getRepository().getDefinition(), params);
+ return this;
+ }
+
+ public Tiles2Tool definition() {
+ currentExecutable = getRepository().getDefinition();
+ return this;
+ }
/**
* Returns a string representation of attribute value. If the attribute is
@@ -61,24 +86,81 @@
*
* @throws IOException If something goes wrong.
*/
- public Tiles2Tool getAsString() throws IOException {
- currentBodyExecutable = getRepository().getGetAsString();
+ public Tiles2Tool getAsString() {
+ currentExecutable = getRepository().getGetAsString();
+ return this;
+ }
+
+ public Tiles2Tool importAttribute(Map<String, Object> params) {
+ execute(getRepository().getImportAttribute(), params);
+ return this;
+ }
+
+ public Tiles2Tool insertAttribute(Map<String, Object> params) {
+ execute(getRepository().getInsertAttribute(), params);
+ return this;
+ }
+
+ public Tiles2Tool insertAttribute() {
+ currentExecutable = getRepository().getInsertAttribute();
+ return this;
+ }
+
+ public Tiles2Tool insertDefinition(Map<String, Object> params) {
+ execute(getRepository().getInsertDefinition(), params);
+ return this;
+ }
+
+ public Tiles2Tool insertDefinition() {
+ currentExecutable = getRepository().getInsertDefinition();
+ return this;
+ }
+
+ public Tiles2Tool insertTemplate(Map<String, Object> params) {
+ execute(getRepository().getInsertTemplate(), params);
+ return this;
+ }
+
+ public Tiles2Tool insertTemplate() {
+ currentExecutable = getRepository().getInsertTemplate();
+ return this;
+ }
+
+ public Tiles2Tool putAttribute(Map<String, Object> params) {
+ execute(getRepository().getPutAttribute(), params);
+ return this;
+ }
+
+ public Tiles2Tool putAttribute() {
+ currentExecutable = getRepository().getPutAttribute();
+ return this;
+ }
+
+ public Tiles2Tool putListAttribute() {
+ currentExecutable = getRepository().getPutListAttribute();
+ return this;
+ }
+
+ public Tiles2Tool setCurrentContainer(String containerKey) {
+ ServletUtil.setCurrentContainer(getRequest(), getServletContext(),
+ containerKey);
return this;
}
public Tiles2Tool start(Map<String, Object> params) {
- if (currentBodyExecutable == null) {
+ if (currentExecutable == null) {
throw new NullPointerException("The current model to start has not
been set");
}
- currentBodyExecutable.start(getRequest(), getResponse(),
getVelocityContext(), params);
+ currentExecutable.start(getRequest(), getResponse(),
getVelocityContext(), params);
return this;
}
public Tiles2Tool end() {
- if (currentBodyExecutable == null) {
+ if (currentExecutable == null) {
throw new NullPointerException("The current model to start has not
been set");
}
- currentBodyExecutable.end(getRequest(), getResponse(),
getVelocityContext());
+ currentExecutable.end(getRequest(), getResponse(),
getVelocityContext());
+ currentExecutable = null;
return this;
}
@@ -90,12 +172,6 @@
Attribute attribute = attributeContext.getAttribute(key);
return attribute;
}
-
- public Tiles2Tool setCurrentContainer(String containerKey) {
- ServletUtil.setCurrentContainer(getRequest(), getServletContext(),
- containerKey);
- return this;
- }
private TilesVelocityRepository getRepository() {
if (repository != null) {
Modified:
tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java?rev=748298&r1=748297&r2=748298&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java
(original)
+++
tiles/sandbox/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java
Thu Feb 26 21:01:16 2009
@@ -2,21 +2,101 @@
import javax.servlet.ServletContext;
+import org.apache.tiles.template.AddAttributeModel;
+import org.apache.tiles.template.AddListAttributeModel;
import org.apache.tiles.template.AttributeResolver;
import org.apache.tiles.template.DefaultAttributeResolver;
+import org.apache.tiles.template.DefinitionModel;
import org.apache.tiles.template.GetAsStringModel;
+import org.apache.tiles.template.ImportAttributeModel;
+import org.apache.tiles.template.InsertAttributeModel;
+import org.apache.tiles.template.InsertDefinitionModel;
+import org.apache.tiles.template.InsertTemplateModel;
+import org.apache.tiles.template.PutAttributeModel;
+import org.apache.tiles.template.PutListAttributeModel;
public class TilesVelocityRepository {
+ private AddAttributeVModel addAttribute;
+
+ private AddListAttributeVModel addListAttribute;
+
+ private DefinitionVModel definition;
+
private GetAsStringVModel getAsString;
-
+
+ private ImportAttributeVModel importAttribute;
+
+ private InsertAttributeVModel insertAttribute;
+
+ private InsertDefinitionVModel insertDefinition;
+
+ private InsertTemplateVModel insertTemplate;
+
+ private PutAttributeVModel putAttribute;
+
+ private PutListAttributeVModel putListAttribute;
+
public TilesVelocityRepository(ServletContext servletContext) {
AttributeResolver attributeResolver = new DefaultAttributeResolver();
+
+ addAttribute = new AddAttributeVModel(new AddAttributeModel());
+ addListAttribute = new AddListAttributeVModel(
+ new AddListAttributeModel());
+ definition = new DefinitionVModel(new DefinitionModel(),
servletContext);
getAsString = new GetAsStringVModel(new GetAsStringModel(
attributeResolver), servletContext);
+ importAttribute = new ImportAttributeVModel(new ImportAttributeModel(),
+ servletContext);
+ insertAttribute = new InsertAttributeVModel(new InsertAttributeModel(
+ attributeResolver), servletContext);
+ insertDefinition = new InsertDefinitionVModel(
+ new InsertDefinitionModel(), servletContext);
+ insertTemplate = new InsertTemplateVModel(new InsertTemplateModel(),
+ servletContext);
+ putAttribute = new PutAttributeVModel(new PutAttributeModel(),
+ servletContext);
+ putListAttribute = new PutListAttributeVModel(
+ new PutListAttributeModel(), servletContext);
+ }
+
+ public AddAttributeVModel getAddAttribute() {
+ return addAttribute;
+ }
+
+ public AddListAttributeVModel getAddListAttribute() {
+ return addListAttribute;
}
-
+
+ public DefinitionVModel getDefinition() {
+ return definition;
+ }
+
public GetAsStringVModel getGetAsString() {
return getAsString;
}
+
+ public ImportAttributeVModel getImportAttribute() {
+ return importAttribute;
+ }
+
+ public InsertAttributeVModel getInsertAttribute() {
+ return insertAttribute;
+ }
+
+ public InsertDefinitionVModel getInsertDefinition() {
+ return insertDefinition;
+ }
+
+ public InsertTemplateVModel getInsertTemplate() {
+ return insertTemplate;
+ }
+
+ public PutAttributeVModel getPutAttribute() {
+ return putAttribute;
+ }
+
+ public PutListAttributeVModel getPutListAttribute() {
+ return putListAttribute;
+ }
}
Copied: tiles/sandbox/trunk/tiles-velocity/src/main/resources/tools.xml (from
r747725,
tiles/sandbox/trunk/tiles-test-sandbox/src/main/webapp/WEB-INF/tools.xml)
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/resources/tools.xml?p2=tiles/sandbox/trunk/tiles-velocity/src/main/resources/tools.xml&p1=tiles/sandbox/trunk/tiles-test-sandbox/src/main/webapp/WEB-INF/tools.xml&r1=747725&r2=748298&rev=748298&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-test-sandbox/src/main/webapp/WEB-INF/tools.xml
(original)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/resources/tools.xml Thu Feb 26
21:01:16 2009
@@ -1,5 +1,4 @@
<?xml version="1.0"?>
-
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -18,14 +17,8 @@
specific language governing permissions and limitations
under the License.
-->
-
<tools>
- <data type="string" key="version" value="2.0"/>
- <!-- ordinarily the SecureLinkTool would simply replace the StrutsLinkTool
- if SSL Ext. is in use - in that case the key would be 'link' but it's
- 'slink' here to distinguish between the two. -->
<toolbox scope="request">
- <tool key="tiles" class="com.anydoby.tiles2.velocity.Tiles2Tool"/>
+ <tool key="tiles" class="org.apache.tiles.velocity.Tiles2Tool"/>
</toolbox>
-
</tools>