diff --git a/plugins/javatemplates/pom.xml b/plugins/javatemplates/pom.xml
new file mode 100644
index 000000000..79745517e
--- /dev/null
+++ b/plugins/javatemplates/pom.xml
@@ -0,0 +1,59 @@
+
+
+ 4.0.0
+
+ org.apache.struts
+ struts2-plugins
+ 2.1.3-SNAPSHOT
+
+ org.apache.struts
+ struts2-javatemplates-plugin
+ jar
+ Struts 2 Java Templates Plugin
+
+
+ scm:svn:http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-javatemplates-plugin/
+ scm:svn:https://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-javatemplates-plugin/
+ http://svn.apache.org/viewcvs.cgi/struts/sandbox/trunk/struts2-javatemplates-plugin/
+
+
+
+
+ junit
+ junit
+ test
+ 3.8.1
+
+
+ org.easymock
+ easymock
+ test
+ 2.2
+
+
+ org.easymock
+ easymockclassextension
+ test
+ 2.2
+
+
+
+
+
+
+ true
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Attributes.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Attributes.java
new file mode 100644
index 000000000..e429948ca
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Attributes.java
@@ -0,0 +1,112 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+import com.opensymphony.xwork2.util.TextUtils;
+
+import java.util.LinkedHashMap;
+
+/**
+ * Map of tag attributes, used for rendering the tags
+ */
+public class Attributes extends LinkedHashMap {
+
+ public Attributes add(String key, String value) {
+ return add(key, value, true);
+ }
+
+ public Attributes add(String key, String value, boolean encode) {
+ put(key, (encode ? TextUtils.htmlEncode(value) : value));
+ return this;
+ }
+
+ /**
+ * Add a key/value pair to the attributes only if the value is not null. Value
+ * is html encoded
+ * @param attrName attribute name
+ * @param paramValue value of attribute
+ * @return this
+ */
+ public Attributes addIfExists(String attrName, Object paramValue) {
+ return addIfExists(attrName, paramValue, true);
+ }
+
+ /**
+ * Add a key/value pair to the attributes only if the value is not null.
+ * @param attrName attribute name
+ * @param paramValue value of attribute
+ * @param encode html encode the value
+ * @return this
+ */
+ public Attributes addIfExists(String attrName, Object paramValue, boolean encode) {
+ if (paramValue != null) {
+ String val = paramValue.toString();
+ if (val.trim().length() > 0)
+ put(attrName, (encode ? TextUtils.htmlEncode(val) : val));
+ }
+ return this;
+ }
+
+ /**
+ * Add a key/value pair to the attributes only if the value is not null and is a boolean with a
+ * value of 'true'. Value is html encoded
+ * @param attrName attribute name
+ * @param paramValue value of attribute
+ * @return this
+ */
+ public Attributes addIfTrue(String attrName, Object paramValue) {
+ if (paramValue != null) {
+ if ((paramValue instanceof Boolean && ((Boolean) paramValue).booleanValue()) ||
+ (Boolean.valueOf(paramValue.toString()).booleanValue())) {
+ put(attrName, attrName);
+ }
+ }
+ return this;
+ }
+
+ /**
+ * Add a key/value pair to the attributes, if the value is null, it will be set as an empty string.
+ * Value is html encoded.
+ * @param attrName attribute name
+ * @param paramValue value of attribute
+ * @return this
+ */
+ public Attributes addDefaultToEmpty(String attrName, Object paramValue) {
+ return addDefaultToEmpty(attrName, paramValue, true);
+ }
+
+ /**
+ * Add a key/value pair to the attributes, if the value is null, it will be set as an empty string.
+ * @param attrName attribute name
+ * @param paramValue value of attribute
+ * @param encode html encode the value
+ * @return this
+ */
+ public Attributes addDefaultToEmpty(String attrName, Object paramValue, boolean encode) {
+ if (paramValue != null) {
+ String val = paramValue.toString();
+ put(attrName, (encode ? TextUtils.htmlEncode(val) : val));
+ } else {
+ put(attrName, "");
+ }
+ return this;
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTagHandlerFactory.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTagHandlerFactory.java
new file mode 100644
index 000000000..7e932aaa1
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTagHandlerFactory.java
@@ -0,0 +1,51 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
+/**
+ * Default implementation of TagHandlerFactory
+ */
+public class DefaultTagHandlerFactory implements TagHandlerFactory {
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultTagHandlerFactory.class);
+
+ private Class tagHandlerClass;
+
+ public DefaultTagHandlerFactory(Class tagHandlerClass) {
+ this.tagHandlerClass = tagHandlerClass;
+ }
+
+ public TagHandler create(TagHandler next) {
+ try {
+ TagHandler th = (TagHandler) tagHandlerClass.newInstance();
+ th.setNext(next);
+ return th;
+ } catch (Exception e) {
+ if (LOG.isErrorEnabled())
+ LOG.error("Failed to instantiate tag handler class [#0]", e, tagHandlerClass.getName());
+ }
+
+ return null;
+ }
+
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTheme.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTheme.java
new file mode 100644
index 000000000..98ba4c79a
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTheme.java
@@ -0,0 +1,85 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+import org.apache.struts2.StrutsException;
+import org.apache.struts2.components.template.TemplateRenderingContext;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
+/**
+ * Default implementation of the theme
+ */
+public class DefaultTheme implements Theme {
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultTheme.class);
+
+ private String name;
+ private Map> handlerFactories;
+
+ protected void setName(String name) {
+ this.name = name;
+ }
+
+ protected void setHandlerFactories(Map> handlers) {
+ this.handlerFactories = handlers;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void renderTag(String tagName, TemplateRenderingContext context) {
+ if (tagName.endsWith(".java")) {
+ tagName = tagName.substring(0, tagName.length() - ".java".length());
+ }
+
+ List handlers = new ArrayList();
+ List factories = handlerFactories.get(tagName);
+ if (factories == null) {
+ throw new StrutsException("Unable to find handlers for tag " + tagName);
+ }
+
+ TagHandler prev = null;
+ for (int x = factories.size() - 1; x >= 0; x--) {
+ prev = factories.get(x).create(prev);
+ prev.setup(context);
+ handlers.add(0, prev);
+ }
+
+ TagSerializer ser = (TagSerializer) handlers.get(handlers.size() - 1);
+
+ TagGenerator gen = (TagGenerator) handlers.get(0);
+ try {
+ if (LOG.isTraceEnabled())
+ LOG.trace("Rendering tag [#0]", tagName);
+ gen.generate();
+ } catch (IOException ex) {
+ throw new StrutsException("Unable to write tag: " + tagName);
+ }
+ }
+
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java
new file mode 100644
index 000000000..6cbdf0014
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+import org.apache.struts2.StrutsException;
+import org.apache.struts2.components.template.BaseTemplateEngine;
+import org.apache.struts2.components.template.Template;
+import org.apache.struts2.components.template.TemplateRenderingContext;
+import org.apache.struts2.views.java.simple.SimpleTheme;
+
+import java.util.HashMap;
+
+/**
+ * Template engine that renders tags using java implementations
+ */
+public class JavaTemplateEngine extends BaseTemplateEngine {
+
+ private Themes themes = new Themes() {{
+ add(new SimpleTheme());
+ }};
+
+ @Override
+ protected String getSuffix() {
+ return "java";
+ }
+
+ public void renderTemplate(TemplateRenderingContext templateContext)
+ throws Exception {
+ Template t = templateContext.getTemplate();
+ Theme theme = themes.get(t.getTheme());
+ if (theme == null) {
+ throw new StrutsException("Cannot render tag [" + t.getName() + "] because theme [" + t.getTheme() + "] was not found.");
+ }
+ theme.renderTag(t.getName(), templateContext);
+ }
+
+ private class Themes {
+ private HashMap themes = new HashMap();
+
+ public void add(Theme theme) {
+ themes.put(theme.getName(), theme);
+ }
+
+ public Theme get(String name) {
+ return themes.get(name);
+ }
+ }
+
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagGenerator.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagGenerator.java
new file mode 100644
index 000000000..cbd717314
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagGenerator.java
@@ -0,0 +1,28 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+import java.io.IOException;
+
+public interface TagGenerator extends TagHandler {
+
+ public void generate() throws IOException;
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagHandler.java
new file mode 100644
index 000000000..126736383
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagHandler.java
@@ -0,0 +1,62 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+import org.apache.struts2.components.template.TemplateRenderingContext;
+
+import java.io.IOException;
+
+public interface TagHandler {
+
+ void setNext(TagHandler next);
+
+ void setup(TemplateRenderingContext context);
+
+ /**
+ * Write a tag openening, with its attributes
+ * @param name name of the tag
+ * @param attributes attributes of the tag
+ * @throws IOException
+ */
+ void start(String name, Attributes attributes) throws IOException;
+
+ /**
+ * Writes a tag close
+ * @param name name of the tag
+ * @throws IOException
+ */
+ void end(String name) throws IOException;
+
+ /**
+ * Writes to the inner text of a tag. By default the body is html encoded
+ * @param text tag body.
+ * @throws IOException
+ */
+ void characters(String text) throws IOException;
+
+ /**
+ * Writes to the inner text of a tag
+ * @param text tag body
+ * @param encode html encode the body
+ * @throws IOException
+ */
+ void characters(String text, boolean encode) throws IOException;
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagHandlerFactory.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagHandlerFactory.java
new file mode 100644
index 000000000..a0d03a621
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagHandlerFactory.java
@@ -0,0 +1,26 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+public interface TagHandlerFactory {
+
+ public TagHandler create(TagHandler next);
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagSerializer.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagSerializer.java
new file mode 100644
index 000000000..da899ae1b
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/TagSerializer.java
@@ -0,0 +1,27 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+/**
+ * Implementations of this class build the html representation of the tag
+ */
+public interface TagSerializer extends TagHandler {
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Theme.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Theme.java
new file mode 100644
index 000000000..f25df200c
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Theme.java
@@ -0,0 +1,29 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+import org.apache.struts2.components.template.TemplateRenderingContext;
+
+public interface Theme {
+ public String getName();
+
+ public void renderTag(String name, TemplateRenderingContext context);
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/XHTMLTagSerializer.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/XHTMLTagSerializer.java
new file mode 100644
index 000000000..034c9b6dd
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/XHTMLTagSerializer.java
@@ -0,0 +1,72 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+import com.opensymphony.xwork2.util.TextUtils;
+import org.apache.struts2.components.template.TemplateRenderingContext;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Write tags as XHTML
+ */
+public class XHTMLTagSerializer implements TagSerializer {
+
+ private Writer writer;
+
+ public void characters(String text) throws IOException {
+ characters(text, true);
+ }
+
+ public void characters(String text, boolean encode) throws IOException {
+ writer.write(encode ? TextUtils.htmlEncode(text) : text);
+ }
+
+ public void end(String name) throws IOException {
+ writer.write("");
+ writer.write(name);
+ writer.write(">");
+ }
+
+ public void setNext(TagHandler next) {
+ }
+
+ public void start(String name, Attributes attrs) throws IOException {
+ writer.write("<");
+ writer.write(name);
+ if (attrs != null) {
+ for (String key : attrs.keySet()) {
+ writer.write(" ");
+ writer.write(key);
+ writer.write("=\"");
+ writer.write(attrs.get(key));
+ writer.write("\"");
+ }
+ }
+
+ writer.write(">");
+ }
+
+ public void setup(TemplateRenderingContext context) {
+ this.writer = context.getWriter();
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AbstractMessageListHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AbstractMessageListHandler.java
new file mode 100644
index 000000000..d3a4525fa
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AbstractMessageListHandler.java
@@ -0,0 +1,75 @@
+/*
+ * $Id: AbstractTagHandler.java 726340 2008-12-14 02:45:05Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.util.MakeIterator;
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Base class for ActionError and ActionMessage
+ */
+public abstract class AbstractMessageListHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Object errorsObj = findValue(getListExpression());
+
+ if (errorsObj != null) {
+ Iterator itt = MakeIterator.convert(errorsObj);
+ if (itt.hasNext()) {
+ Attributes attrs = new Attributes();
+ attrs.addIfExists("style", params.get("cssStyle"))
+ .add("class", params.containsKey("cssClass") ? (String) params.get("cssClass") : getDefaultClass());
+ start("ul", attrs);
+ while (itt.hasNext()) {
+ String error = (String) itt.next();
+
+ //li for each error
+ start("li", null);
+
+ //span for error
+ start("span", null);
+ characters(error);
+ end("span");
+ end("li");
+
+ }
+ end("ul");
+ }
+ }
+ }
+
+ /*
+ * Expression used to get list from stack
+ */
+ protected abstract String getListExpression();
+
+ /*
+ * default class for UL element
+ */
+ protected abstract String getDefaultClass();
+}
+
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AbstractTagHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AbstractTagHandler.java
new file mode 100644
index 000000000..8c6e49eb6
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AbstractTagHandler.java
@@ -0,0 +1,98 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import com.opensymphony.xwork2.util.TextParseUtil;
+import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.struts2.components.template.TemplateRenderingContext;
+import org.apache.struts2.components.Component;
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagHandler;
+import org.apache.struts2.views.util.ContextUtil;
+
+import java.io.IOException;
+
+public abstract class AbstractTagHandler implements TagHandler {
+
+ protected TagHandler nextTagHandler;
+ protected TemplateRenderingContext context;
+ protected boolean altSyntax;
+
+ public void characters(String text) throws IOException {
+ characters(text, true);
+ }
+
+ public void characters(String text, boolean encode) throws IOException {
+ if (nextTagHandler != null) {
+ nextTagHandler.characters(text, encode);
+ }
+ }
+
+ public void end(String name) throws IOException {
+ if (nextTagHandler != null) {
+ nextTagHandler.end(name);
+ }
+
+ }
+
+ public void setNext(TagHandler next) {
+ this.nextTagHandler = next;
+ }
+
+ public void start(String name, Attributes a) throws IOException {
+ if (nextTagHandler != null) {
+ nextTagHandler.start(name, a);
+ }
+
+ }
+
+ public void setup(TemplateRenderingContext context) {
+ this.context = context;
+ this.altSyntax = ContextUtil.isUseAltSyntax(context.getStack().getContext());
+ processParams();
+ }
+
+ protected void processParams() {
+ }
+
+ protected String findString(String expr) {
+ return (String) findValue(expr, String.class);
+ }
+
+ protected Object findValue(String expr) {
+ if (expr == null) {
+ return null;
+ }
+
+ ValueStack stack = context.getStack();
+ return stack.findValue(Component.stripExpressionIfAltSyntax(stack, expr));
+ }
+
+ private Object findValue(String expr, Class toType) {
+ ValueStack stack = context.getStack();
+
+ if (altSyntax && toType == String.class) {
+ return TextParseUtil.translateVariables('%', expr, stack);
+ } else {
+ return stack.findValue(Component.stripExpressionIfAltSyntax(stack, expr), toType);
+ }
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ActionErrorHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ActionErrorHandler.java
new file mode 100644
index 000000000..9fefd9177
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ActionErrorHandler.java
@@ -0,0 +1,32 @@
+/*
+ * $Id: SelectHandler.java 726340 2008-12-14 02:45:05Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+public class ActionErrorHandler extends AbstractMessageListHandler {
+ protected String getListExpression() {
+ return "actionErrors";
+ }
+
+ @Override
+ protected String getDefaultClass() {
+ return "errorMessage";
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ActionMessageHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ActionMessageHandler.java
new file mode 100644
index 000000000..144242b09
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ActionMessageHandler.java
@@ -0,0 +1,12 @@
+package org.apache.struts2.views.java.simple;
+
+public class ActionMessageHandler extends AbstractMessageListHandler {
+ protected String getListExpression() {
+ return "actionMessages";
+ }
+
+ @Override
+ protected String getDefaultClass() {
+ return "actionMessage";
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java
new file mode 100644
index 000000000..63246f42a
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java
@@ -0,0 +1,51 @@
+/*
+ * $Id: SelectHandler.java 726340 2008-12-14 02:45:05Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class AnchorHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+
+ attrs.addIfExists("name", params.get("name"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("href", params.get("href"), false)
+ .addIfExists("title", params.get("title"))
+ .addIfExists("tabindex", params.get("tabindex"));
+ start("a", attrs);
+ }
+
+ public static class CloseHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ end("a");
+ }
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java
new file mode 100644
index 000000000..6556ff8bc
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java
@@ -0,0 +1,45 @@
+package org.apache.struts2.views.java.simple;
+
+import com.opensymphony.xwork2.util.TextUtils;
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class CheckboxHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+
+ String fieldValue = (String) params.get("fieldValue");
+ String id = (String) params.get("id");
+ String name = (String) params.get("name");
+ Object disabled = params.get("disabled");
+
+ attrs.add("type", "checkbox")
+ .add("name", name)
+ .add("value", fieldValue)
+ .addIfTrue("checked", params.get("nameValue"))
+ .addIfTrue("readonly", params.get("readonly"))
+ .addIfTrue("disabled", disabled)
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", id)
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"));
+ start("input", attrs);
+ end("input");
+
+ //hidden input
+ attrs = new Attributes();
+ attrs.add("type", "hidden")
+ .add("id", "__checkbox_" + TextUtils.htmlEncode(id))
+ .add("name", "__checkbox_" + TextUtils.htmlEncode(name))
+ .add("value", "__checkbox_" + TextUtils.htmlEncode(fieldValue))
+ .addIfTrue("disabled", disabled);
+ start("input", attrs);
+ end("input");
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CommonAttributesHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CommonAttributesHandler.java
new file mode 100644
index 000000000..834abb9a4
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CommonAttributesHandler.java
@@ -0,0 +1,41 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+
+import java.io.IOException;
+
+/**
+ * Adds attributes from common-attributes.ftl
+ */
+public class CommonAttributesHandler extends AbstractTagHandler {
+
+ /* (non-Javadoc)
+ * @see org.apache.struts2.views.java.simple.AbstractTagHandler#start(java.lang.String, org.apache.struts2.views.java.Attributes)
+ */
+ @Override
+ public void start(String name, Attributes a) throws IOException {
+ a.addIfExists("accesskey", context.getParameters().get("accesskey"));
+ super.start(name, a);
+ }
+
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/DivHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/DivHandler.java
new file mode 100644
index 000000000..9aa18b4f9
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/DivHandler.java
@@ -0,0 +1,48 @@
+/*
+ * $Id: CommonAttributesHandler.java 726340 2008-12-14 02:45:05Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class DivHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+ attrs.addIfExists("name", params.get("name"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"));
+ start("div", attrs);
+ }
+
+ public static class CloseHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ end("div");
+ }
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/EmptyHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/EmptyHandler.java
new file mode 100644
index 000000000..eb81481bc
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/EmptyHandler.java
@@ -0,0 +1,32 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+
+//does nothing
+public class EmptyHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FieldErrorHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FieldErrorHandler.java
new file mode 100644
index 000000000..27782ccd6
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FieldErrorHandler.java
@@ -0,0 +1,78 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+public class FieldErrorHandler extends AbstractTagHandler implements TagGenerator {
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Map> errors = (Map>) findValue("fieldErrors");
+ List fieldErrorFieldNames = (List) params.get("errorFieldNames");
+
+ if (fieldErrorFieldNames != null && !fieldErrorFieldNames.isEmpty()) {
+ //wrapping ul
+ Attributes attrs = new Attributes();
+ attrs.addIfExists("style", params.get("cssStyle"))
+ .add("class", params.containsKey("cssClass") ? (String) params.get("cssClass") : "errorMessage");
+ start("ul", attrs);
+
+ //iterate over field error names
+ for (String fieldErrorFieldName : fieldErrorFieldNames) {
+ List fieldErrors = errors.get(fieldErrorFieldName);
+ if (fieldErrors != null) {
+ for (String fieldError : fieldErrors) {
+ start("li", null);
+ start("span", null);
+ characters(fieldError);
+ end("span");
+ end("li");
+ }
+ }
+ }
+
+ end("ul");
+ } else if (errors != null && !errors.isEmpty()) {
+ //wrapping ul
+ Attributes attrs = new Attributes();
+ attrs.addIfExists("style", params.get("cssStyle"))
+ .add("class", params.containsKey("cssClass") ? (String) params.get("cssClass") : "errorMessage");
+ start("ul", attrs);
+
+ for (Map.Entry> errorEntry : errors.entrySet()) {
+ for (String fieldError : errorEntry.getValue()) {
+ start("li", null);
+ start("span", null);
+ characters(fieldError);
+ end("span");
+ end("li");
+ }
+ }
+
+ end("ul");
+ }
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FileHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FileHandler.java
new file mode 100644
index 000000000..af0db577b
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FileHandler.java
@@ -0,0 +1,49 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class FileHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes a = new Attributes();
+
+ a.addDefaultToEmpty("name", params.get("name"))
+ .add("type", "file")
+ .addIfExists("size", params.get("size"))
+ .addIfExists("value", params.get("nameValue"), false)
+ .addIfTrue("disabled", params.get("disabled"))
+ .addIfExists("accept", params.get("accept"))
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"));
+ super.start("input", a);
+ super.end("input");
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FormHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FormHandler.java
new file mode 100644
index 000000000..febf73403
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/FormHandler.java
@@ -0,0 +1,55 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class FormHandler extends AbstractTagHandler implements TagGenerator {
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+
+ attrs.addIfExists("name", params.get("name"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("onsubmit", params.get("onsubmit"))
+ .addIfExists("onreset", params.get("onreset"))
+ .addIfExists("action", params.get("action"))
+ .addIfExists("target", params.get("target"))
+ .addIfExists("enctype", params.get("enctype"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"))
+ .addIfExists("accept-charset", params.get("acceptcharset"));
+ attrs.add("method", params.containsKey("method") ? (String) params.get("method") : "post");
+ start("form", attrs);
+ }
+
+ public static class CloseHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ end("form");
+ }
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/HeadHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/HeadHandler.java
new file mode 100644
index 000000000..fcd0fccf3
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/HeadHandler.java
@@ -0,0 +1,49 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+import org.apache.struts2.ServletActionContext;
+
+import java.io.IOException;
+import java.util.Map;
+
+import com.opensymphony.xwork2.ActionContext;
+
+public class HeadHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+ attrs.put("type", "text/javascript");
+
+ String base = ServletActionContext.getRequest().getContextPath();
+ StringBuilder sb = new StringBuilder();
+ if (base != null)
+ sb.append(base);
+ sb.append("/struts/utils.js");
+ attrs.put("src", sb.toString());
+
+ super.start("script", attrs);
+ super.end("script");
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/HiddenHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/HiddenHandler.java
new file mode 100644
index 000000000..1a5dcd73b
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/HiddenHandler.java
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class HiddenHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes a = new Attributes();
+
+ a.addDefaultToEmpty("name", params.get("name"))
+ .add("type", "hidden")
+ .addIfExists("value", params.get("nameValue"), false)
+ .addIfTrue("disabled", params.get("disabled"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"));
+ super.start("input", a);
+ super.end("input");
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/LabelHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/LabelHandler.java
new file mode 100644
index 000000000..f739f4747
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/LabelHandler.java
@@ -0,0 +1,49 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.TagGenerator;
+import org.apache.struts2.views.java.Attributes;
+
+import java.io.IOException;
+import java.util.Map;
+
+import com.opensymphony.xwork2.util.TextUtils;
+
+public class LabelHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes a = new Attributes();
+
+ a.addDefaultToEmpty("name", params.get("name"))
+ .addIfExists("for", params.get("for"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"));
+ super.start("label", a);
+ String value = (String) params.get("nameValue");
+ if (TextUtils.stringSet(value))
+ characters(value);
+ super.end("label");
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/PasswordHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/PasswordHandler.java
new file mode 100644
index 000000000..e7011b1ad
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/PasswordHandler.java
@@ -0,0 +1,54 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.TagGenerator;
+import org.apache.struts2.views.java.Attributes;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class PasswordHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+
+ Boolean showPassword = (Boolean) params.get("showPassword");
+ if (showPassword != null && showPassword)
+ attrs.addIfExists("value", params.get("nameValue"), false);
+
+ attrs.addDefaultToEmpty("name", params.get("name"))
+ .add("type", "password")
+ .addIfExists("size", params.get("size"))
+ .addIfExists("maxlength", params.get("maxlength"))
+ .addIfTrue("disabled", params.get("disabled"))
+ .addIfTrue("readonly", params.get("readonly"))
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"));
+ super.start("input", attrs);
+ super.end("input");
+ }
+}
+
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ResetHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ResetHandler.java
new file mode 100644
index 000000000..0a6e0fe85
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ResetHandler.java
@@ -0,0 +1,60 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.TagGenerator;
+import org.apache.struts2.views.java.Attributes;
+
+import java.io.IOException;
+import java.util.Map;
+
+import com.opensymphony.xwork2.util.TextUtils;
+
+public class ResetHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+
+ boolean isButton = "button".equals(params.get("type"));
+
+ attrs.addDefaultToEmpty("name", params.get("name"))
+ .add("type", "reset")
+ .addIfExists("value", params.get("nameValue"), false)
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"));
+
+ if (!isButton)
+ attrs.addIfExists("title", params.get("title"));
+
+ super.start("input", attrs);
+ if (isButton) {
+ String label = (String) params.get("label");
+ if (TextUtils.stringSet(label))
+ characters(label);
+ }
+
+ super.end("input");
+ }
+}
+
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ScriptingEventsHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ScriptingEventsHandler.java
new file mode 100644
index 000000000..a439676ca
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ScriptingEventsHandler.java
@@ -0,0 +1,57 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Adds attributes from scripting-event.ftl
+ */
+public class ScriptingEventsHandler extends AbstractTagHandler {
+
+ /* (non-Javadoc)
+ * @see org.apache.struts2.views.java.simple.AbstractTagHandler#start(java.lang.String, org.apache.struts2.views.java.Attributes)
+ */
+ @Override
+ public void start(String name, Attributes a) throws IOException {
+ Map params = context.getParameters();
+ a.addIfExists("onclick", params.get("onclick"));
+ a.addIfExists("ondblclick", params.get("ondblclick"));
+ a.addIfExists("onmousedown", params.get("onmousedown"));
+ a.addIfExists("onmouseup", params.get("onmouseup"));
+ a.addIfExists("onmouseover", params.get("onmouseover"));
+ a.addIfExists("onmousemove", params.get("onmousemove"));
+ a.addIfExists("onmouseout", params.get("onmouseout"));
+ a.addIfExists("onfocus", params.get("onfocus"));
+ a.addIfExists("onblur", params.get("onblur"));
+ a.addIfExists("onkeypress", params.get("onkeypress"));
+ a.addIfExists("onkeydown", params.get("onkeydown"));
+ a.addIfExists("onkeyup", params.get("onkeyup"));
+ a.addIfExists("onselect", params.get("onselect"));
+ a.addIfExists("onchange", params.get("onchange"));
+
+ super.start(name, a);
+ }
+
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SelectHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SelectHandler.java
new file mode 100644
index 000000000..280dbc612
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SelectHandler.java
@@ -0,0 +1,143 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import com.opensymphony.xwork2.util.TextUtils;
+import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.struts2.components.ListUIBean;
+import org.apache.struts2.components.OptGroup;
+import org.apache.struts2.util.ContainUtil;
+import org.apache.struts2.util.MakeIterator;
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class SelectHandler extends AbstractTagHandler implements TagGenerator {
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes a = new Attributes();
+
+ Object value = params.get("nameValue");
+
+ a.addDefaultToEmpty("name", params.get("name"))
+ .addIfExists("size", params.get("size"))
+ .addIfExists("value", value, false)
+ .addIfTrue("disabled", params.get("disabled"))
+ .addIfTrue("readonly", params.get("readonly"))
+ .addIfTrue("multiple", params.get("multiple"))
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"));
+ super.start("select", a);
+
+ //options
+
+ //header
+ String headerKey = (String) params.get("headerKey");
+ String headerValue = (String) params.get("headerValue");
+ if (headerKey != null && headerValue != null) {
+ boolean selected = ContainUtil.contains(value, params.get("headerKey"));
+ writeOption(headerKey, headerValue, selected);
+ }
+
+ Object listObj = params.get("list");
+ String listKey = (String) params.get("listKey");
+ String listValue = (String) params.get("listValue");
+ ValueStack stack = this.context.getStack();
+ if (listObj != null) {
+ Iterator itt = MakeIterator.convert(listObj);
+ while (itt.hasNext()) {
+ Object item = itt.next();
+ stack.push(item);
+
+ //key
+ Object itemKey = findValue(listKey != null ? listKey : "top");
+ String itemKeyStr = TextUtils.noNull(itemKey.toString());
+ //value
+ Object itemValue = findValue(listValue != null ? listValue : "top");
+ String itemValueStr = TextUtils.noNull(itemValue.toString());
+
+ boolean selected = ContainUtil.contains(value, itemKey);
+ writeOption(itemKeyStr, itemValueStr, selected);
+
+ stack.pop();
+ }
+ }
+
+ //opt group
+ List listUIBeans = (List) params.get(OptGroup.INTERNAL_LIST_UI_BEAN_LIST_PARAMETER_KEY);
+ if (listUIBeans != null) {
+ for (ListUIBean listUIBean : listUIBeans) {
+ writeOptionGroup(listUIBean, value);
+ }
+ }
+
+ super.end("select");
+ }
+
+ private void writeOption(String value, String text, boolean selected) throws IOException {
+ Attributes attrs = new Attributes();
+ attrs.addIfExists("value", value)
+ .addIfTrue("selected", selected);
+
+ start("option", attrs);
+ characters(text);
+ end("option");
+ }
+
+ private void writeOptionGroup(ListUIBean listUIBean, Object value) throws IOException {
+ Map params = listUIBean.getParameters();
+ Attributes attrs = new Attributes();
+ attrs.addIfExists("label", params.get("label"))
+ .addIfTrue("disabled", params.get("disabled"));
+ start("optgroup", attrs);
+
+ //options
+ ValueStack stack = context.getStack();
+ Object listObj = params.get("list");
+ if (listObj != null) {
+ Iterator itt = MakeIterator.convert(listObj);
+ String listKey = (String) params.get("listKey");
+ String listValue = (String) params.get("listValue");
+ while (itt.hasNext()) {
+ Object optGroupBean = itt.next();
+ stack.push(optGroupBean);
+
+ Object tmpKey = stack.findValue(listKey != null ? listKey : "top");
+ String tmpKeyStr = TextUtils.noNull(tmpKey.toString());
+ Object tmpValue = stack.findValue(listValue != null ? listValue : "top");
+ String tmpValueStr = TextUtils.noNull(tmpValue.toString());
+ boolean selected = ContainUtil.contains(value, tmpKeyStr);
+ writeOption(tmpKeyStr, tmpValueStr, selected);
+
+ stack.pop();
+ }
+ }
+
+ end("optgroup");
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SimpleTheme.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SimpleTheme.java
new file mode 100644
index 000000000..015b577d0
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SimpleTheme.java
@@ -0,0 +1,74 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.DefaultTagHandlerFactory;
+import org.apache.struts2.views.java.DefaultTheme;
+import org.apache.struts2.views.java.TagHandlerFactory;
+import org.apache.struts2.views.java.XHTMLTagSerializer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class SimpleTheme extends DefaultTheme {
+
+ public SimpleTheme() {
+ setHandlerFactories(new HashMap>() {{
+ put("text", new FactoryList(TextFieldHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("textfield", new FactoryList(TextFieldHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("select", new FactoryList(SelectHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("form", new FactoryList(FormHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("form-close", new FactoryList(FormHandler.CloseHandler.class));
+ put("a", new FactoryList(AnchorHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("a-close", new FactoryList(AnchorHandler.CloseHandler.class));
+ put("checkbox", new FactoryList(CheckboxHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("file", new FactoryList(FileHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("password", new FactoryList(PasswordHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("label", new FactoryList(LabelHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("reset", new FactoryList(ResetHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("submit", new FactoryList(SubmitHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("submit-close", new FactoryList(SubmitHandler.CloseHandler.class));
+ put("textarea", new FactoryList(TextAreaHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("actionerror", new FactoryList(ActionErrorHandler.class));
+ put("token", new FactoryList(TokenHandler.class));
+ put("actionmessage", new FactoryList(ActionMessageHandler.class));
+ put("head", new FactoryList(HeadHandler.class));
+ put("hidden", new FactoryList(HiddenHandler.class));
+ put("fielderror", new FactoryList(FieldErrorHandler.class));
+ put("div", new FactoryList(DivHandler.class, ScriptingEventsHandler.class, CommonAttributesHandler.class));
+ put("div-close", new FactoryList(DivHandler.CloseHandler.class));
+ put("empty", new FactoryList(EmptyHandler.class));
+ }});
+ setName("simple");
+ }
+
+ private class FactoryList extends ArrayList {
+ public FactoryList(Class... classes) {
+ super();
+ for (Class cls : classes) {
+ add(new DefaultTagHandlerFactory(cls));
+ }
+ add(new DefaultTagHandlerFactory(XHTMLTagSerializer.class));
+ }
+ }
+
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SubmitHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SubmitHandler.java
new file mode 100644
index 000000000..b2f90eab5
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SubmitHandler.java
@@ -0,0 +1,98 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.TagGenerator;
+import org.apache.struts2.views.java.Attributes;
+
+import java.io.IOException;
+import java.util.Map;
+
+import com.opensymphony.xwork2.util.TextUtils;
+
+public class SubmitHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+
+ String type = TextUtils.noNull((String) params.get("type"), "input");
+
+ if ("button".equals(type)) {
+ attrs.addIfExists("name", params.get("name"))
+ .add("type", "submit")
+ .addIfExists("value", params.get("nameValue"), false)
+ .addIfTrue("disabled", params.get("disabled"))
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"));
+
+ start("button", attrs);
+ } else if ("image".equals(type)) {
+ attrs.addIfExists("src", params.get("src"), false)
+ .add("type", "image")
+ .addIfExists("alt", params.get("label"));
+
+ start("input", attrs);
+ } else {
+ attrs.addIfExists("name", params.get("name"))
+ .add("type", "submit")
+ .addIfExists("value", params.get("nameValue"), false)
+ .addIfTrue("disabled", params.get("disabled"))
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"));
+
+ start("input", attrs);
+ }
+ }
+
+ public static class CloseHandler extends AbstractTagHandler implements TagGenerator {
+ @Override
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+ String body = (String) params.get("body");
+
+ String type = TextUtils.noNull((String) params.get("type"), "input");
+ if ("button".equals(type)) {
+ //button body
+ if (TextUtils.stringSet(body))
+ characters(body, false);
+ else if (params.containsKey("label")) {
+ String label = (String) params.get("label");
+ if (TextUtils.stringSet(label))
+ characters(label, false);
+ }
+ end("button");
+ } else if ("image".equals(type)) {
+ if (TextUtils.stringSet(body))
+ characters(body, false);
+ end("input");
+ } else
+ end("input");
+ }
+ }
+}
+
+
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TextAreaHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TextAreaHandler.java
new file mode 100644
index 000000000..554868f67
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TextAreaHandler.java
@@ -0,0 +1,54 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.TagGenerator;
+import org.apache.struts2.views.java.Attributes;
+
+import java.io.IOException;
+import java.util.Map;
+
+import com.opensymphony.xwork2.util.TextUtils;
+
+public class TextAreaHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+
+ attrs.addDefaultToEmpty("name", params.get("name"))
+ .addDefaultToEmpty("cols", params.get("cols"))
+ .addDefaultToEmpty("rows", params.get("rows"))
+ .addIfExists("wrap", params.get("wrap"))
+ .addIfTrue("disabled", params.get("disabled"))
+ .addIfTrue("readonly", params.get("readonly"))
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"));
+ start("textarea", attrs);
+ String value = (String) params.get("nameValue");
+ if (TextUtils.stringSet(value))
+ characters(value);
+ end("textarea");
+ }
+}
\ No newline at end of file
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TextFieldHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TextFieldHandler.java
new file mode 100644
index 000000000..d7cdd7ce4
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TextFieldHandler.java
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.Attributes;
+import org.apache.struts2.views.java.TagGenerator;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class TextFieldHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attr = new Attributes();
+
+ attr.add("type", "text")
+ .addDefaultToEmpty("name", params.get("name"))
+ .addIfExists("size", params.get("size"))
+ .addIfExists("maxlength", params.get("maxlength"))
+ .addIfExists("value", params.get("nameValue"), false)
+ .addIfTrue("disabled", params.get("disabled"))
+ .addIfTrue("readonly", params.get("readonly"))
+ .addIfExists("tabindex", params.get("tabindex"))
+ .addIfExists("id", params.get("id"))
+ .addIfExists("class", params.get("cssClass"))
+ .addIfExists("style", params.get("cssStyle"))
+ .addIfExists("title", params.get("title"));
+ super.start("input", attr);
+ super.end("input");
+ }
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TokenHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TokenHandler.java
new file mode 100644
index 000000000..8b65ce485
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/TokenHandler.java
@@ -0,0 +1,53 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.views.java.TagGenerator;
+import org.apache.struts2.views.java.Attributes;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class TokenHandler extends AbstractTagHandler implements TagGenerator {
+
+ public void generate() throws IOException {
+ Map params = context.getParameters();
+ Attributes attrs = new Attributes();
+
+ //first input
+ attrs.add("type", "hidden")
+ .addDefaultToEmpty("name", params.get("tokenNameField"), false)
+ .addDefaultToEmpty("value", params.get("name"));
+
+ start("input", attrs);
+ end("input");
+
+ //second input
+ attrs = new Attributes();
+ attrs.add("type", "hidden")
+ .addDefaultToEmpty("name", params.get("name"), false)
+ .addDefaultToEmpty("value", params.get("token"));
+
+ start("input", attrs);
+ end("input");
+ }
+}
+
diff --git a/plugins/javatemplates/src/main/resources/struts-plugin.xml b/plugins/javatemplates/src/main/resources/struts-plugin.xml
new file mode 100644
index 000000000..028b89023
--- /dev/null
+++ b/plugins/javatemplates/src/main/resources/struts-plugin.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractCommonAttributesTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractCommonAttributesTest.java
new file mode 100644
index 000000000..4b93df858
--- /dev/null
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractCommonAttributesTest.java
@@ -0,0 +1,33 @@
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.components.UIBean;
+
+public abstract class AbstractCommonAttributesTest extends AbstractTest {
+ public void testRenderTextFieldScriptingAttrs() throws Exception {
+ UIBean tag = getUIBean();
+
+ applyScriptingAttrs(tag);
+
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ String output = writer.getBuffer().toString();
+
+ assertScriptingAttrs(output);
+ }
+
+ public void testRenderTextFieldCommonAttrs() throws Exception {
+ UIBean tag = getUIBean();
+
+
+ applyCommonAttrs(tag);
+
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ String output = writer.getBuffer().toString();
+
+ assertCommongAttrs(output);
+ }
+
+}
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractTest.java
new file mode 100644
index 000000000..b49a28ab5
--- /dev/null
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractTest.java
@@ -0,0 +1,162 @@
+package org.apache.struts2.views.java.simple;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.ValueStack;
+import junit.framework.TestCase;
+import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.components.Component;
+import org.apache.struts2.components.UIBean;
+import org.apache.struts2.components.template.Template;
+import org.apache.struts2.components.template.TemplateRenderingContext;
+import org.easymock.EasyMock;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+public abstract class AbstractTest extends TestCase {
+ private Map scriptingAttrs = new HashMap();
+ private Map commonAttrs = new HashMap();
+
+ protected SimpleTheme theme;
+
+ protected StringWriter writer;
+ protected Map map;
+
+ protected Template template;
+ protected Map stackContext;
+ protected ValueStack stack;
+ protected TemplateRenderingContext context;
+ protected HttpServletRequest request;
+ protected HttpServletResponse response;
+
+ protected abstract UIBean getUIBean() throws Exception;
+
+ protected abstract String getTagName();
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ scriptingAttrs.put("onclick", "onclick_");
+ scriptingAttrs.put("ondblclick", "ondblclick_");
+ scriptingAttrs.put("onmousedown", "onmousedown_");
+ scriptingAttrs.put("onmouseup", "onmouseup_");
+ scriptingAttrs.put("onmouseover", "onmouseover_");
+ scriptingAttrs.put("onmousemove", "onmousemove_");
+ scriptingAttrs.put("onmouseout", "onmouseout_");
+ scriptingAttrs.put("onfocus", "onfocus_");
+ scriptingAttrs.put("onblur", "onblur_");
+ scriptingAttrs.put("onkeypress", "onkeypress_");
+ scriptingAttrs.put("onkeydown", "onkeydown_");
+ scriptingAttrs.put("onkeyup", "onkeyup_");
+ scriptingAttrs.put("onselect", "onselect_");
+ scriptingAttrs.put("onchange", "onchange_");
+
+ commonAttrs.put("accesskey", "accesskey_");
+
+ theme = new SimpleTheme();
+ writer = new StringWriter();
+ map = new HashMap();
+
+ template = org.easymock.classextension.EasyMock.createMock(Template.class);
+ stack = EasyMock.createNiceMock(ValueStack.class);
+ setUpStack();
+ stackContext = new HashMap();
+
+ context = new TemplateRenderingContext(template, writer, stack, map, null);
+ stackContext.put(Component.COMPONENT_STACK, new Stack());
+
+ request = EasyMock.createNiceMock(HttpServletRequest.class);
+ EasyMock.expect(request.getContextPath()).andReturn("/some/path").anyTimes();
+ response = EasyMock.createNiceMock(HttpServletResponse.class);
+
+ EasyMock.expect(stack.getContext()).andReturn(stackContext).anyTimes();
+
+ Container container = EasyMock.createNiceMock(Container.class);
+ XWorkConverter converter = new ConverterEx();
+ EasyMock.expect(container.getInstance(String.class, StrutsConstants.STRUTS_TAG_ALTSYNTAX)).andReturn("true").anyTimes();
+ EasyMock.expect(container.getInstance(XWorkConverter.class)).andReturn(converter).anyTimes();
+ stackContext.put(ActionContext.CONTAINER, container);
+
+
+ EasyMock.replay(request);
+ EasyMock.replay(stack);
+ EasyMock.replay(container);
+
+ ActionContext.setContext(new ActionContext(stackContext));
+ ServletActionContext.setRequest(request);
+ }
+
+ protected static String s(String input) {
+ return input.replaceAll("'", "\"");
+ }
+
+ protected void expectFind(String expr, Class toClass, Object returnVal) {
+ EasyMock.expect(stack.findValue(expr, toClass)).andReturn(returnVal);
+ }
+
+ protected void expectFind(String expr, Object returnVal) {
+ EasyMock.expect(stack.findValue(expr)).andReturn(returnVal);
+ }
+
+ protected void setUpStack() {
+ //TODO setup a config with stack and all..for real
+ }
+
+ protected void applyScriptingAttrs(UIBean bean) {
+ bean.setOnclick(scriptingAttrs.get("onclick"));
+ bean.setOndblclick(scriptingAttrs.get("ondblclick"));
+ bean.setOnmousedown(scriptingAttrs.get("onmousedown"));
+ bean.setOnmouseup(scriptingAttrs.get("onmouseup"));
+ bean.setOnmouseover(scriptingAttrs.get("onmouseover"));
+ bean.setOnmousemove(scriptingAttrs.get("onmousemove"));
+ bean.setOnmouseout(scriptingAttrs.get("onmouseout"));
+ bean.setOnfocus(scriptingAttrs.get("onfocus"));
+ bean.setOnblur(scriptingAttrs.get("onblur"));
+ bean.setOnkeypress(scriptingAttrs.get("onkeypress"));
+ bean.setOnkeydown(scriptingAttrs.get("onkeydown"));
+ bean.setOnkeyup(scriptingAttrs.get("onkeyup"));
+ bean.setOnselect(scriptingAttrs.get("onselect"));
+ bean.setOnchange(scriptingAttrs.get("onchange"));
+ }
+
+ protected void applyCommonAttrs(UIBean bean) {
+ bean.setAccesskey("accesskey_");
+ }
+
+ protected void assertScriptingAttrs(String str) {
+ for (Map.Entry entry : scriptingAttrs.entrySet()) {
+ String substr = entry.getKey() + "=\"" + entry.getValue() + "\"";
+ assertTrue("String [" + substr + "] was not found in [" + str + "]", str.indexOf(substr) >= 0);
+ }
+ }
+
+ protected void assertCommongAttrs(String str) {
+ for (Map.Entry entry : commonAttrs.entrySet()) {
+ String substr = entry.getKey() + "=\"" + entry.getValue() + "\"";
+ assertTrue("String [" + substr + "] was not found in [" + str + "]", str.indexOf(substr) >= 0);
+ }
+ }
+
+ protected Object doFindValue(String expr, Class toType) {
+ Object val = stack.findValue(expr);
+
+ if (toType == String.class)
+ return val == null ? expr : val;
+ else
+ return val == null ? null : val;
+ }
+
+ //XWorkConverter doesnt have a public onstructor (the one with parameters will require mor config)
+ public class ConverterEx extends XWorkConverter {
+ public ConverterEx() {
+
+ }
+ }
+}
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/ActionErrorTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/ActionErrorTest.java
new file mode 100644
index 000000000..22eb6d6bd
--- /dev/null
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/ActionErrorTest.java
@@ -0,0 +1,92 @@
+/*
+ * $Id: Bean.java 726216 2008-12-13 14:58:16Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.components.ActionError;
+import org.apache.struts2.components.Anchor;
+import org.apache.struts2.components.UIBean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ActionErrorTest extends AbstractTest {
+ private ActionError tag;
+ private List errors;
+
+ public void testRenderActionError() {
+ tag.setCssClass("class");
+ tag.setCssStyle("style");
+
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ String output = writer.getBuffer().toString();
+ String expected = s("
");
+ assertEquals(expected, output);
+ }
+
+ public void testRenderActionErrorNoErrors() {
+ this.errors.clear();
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ String output = writer.getBuffer().toString();
+ assertEquals("", output);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ this.errors = new ArrayList();
+ this.errors.add("this clas is bad");
+ this.errors.add("baaaaad");
+
+ //errors are needed to setup stack
+ super.setUp();
+ this.tag = new ActionError(stack, request, response);
+ }
+
+ @Override
+ protected void setUpStack() {
+ super.setUpStack();
+ expectFind("actionMessages", this.errors);
+ }
+
+ @Override
+ protected UIBean getUIBean() {
+ return tag;
+ }
+
+ @Override
+ protected String getTagName() {
+ return "actionmessage";
+ }
+}
+
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java
new file mode 100644
index 000000000..d8520c4cc
--- /dev/null
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java
@@ -0,0 +1,63 @@
+/*
+ * $Id: Bean.java 726216 2008-12-13 14:58:16Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.components.Anchor;
+import org.apache.struts2.components.UIBean;
+
+public class AnchorTest extends AbstractCommonAttributesTest {
+ private Anchor tag;
+
+ public void testRenderAnchor() {
+ tag.setName("name_");
+ tag.setDisabled("true");
+ tag.setTabindex("1");
+ tag.setId("id_");
+ tag.setCssClass("class");
+ tag.setCssStyle("style");
+ tag.setTitle("title");
+ tag.setHref("http://sometest.com?ab=10");
+
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ theme.renderTag(getTagName() + "-close", context);
+ String output = writer.getBuffer().toString();
+ String expected = s("");
+ assertEquals(expected, output);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.tag = new Anchor(stack, request, response);
+ }
+
+ @Override
+ protected UIBean getUIBean() {
+ return tag;
+ }
+
+ @Override
+ protected String getTagName() {
+ return "a";
+ }
+}
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/Bean.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/Bean.java
new file mode 100644
index 000000000..f481372bc
--- /dev/null
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/Bean.java
@@ -0,0 +1,42 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+public class Bean {
+ private int intField;
+ private String stringField;
+
+ public int getIntField() {
+ return intField;
+ }
+
+ public void setIntField(int intField) {
+ this.intField = intField;
+ }
+
+ public String getStringField() {
+ return stringField;
+ }
+
+ public void setStringField(String stringField) {
+ this.stringField = stringField;
+ }
+}
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java
new file mode 100644
index 000000000..06356400c
--- /dev/null
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java
@@ -0,0 +1,82 @@
+/*
+ * $Id: Bean.java 726216 2008-12-13 14:58:16Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.components.Checkbox;
+import org.apache.struts2.components.UIBean;
+
+public class CheckboxTest extends AbstractCommonAttributesTest {
+ private Checkbox tag;
+
+ public void testRenderCheckbox() {
+ tag.setName("name_");
+ tag.setDisabled("true");
+ tag.setTabindex("1");
+ tag.setId("id_");
+ tag.setCssClass("class");
+ tag.setCssStyle("style");
+ tag.setTitle("title");
+ tag.setFieldValue("xyz");
+
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ String output = writer.getBuffer().toString();
+ String expected = s("");
+ assertEquals(expected, output);
+ }
+
+ public void testRenderCheckboxWithNameValue() {
+ tag.setName("name_");
+ tag.setValue("%{someValue}");
+ tag.setDisabled("true");
+
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ String output = writer.getBuffer().toString();
+ String expected = s("");
+ assertEquals(expected, output);
+ }
+
+ @Override
+ protected void setUpStack() {
+ super.setUpStack();
+
+ expectFind("someValue", Boolean.class, true);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ tag = new Checkbox(stack, request, response);
+ }
+
+ @Override
+ protected UIBean getUIBean() {
+ return tag;
+ }
+
+ @Override
+ protected String getTagName() {
+ return "checkbox";
+ }
+}
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/DivTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/DivTest.java
new file mode 100644
index 000000000..ff978954e
--- /dev/null
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/DivTest.java
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.components.Div;
+import org.apache.struts2.components.UIBean;
+
+public class DivTest extends AbstractCommonAttributesTest {
+ private Div tag;
+
+ public void testRenderAnchor() {
+ tag.setName("name_");
+ tag.setDisabled("true");
+ tag.setId("id_");
+ tag.setCssClass("class");
+ tag.setCssStyle("style");
+ tag.setTitle("title");
+
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ theme.renderTag(getTagName() + "-close", context);
+ String output = writer.getBuffer().toString();
+ String expected = s("");
+ assertEquals(expected, output);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.tag = new Div(stack, request, response);
+ }
+
+ @Override
+ protected UIBean getUIBean() {
+ return tag;
+ }
+
+ @Override
+ protected String getTagName() {
+ return "div";
+ }
+}
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/FieldErrorTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/FieldErrorTest.java
new file mode 100644
index 000000000..9728c5742
--- /dev/null
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/FieldErrorTest.java
@@ -0,0 +1,126 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java.simple;
+
+import org.apache.struts2.components.FieldError;
+import org.apache.struts2.components.UIBean;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.LinkedHashMap;
+
+public class FieldErrorTest extends AbstractTest {
+ private FieldError tag;
+ private Map> errors;
+ private List fieldNames;
+
+ public void testRenderFieldError() {
+ tag.setCssClass("class");
+ tag.setCssStyle("style");
+
+ tag.evaluateParams();
+ map.putAll(tag.getParameters());
+ theme.renderTag(getTagName(), context);
+ String output = writer.getBuffer().toString();
+ String expected = s("