This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5233-tiles in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/WW-5233-tiles by this push: new b3f1c1e6d Add missing classes and tld definition. new f71e32202 Merge pull request #610 from gregh3269/WW-5233-tiles b3f1c1e6d is described below commit b3f1c1e6d267e4110176fe5617799b1b908a6abd Author: Greg Huber <ghu...@apache.org> AuthorDate: Fri Oct 7 09:57:10 2022 +0100 Add missing classes and tld definition. --- .../apache/tiles/template/GetAsStringModel.java | 9 + .../tiles/web/jsp/taglib/AddAttributeTag.java | 166 ++++ .../tiles/web/jsp/taglib/AddListAttributeTag.java | 88 ++ .../apache/tiles/web/jsp/taglib/DefinitionTag.java | 185 +++++ .../tiles/web/jsp/taglib/GetAsStringTag.java | 266 ++++++ .../tiles/web/jsp/taglib/ImportAttributeTag.java | 167 ++++ .../tiles/web/jsp/taglib/InsertAttributeTag.java | 303 +++++++ .../tiles/web/jsp/taglib/InsertDefinitionTag.java | 260 ++++++ .../tiles/web/jsp/taglib/InsertTemplateTag.java | 233 ++++++ .../tiles/web/jsp/taglib/PutAttributeTag.java | 234 ++++++ .../tiles/web/jsp/taglib/PutListAttributeTag.java | 164 ++++ .../web/jsp/taglib/SetCurrentContainerTag.java | 81 ++ .../tiles/web/jsp/taglib/UseAttributeTag.java | 21 +- .../apache/tiles/web/jsp/taglib/package-info.java | 4 +- .../resources/META-INF/tld/tiles-extras-jsp.tld | 16 +- .../src/main/resources/META-INF/tld/tiles-jsp.tld | 894 +++++++++++++++++++++ 16 files changed, 3067 insertions(+), 24 deletions(-) diff --git a/plugins/tiles/src/main/java/org/apache/tiles/template/GetAsStringModel.java b/plugins/tiles/src/main/java/org/apache/tiles/template/GetAsStringModel.java index b2d7db437..1bf1de742 100644 --- a/plugins/tiles/src/main/java/org/apache/tiles/template/GetAsStringModel.java +++ b/plugins/tiles/src/main/java/org/apache/tiles/template/GetAsStringModel.java @@ -56,6 +56,15 @@ public class GetAsStringModel { * The attribute resolver to use. */ private final AttributeResolver attributeResolver; + + /** + * Constructor that uses the defaut attribute resolver. + * + * @since 3.0.0 + */ + public GetAsStringModel() { + this(new DefaultAttributeResolver()); + } /** * Constructor. diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/AddAttributeTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/AddAttributeTag.java new file mode 100644 index 000000000..a5bd36b04 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/AddAttributeTag.java @@ -0,0 +1,166 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.AddAttributeModel; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Add an element to the surrounding list. Equivalent to 'putAttribute', but for + * list element. + * </p> + * + * <p> + * Add an element to the surrounding list. This tag can only be used inside + * 'putListAttribute' or 'addListAttribute' tags. Value can come from a direct + * assignment (value="aValue") + * </p> + */ +public class AddAttributeTag extends SimpleTagSupport { + + /** + * The template model. + */ + private AddAttributeModel model = new AddAttributeModel(); + + /** + * The value of the attribute. Use this parameter, or expression, or body. + */ + private Object value; + + /** + * The expression to calculate the value from. Use this parameter, or value, or + * body. + */ + private String expression; + + /** + * A comma-separated list of roles. If present, the attribute will be rendered + * only if the current user belongs to one of the roles. + */ + private String role; + + /** + * The type (renderer) of the attribute. + */ + private String type; + + /** + * Getter for value property. + * + * @return The value of the attribute. Use this parameter, or expression, or + * body. + */ + public Object getValue() { + return value; + } + + /** + * Setter for value property. + * + * @param value The value of the attribute. Use this parameter, or expression, + * or body. + */ + public void setValue(Object value) { + this.value = value; + } + + /** + * Getter for expression property. + * + * @return The expression to calculate the value from. Use this parameter, or + * value, or body. + */ + public String getExpression() { + return expression; + } + + /** + * Setter for expression property. + * + * @param expression The expression to calculate the value from. Use this + * parameter, or value, or body. + */ + public void setExpression(String expression) { + this.expression = expression; + } + + /** + * Getter for role property. + * + * @return A comma-separated list of roles. If present, the attribute will be + * rendered only if the current user belongs to one of the roles. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role A comma-separated list of roles. If present, the attribute will + * be rendered only if the current user belongs to one of the roles. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for type property. + * + * @return The type (renderer) of the attribute. + */ + public String getType() { + return type; + } + + /** + * Setter for type property. + * + * @param type The type (renderer) of the attribute. + */ + public void setType(String type) { + this.type = type; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(value, expression, role, type, request, modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/AddListAttributeTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/AddListAttributeTag.java new file mode 100644 index 000000000..5f17d8145 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/AddListAttributeTag.java @@ -0,0 +1,88 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.AddListAttributeModel; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Declare a list that will be pass as an attribute. + * </p> + * <p> + * Declare a list that will be pass as an attribute . List elements are added + * using the tag 'addAttribute' or 'addListAttribute'. This tag can only be used + * inside 'insertTemplate', 'insertDefinition' or 'definition' tag. + * </p> + */ +public class AddListAttributeTag extends SimpleTagSupport { + + /** + * The template model. + */ + private AddListAttributeModel model = new AddListAttributeModel(); + + /** + * The comma-separated list of roles that can use the list attribute. + */ + private String role; + + /** + * Getter for role property. + * + * @return The comma-separated list of roles that can use the list attribute. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role The comma-separated list of roles that can use the list + * attribute. + */ + public void setRole(String role) { + this.role = role; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(role, request, modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/DefinitionTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/DefinitionTag.java new file mode 100644 index 000000000..340917369 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/DefinitionTag.java @@ -0,0 +1,185 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.DefinitionModel; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Create a definition at runtime. + * </p> + * <p> + * Create a new definition at runtime. Newly created definition will be + * available across the entire request. + * </p> + */ +public class DefinitionTag extends SimpleTagSupport { + + /** + * The template model. + */ + private DefinitionModel model = new DefinitionModel(); + + /** + * The name of the definition to create. If not specified, an anonymous + * definition will be created. + */ + private String name; + + /** + * The template of this definition. + */ + private String template; + + /** + * A comma-separated list of roles. If present, the definition will be rendered + * only if the current user belongs to one of the roles. + */ + private String role; + + /** + * The definition name that this definition extends. + */ + private String extendsParam; + + /** + * The preparer to use to invoke before the definition is rendered. + */ + private String preparer; + + /** + * Getter for name property. + * + * @return The name of the definition to create. If not specified, an anonymous + * definition will be created. + */ + public String getName() { + return name; + } + + /** + * Setter for name property. + * + * @param name The name of the definition to create. If not specified, an + * anonymous definition will be created. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for template property. + * + * @return The template of this definition. + */ + public String getTemplate() { + return template; + } + + /** + * Setter for template property. + * + * @param template The template of this definition. + */ + public void setTemplate(String template) { + this.template = template; + } + + /** + * Getter for role property. + * + * @return A comma-separated list of roles. If present, the definition will be + * rendered only if the current user belongs to one of the roles. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role A comma-separated list of roles. If present, the definition will + * be rendered only if the current user belongs to one of the roles. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for extends property. + * + * @return The definition name that this definition extends. + */ + public String getExtends() { + return extendsParam; + } + + /** + * Setter for extends property. + * + * @param extendsParam The definition name that this definition extends. + */ + public void setExtends(String extendsParam) { + this.extendsParam = extendsParam; + } + + /** + * Getter for preparer property. + * + * @return The preparer to use to invoke before the definition is rendered. + */ + public String getPreparer() { + return preparer; + } + + /** + * Setter for preparer property. + * + * @param preparer The preparer to use to invoke before the definition is + * rendered. + */ + public void setPreparer(String preparer) { + this.preparer = preparer; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(name, template, role, extendsParam, preparer, request, modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/GetAsStringTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/GetAsStringTag.java new file mode 100644 index 000000000..5cd777819 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/GetAsStringTag.java @@ -0,0 +1,266 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.GetAsStringModel; +import org.apache.tiles.api.Attribute; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Render the value of the specified template attribute to the current Writer + * </p> + * + * <p> + * Retrieve the value of the specified template attribute property, and render + * it to the current Writer as a String. The usual toString() conversions is + * applied on found value. + * </p> + */ +public class GetAsStringTag extends SimpleTagSupport { + + /** + * The template model. + */ + private GetAsStringModel model = new GetAsStringModel(); + + /** + * If true, if an exception happens during rendering, of if the attribute is + * null, the problem will be ignored. + */ + private boolean ignore; + + /** + * The preparer to invoke before rendering the attribute. + */ + private String preparer; + + /** + * A comma-separated list of roles. If present, the attribute will be rendered + * only if the current user belongs to one of the roles. + */ + private String role; + + /** + * The default value of the attribute. To use only if the attribute was not + * computed. + */ + private Object defaultValue; + + /** + * The default comma-separated list of roles. To use only if the attribute was + * not computed. + */ + private String defaultValueRole; + + /** + * The default type of the attribute. To use only if the attribute was not + * computed. + */ + private String defaultValueType; + + /** + * The name of the attribute. + */ + private String name; + + /** + * The attribute to use immediately, if not null. + */ + private Attribute value; + + /** + * Getter for ignore property. + * + * @return If true, if an exception happens during rendering, of if the + * attribute is null, the problem will be ignored. + */ + public boolean isIgnore() { + return ignore; + } + + /** + * Setter for ignore property. + * + * @param ignore If true, if an exception happens during rendering, of if the + * attribute is null, the problem will be ignored. + */ + public void setIgnore(boolean ignore) { + this.ignore = ignore; + } + + /** + * Getter for preparer property. + * + * @return The preparer to invoke before rendering the attribute. + */ + public String getPreparer() { + return preparer; + } + + /** + * Setter for preparer property. + * + * @param preparer The preparer to invoke before rendering the attribute. + */ + public void setPreparer(String preparer) { + this.preparer = preparer; + } + + /** + * Getter for role property. + * + * @return A comma-separated list of roles. If present, the attribute will be + * rendered only if the current user belongs to one of the roles. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role A comma-separated list of roles. If present, the attribute will + * be rendered only if the current user belongs to one of the roles. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for defaultValue property. + * + * @return The default value of the attribute. To use only if the attribute was + * not computed. + */ + public Object getDefaultValue() { + return defaultValue; + } + + /** + * Setter for defaultValue property. + * + * @param defaultValue The default value of the attribute. To use only if the + * attribute was not computed. + */ + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } + + /** + * Getter for defaultValueRole property. + * + * @return The default comma-separated list of roles. To use only if the + * attribute was not computed. + */ + public String getDefaultValueRole() { + return defaultValueRole; + } + + /** + * Setter for defaultValueRole property. + * + * @param defaultValueRole The default comma-separated list of roles. To use + * only if the attribute was not computed. + */ + public void setDefaultValueRole(String defaultValueRole) { + this.defaultValueRole = defaultValueRole; + } + + /** + * Getter for defaultValueType property. + * + * @return The default type of the attribute. To use only if the attribute was + * not computed. + */ + public String getDefaultValueType() { + return defaultValueType; + } + + /** + * Setter for defaultValueType property. + * + * @param defaultValueType The default type of the attribute. To use only if the + * attribute was not computed. + */ + public void setDefaultValueType(String defaultValueType) { + this.defaultValueType = defaultValueType; + } + + /** + * Getter for name property. + * + * @return The name of the attribute. + */ + public String getName() { + return name; + } + + /** + * Setter for name property. + * + * @param name The name of the attribute. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for value property. + * + * @return The attribute to use immediately, if not null. + */ + public Attribute getValue() { + return value; + } + + /** + * Setter for value property. + * + * @param value The attribute to use immediately, if not null. + */ + public void setValue(Attribute value) { + this.value = value; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(ignore, preparer, role, defaultValue, defaultValueRole, defaultValueType, name, value, request, + modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/ImportAttributeTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/ImportAttributeTag.java new file mode 100644 index 000000000..3468f3865 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/ImportAttributeTag.java @@ -0,0 +1,167 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.ImportAttributeModel; + +/** + * <p> + * Import attribute(s) in specified context. + * </p> + * <p> + * Import attribute(s) to requested scope. Attribute name and scope are + * optional. If not specified, all attributes are imported in page scope. Once + * imported, an attribute can be used as any other beans from jsp contexts. + * </p> + */ +public class ImportAttributeTag extends SimpleTagSupport { + + /** + * The template model. + */ + private ImportAttributeModel model = new ImportAttributeModel(); + + /** + * The name of the attribute to import. If it is null, all the attributes will + * be imported. + */ + private String name; + + /** + * The scope into which the attribute(s) will be imported. If null, the import + * will go in page scope. + */ + private String scope; + + /** + * The name of the attribute into which the attribute will be imported. To be + * used in conjunction to name. If null, the value of name will be used. + */ + private String toName; + + /** + * If true, if the attribute is not present, the problem will be ignored. + */ + private boolean ignore; + + /** + * Getter for name property. + * + * @return The name of the attribute to import. If it is null, all the + * attributes will be imported. + */ + public String getName() { + return name; + } + + /** + * Setter for name property. + * + * @param name The name of the attribute to import. If it is null, all the + * attributes will be imported. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for scope property. + * + * @return The scope into which the attribute(s) will be imported. If null, the + * import will go in page scope. + */ + public String getScope() { + return scope; + } + + /** + * Setter for scope property. + * + * @param scope The scope into which the attribute(s) will be imported. If null, + * the import will go in page scope. + */ + public void setScope(String scope) { + this.scope = scope; + } + + /** + * Getter for toName property. + * + * @return The name of the attribute into which the attribute will be imported. + * To be used in conjunction to name. If null, the value of name will be + * used. + */ + public String getToName() { + return toName; + } + + /** + * Setter for toName property. + * + * @param toName The name of the attribute into which the attribute will be + * imported. To be used in conjunction to name. If null, the value + * of name will be used. + */ + public void setToName(String toName) { + this.toName = toName; + } + + /** + * Getter for ignore property. + * + * @return If true, if the attribute is not present, the problem will be + * ignored. + */ + public boolean isIgnore() { + return ignore; + } + + /** + * Setter for ignore property. + * + * @param ignore If true, if the attribute is not present, the problem will be + * ignored. + */ + public void setIgnore(boolean ignore) { + this.ignore = ignore; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + model.execute(name, scope, toName, ignore, request); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertAttributeTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertAttributeTag.java new file mode 100644 index 000000000..58909fc6c --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertAttributeTag.java @@ -0,0 +1,303 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.InsertAttributeModel; +import org.apache.tiles.api.Attribute; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Inserts the value of an attribute into the page. + * </p> + * <p> + * This tag can be flexibly used to insert the value of an attribute into a + * page. As in other usages in Tiles, every attribute can be determined to have + * a "type", either set explicitly when it was defined, or "computed". If the + * type is not explicit, then if the attribute value is a valid definition, it + * will be inserted as such. Otherwise, if it begins with a "/" character, it + * will be treated as a "template". Finally, if it has not otherwise been + * assigned a type, it will be treated as a String and included without any + * special handling. + * </p> + * + * <p> + * Example : + * </p> + * + * <pre> + * <code> + * <tiles:insertAttribute name="body" /> + * </code> + * </pre> + */ +public class InsertAttributeTag extends SimpleTagSupport { + + /** + * The template model. + */ + private InsertAttributeModel model = new InsertAttributeModel(); + + /** + * If true, if an exception happens during rendering, of if the attribute is + * null, the problem will be ignored. + */ + private boolean ignore; + + /** + * The preparer to invoke before rendering the attribute. + */ + private String preparer; + + /** + * A comma-separated list of roles. If present, the attribute will be rendered + * only if the current user belongs to one of the roles. + */ + private String role; + + /** + * The default value of the attribute. To use only if the attribute was not + * computed. + */ + private Object defaultValue; + + /** + * The default comma-separated list of roles. To use only if the attribute was + * not computed. + */ + private String defaultValueRole; + + /** + * The default type of the attribute. To use only if the attribute was not + * computed. + */ + private String defaultValueType; + + /** + * The name of the attribute. + */ + private String name; + + /** + * The attribute to use immediately, if not null. + */ + private Attribute value; + + /** + * If true, the response will be flushed after the insert. + */ + private boolean flush; + + /** + * Getter for ignore property. + * + * @return If true, if an exception happens during rendering, of if the + * attribute is null, the problem will be ignored. + */ + public boolean isIgnore() { + return ignore; + } + + /** + * Setter for ignore property. + * + * @param ignore If true, if an exception happens during rendering, of if the + * attribute is null, the problem will be ignored. + */ + public void setIgnore(boolean ignore) { + this.ignore = ignore; + } + + /** + * Getter for preparer property. + * + * @return The preparer to invoke before rendering the attribute. + */ + public String getPreparer() { + return preparer; + } + + /** + * Setter for preparer property. + * + * @param preparer The preparer to invoke before rendering the attribute. + */ + public void setPreparer(String preparer) { + this.preparer = preparer; + } + + /** + * Getter for role property. + * + * @return A comma-separated list of roles. If present, the attribute will be + * rendered only if the current user belongs to one of the roles. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role A comma-separated list of roles. If present, the attribute will + * be rendered only if the current user belongs to one of the roles. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for defaultValue property. + * + * @return The default value of the attribute. To use only if the attribute was + * not computed. + */ + public Object getDefaultValue() { + return defaultValue; + } + + /** + * Setter for defaultValue property. + * + * @param defaultValue The default value of the attribute. To use only if the + * attribute was not computed. + */ + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } + + /** + * Getter for defaultValueRole property. + * + * @return The default comma-separated list of roles. To use only if the + * attribute was not computed. + */ + public String getDefaultValueRole() { + return defaultValueRole; + } + + /** + * Setter for defaultValueRole property. + * + * @param defaultValueRole The default comma-separated list of roles. To use + * only if the attribute was not computed. + */ + public void setDefaultValueRole(String defaultValueRole) { + this.defaultValueRole = defaultValueRole; + } + + /** + * Getter for defaultValueType property. + * + * @return The default type of the attribute. To use only if the attribute was + * not computed. + */ + public String getDefaultValueType() { + return defaultValueType; + } + + /** + * Setter for defaultValueType property. + * + * @param defaultValueType The default type of the attribute. To use only if the + * attribute was not computed. + */ + public void setDefaultValueType(String defaultValueType) { + this.defaultValueType = defaultValueType; + } + + /** + * Getter for name property. + * + * @return The name of the attribute. + */ + public String getName() { + return name; + } + + /** + * Setter for name property. + * + * @param name The name of the attribute. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for value property. + * + * @return The attribute to use immediately, if not null. + */ + public Attribute getValue() { + return value; + } + + /** + * Setter for value property. + * + * @param value The attribute to use immediately, if not null. + */ + public void setValue(Attribute value) { + this.value = value; + } + + /** + * Getter for flush property. + * + * @return If true, the response will be flushed after the insert. + */ + public boolean isFlush() { + return flush; + } + + /** + * Setter for flush property. + * + * @param flush If true, the response will be flushed after the insert. + */ + public void setFlush(boolean flush) { + this.flush = flush; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(ignore, preparer, role, defaultValue, defaultValueRole, defaultValueType, name, value, flush, + request, modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertDefinitionTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertDefinitionTag.java new file mode 100644 index 000000000..bd42a4b78 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertDefinitionTag.java @@ -0,0 +1,260 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.InsertDefinitionModel; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Insert a definition. + * </p> + * <p> + * Insert a definition with the possibility to override and specify parameters + * (called attributes). A definition can be seen as a (partially or totally) + * filled template that can override or complete attribute values. + * <tiles:insertDefinition> allows to define these attributes and pass + * them to the inserted jsp page, called template. Attributes are defined using + * nested tag <tiles:putAttribute> or <tiles:putListAttribute>. + * </p> + * <p> + * You must specify name tag attribute, for inserting a definition from + * definitions factory. + * </p> + * <p> + * Example : + * </p> + * + * <pre> + * <code> + * <tiles:insertDefinition name=".my.tiles.defininition flush="true"> + * <tiles:putAttribute name="title" value="My first page" /> + * <tiles:putAttribute name="header" value="/common/header.jsp" /> + * <tiles:putAttribute name="footer" value="/common/footer.jsp" /> + * <tiles:putAttribute name="menu" value="/basic/menu.jsp" /> + * <tiles:putAttribute name="body" value="/basic/helloBody.jsp" /> + * </tiles:insertDefinition> + * </code> + * </pre> + */ +public class InsertDefinitionTag extends SimpleTagSupport { + + /** + * The template model. + */ + private InsertDefinitionModel model = new InsertDefinitionModel(); + + /** + * The name of the definition to render. + */ + private String definitionName; + + /** + * If specified, this template will be used instead of the one used by the + * definition. + */ + private String template; + + /** + * The type of the template attribute. + */ + private String templateType; + + /** + * The expression to evaluate to get the value of the template. + */ + private String templateExpression; + + /** + * A comma-separated list of roles. If present, the definition will be rendered + * only if the current user belongs to one of the roles. + */ + private String role; + + /** + * The preparer to use to invoke before the definition is rendered. If + * specified, it overrides the preparer specified in the definition itself. + */ + private String preparer; + + /** + * If true, the response will be flushed after the insert. + */ + private boolean flush; + + /** + * Getter for name property. + * + * @return The name of the definition to render. + */ + public String getName() { + return definitionName; + } + + /** + * Setter for name property. + * + * @param definitionName The name of the definition to render. + */ + public void setName(String definitionName) { + this.definitionName = definitionName; + } + + /** + * Getter for template property. + * + * @return If specified, this template will be used instead of the one used by + * the definition. + */ + public String getTemplate() { + return template; + } + + /** + * Setter for template property. + * + * @param template If specified, this template will be used instead of the one + * used by the definition. + */ + public void setTemplate(String template) { + this.template = template; + } + + /** + * Getter for templateType property. + * + * @return The type of the template attribute. + */ + public String getTemplateType() { + return templateType; + } + + /** + * Setter for templateType property. + * + * @param templateType The type of the template attribute. + */ + public void setTemplateType(String templateType) { + this.templateType = templateType; + } + + /** + * Getter for templateExpression property. + * + * @return The expression to evaluate to get the value of the template. + */ + public String getTemplateExpression() { + return templateExpression; + } + + /** + * Setter for templateExpression property. + * + * @param templateExpression The expression to evaluate to get the value of the + * template. + */ + public void setTemplateExpression(String templateExpression) { + this.templateExpression = templateExpression; + } + + /** + * Getter for role property. + * + * @return A comma-separated list of roles. If present, the definition will be + * rendered only if the current user belongs to one of the roles. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role A comma-separated list of roles. If present, the definition will + * be rendered only if the current user belongs to one of the roles. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for preparer property. + * + * @return The preparer to use to invoke before the definition is rendered. If + * specified, it overrides the preparer specified in the definition + * itself. + */ + public String getPreparer() { + return preparer; + } + + /** + * Setter for preparer property. + * + * @param preparer The preparer to use to invoke before the definition is + * rendered. If specified, it overrides the preparer specified + * in the definition itself. + */ + public void setPreparer(String preparer) { + this.preparer = preparer; + } + + /** + * Getter for flush property. + * + * @return If true, the response will be flushed after the insert. + */ + public boolean isFlush() { + return flush; + } + + /** + * Setter for flush property. + * + * @param flush If true, the response will be flushed after the insert. + */ + public void setFlush(boolean flush) { + this.flush = flush; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(definitionName, template, templateType, templateExpression, role, preparer, flush, request, + modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertTemplateTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertTemplateTag.java new file mode 100644 index 000000000..aaa187068 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/InsertTemplateTag.java @@ -0,0 +1,233 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.InsertTemplateModel; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Insert a template. + * </p> + * <p> + * Insert a template with the possibility to pass parameters (called + * attributes). A template can be seen as a procedure that can take parameters + * or attributes. <tiles:insertTemplate> allows to define these attributes + * and pass them to the inserted jsp page, called template. Attributes are + * defined using nested tag <tiles:putAttribute> or + * <tiles:putListAttribute>. + * </p> + * <p> + * You must specify template attribute, for inserting a template + * </p> + * + * <p> + * Example : + * </p> + * + * <pre> + * <code> + * <tiles:insertTemplate template="/basic/myLayout.jsp" flush="true"> + * <tiles:putAttribute name="title" value="My first page" /> + * <tiles:putAttribute name="header" value="/common/header.jsp" /> + * <tiles:putAttribute name="footer" value="/common/footer.jsp" /> + * <tiles:putAttribute name="menu" value="/basic/menu.jsp" /> + * <tiles:putAttribute name="body" value="/basic/helloBody.jsp" /> + * </tiles:insertTemplate> + * </code> + * </pre> + */ +public class InsertTemplateTag extends SimpleTagSupport { + + /** + * The template model. + */ + private InsertTemplateModel model = new InsertTemplateModel(); + + /** + * The template to render. + */ + private String template; + + /** + * The type of the template attribute. + */ + private String templateType; + + /** + * The expression to evaluate to get the value of the template. + */ + private String templateExpression; + + /** + * A comma-separated list of roles. If present, the template will be rendered + * only if the current user belongs to one of the roles. + */ + private String role; + + /** + * The preparer to use to invoke before the definition is rendered. If + * specified, it overrides the preparer specified in the definition itself. + */ + private String preparer; + + /** + * If true, the response will be flushed after the insert. + */ + private boolean flush; + + /** + * Getter for template property. + * + * @return The template to render. + */ + public String getTemplate() { + return template; + } + + /** + * Setter for template property. + * + * @param template The template to render. + */ + public void setTemplate(String template) { + this.template = template; + } + + /** + * Getter for templateType property. + * + * @return The type of the template attribute. + */ + public String getTemplateType() { + return templateType; + } + + /** + * Setter for templateType property. + * + * @param templateType The type of the template attribute. + */ + public void setTemplateType(String templateType) { + this.templateType = templateType; + } + + /** + * Getter for templateExpression property. + * + * @return The expression to evaluate to get the value of the template. + */ + public String getTemplateExpression() { + return templateExpression; + } + + /** + * Setter for templateExpression property. + * + * @param templateExpression The expression to evaluate to get the value of the + * template. + */ + public void setTemplateExpression(String templateExpression) { + this.templateExpression = templateExpression; + } + + /** + * Getter for role property. + * + * @return A comma-separated list of roles. If present, the template will be + * rendered only if the current user belongs to one of the roles. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role A comma-separated list of roles. If present, the template will be + * rendered only if the current user belongs to one of the roles. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for preparer property. + * + * @return The preparer to use to invoke before the definition is rendered. If + * specified, it overrides the preparer specified in the definition + * itself. + */ + public String getPreparer() { + return preparer; + } + + /** + * Setter for preparer property. + * + * @param preparer The preparer to use to invoke before the definition is + * rendered. If specified, it overrides the preparer specified + * in the definition itself. + */ + public void setPreparer(String preparer) { + this.preparer = preparer; + } + + /** + * Getter for flush property. + * + * @return If true, the response will be flushed after the insert. + */ + public boolean isFlush() { + return flush; + } + + /** + * Setter for flush property. + * + * @param flush If true, the response will be flushed after the insert. + */ + public void setFlush(boolean flush) { + this.flush = flush; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(template, templateType, templateExpression, role, preparer, flush, request, modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/PutAttributeTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/PutAttributeTag.java new file mode 100644 index 000000000..f687d7e49 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/PutAttributeTag.java @@ -0,0 +1,234 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.PutAttributeModel; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Put an attribute in enclosing attribute container tag. + * </p> + * <p> + * Enclosing attribute container tag can be : + * <ul> + * <li><initContainer></li> + * <li><definition></li> + * <li><insertAttribute></li> + * <li><insertDefinition></li> + * <li><putListAttribute></li> + * </ul> + * (or any other tag which implements the PutAttributeTagParent interface. + * Exception is thrown if no appropriate tag can be found. + * </p> + * <p> + * Put tag can have following atributes : + * <ul> + * <li>name : Name of the attribute</li> + * <li>value : value to put as attribute</li> + * <li>type : value type. Possible type are : string (value is used as direct + * string), template (value is used as a page url to insert), definition (value + * is used as a definition name to insert), object (value is used as it is)</li> + * <li>role : Role to check when 'insertAttribute' will be called.</li> + * </ul> + * </p> + * <p> + * Value can also come from tag body. Tag body is taken into account only if + * value is not set by one of the tag attributes. In this case Attribute type is + * "string", unless tag body define another type. + * </p> + */ +public class PutAttributeTag extends SimpleTagSupport { + + /** + * The template model. + */ + private PutAttributeModel model = new org.apache.tiles.template.PutAttributeModel(); + + /** + * The name of the attribute to put. + */ + private String name; + + /** + * The value of the attribute. Use this parameter, or expression, or body. + */ + private Object value; + + /** + * The expression to calculate the value from. Use this parameter, or value, or + * body. + */ + private String expression; + + /** + * A comma-separated list of roles. If present, the attribute will be rendered + * only if the current user belongs to one of the roles. + */ + private String role; + + /** + * The type (renderer) of the attribute. + */ + private String type; + + /** + * If true the attribute will be cascaded to all nested attributes. + */ + private boolean cascade; + + /** + * Getter for name property. + * + * @return The name of the attribute to put. + */ + public String getName() { + return name; + } + + /** + * Setter for name property. + * + * @param name The name of the attribute to put. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for value property. + * + * @return The value of the attribute. Use this parameter, or expression, or + * body. + */ + public Object getValue() { + return value; + } + + /** + * Setter for value property. + * + * @param value The value of the attribute. Use this parameter, or expression, + * or body. + */ + public void setValue(Object value) { + this.value = value; + } + + /** + * Getter for expression property. + * + * @return The expression to calculate the value from. Use this parameter, or + * value, or body. + */ + public String getExpression() { + return expression; + } + + /** + * Setter for expression property. + * + * @param expression The expression to calculate the value from. Use this + * parameter, or value, or body. + */ + public void setExpression(String expression) { + this.expression = expression; + } + + /** + * Getter for role property. + * + * @return A comma-separated list of roles. If present, the attribute will be + * rendered only if the current user belongs to one of the roles. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role A comma-separated list of roles. If present, the attribute will + * be rendered only if the current user belongs to one of the roles. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for type property. + * + * @return The type (renderer) of the attribute. + */ + public String getType() { + return type; + } + + /** + * Setter for type property. + * + * @param type The type (renderer) of the attribute. + */ + public void setType(String type) { + this.type = type; + } + + /** + * Getter for cascade property. + * + * @return If true the attribute will be cascaded to all nested attributes. + */ + public boolean isCascade() { + return cascade; + } + + /** + * Setter for cascade property. + * + * @param cascade If true the attribute will be cascaded to all nested + * attributes. + */ + public void setCascade(boolean cascade) { + this.cascade = cascade; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(name, value, expression, role, type, cascade, request, modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/PutListAttributeTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/PutListAttributeTag.java new file mode 100644 index 000000000..b60628f25 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/PutListAttributeTag.java @@ -0,0 +1,164 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; + +/** + * <p> + * Declare a list that will be pass as attribute to tile. + * </p> + * <p> + * Declare a list that will be pass as attribute to tile. List elements are + * added using the tags 'addAttribute' or 'addListAttribute'. This tag can only + * be used inside 'insertTemplate', 'insertDefinition', 'definition' tags. + * </p> + */ +public class PutListAttributeTag extends SimpleTagSupport { + + /** + * The template model. + */ + private org.apache.tiles.template.PutListAttributeModel model = new org.apache.tiles.template.PutListAttributeModel(); + + /** + * The name of the attribute to put. + */ + private String name; + + /** + * A comma-separated list of roles. If present, the attribute will be rendered + * only if the current user belongs to one of the roles. + */ + private String role; + + /** + * If true, the list attribute will use, as first elements, the list contained + * in the list attribute, put with the same name, of the containing definition. + */ + private boolean inherit; + + /** + * If true the attribute will be cascaded to all nested attributes. + */ + private boolean cascade; + + /** + * Getter for name property. + * + * @return The name of the attribute to put. + */ + public String getName() { + return name; + } + + /** + * Setter for name property. + * + * @param name The name of the attribute to put. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for role property. + * + * @return A comma-separated list of roles. If present, the attribute will be + * rendered only if the current user belongs to one of the roles. + */ + public String getRole() { + return role; + } + + /** + * Setter for role property. + * + * @param role A comma-separated list of roles. If present, the attribute will + * be rendered only if the current user belongs to one of the roles. + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for inherit property. + * + * @return If true, the list attribute will use, as first elements, the list + * contained in the list attribute, put with the same name, of the + * containing definition. + */ + public boolean isInherit() { + return inherit; + } + + /** + * Setter for inherit property. + * + * @param inherit If true, the list attribute will use, as first elements, the + * list contained in the list attribute, put with the same name, + * of the containing definition. + */ + public void setInherit(boolean inherit) { + this.inherit = inherit; + } + + /** + * Getter for cascade property. + * + * @return If true the attribute will be cascaded to all nested attributes. + */ + public boolean isCascade() { + return cascade; + } + + /** + * Setter for cascade property. + * + * @param cascade If true the attribute will be cascaded to all nested + * attributes. + */ + public void setCascade(boolean cascade) { + this.cascade = cascade; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + ModelBody modelBody = runtime.createModelBody(); + model.execute(name, role, inherit, cascade, request, modelBody); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/SetCurrentContainerTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/SetCurrentContainerTag.java new file mode 100644 index 000000000..ee4877c38 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/SetCurrentContainerTag.java @@ -0,0 +1,81 @@ +/* + * 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.tiles.web.jsp.taglib; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.SimpleTagSupport; + +import org.apache.tiles.autotag.core.runtime.AutotagRuntime; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.jsp.autotag.JspAutotagRuntime; +import org.apache.tiles.template.SetCurrentContainerModel; + +/** + * Selects a container to be used as the "current" container. + */ +public class SetCurrentContainerTag extends SimpleTagSupport { + + /** + * The template model. + */ + private SetCurrentContainerModel model = new SetCurrentContainerModel(); + + /** + * The key of the container to be used as "current". If null, the default one + * will be used. + */ + private String containerKey; + + /** + * Getter for containerKey property. + * + * @return The key of the container to be used as "current". If null, the + * default one will be used. + */ + public String getContainerKey() { + return containerKey; + } + + /** + * Setter for containerKey property. + * + * @param containerKey The key of the container to be used as "current". If + * null, the default one will be used. + */ + public void setContainerKey(String containerKey) { + this.containerKey = containerKey; + } + + /** {@inheritDoc} */ + @Override + public void doTag() throws JspException, IOException { + AutotagRuntime<Request> runtime = new JspAutotagRuntime(); + if (runtime instanceof SimpleTagSupport) { + SimpleTagSupport tag = (SimpleTagSupport) runtime; + tag.setJspContext(getJspContext()); + tag.setJspBody(getJspBody()); + tag.setParent(getParent()); + tag.doTag(); + } + Request request = runtime.createRequest(); + model.execute(containerKey, request); + } +} diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/UseAttributeTag.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/UseAttributeTag.java index 0262029d8..e2740e56c 100644 --- a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/UseAttributeTag.java +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/UseAttributeTag.java @@ -58,7 +58,7 @@ public class UseAttributeTag extends SimpleTagSupport { private String name = null; /** - * Flag that, if <code>true</code>, ignores exceptions. + * Flag that, if true, ignores exceptions. */ private boolean ignore = false; @@ -126,10 +126,8 @@ public class UseAttributeTag extends SimpleTagSupport { /** * Set ignore flag. * - * @param ignore default: <code>false</code>: Exception is thrown when - * attribute is not found, set to <code> - * true</code> to - * ignore missing attributes silently + * @param ignore default: false: Exception is thrown when attribute is not + * found, set to true to ignore missing attributes silently */ public void setIgnore(boolean ignore) { this.ignore = ignore; @@ -138,10 +136,8 @@ public class UseAttributeTag extends SimpleTagSupport { /** * Get ignore flag. * - * @return default: <code>false</code>: Exception is thrown when attribute - * is not found, set to <code> - * true</code> to ignore missing - * attributes silently + * @return default: false: Exception is thrown when attribute is not found, set + * to true to ignore missing attributes silently */ public boolean isIgnore() { return ignore; @@ -191,8 +187,8 @@ public class UseAttributeTag extends SimpleTagSupport { } /** - * Implementation of <code>TagExtraInfo</code> which identifies the - * scripting object(s) to be made visible. + * Implementation of TagExtraInfo which identifies the scripting object(s) to be + * made visible. */ public static class Tei extends TagExtraInfo { @@ -211,8 +207,7 @@ public class UseAttributeTag extends SimpleTagSupport { id = data.getAttributeString("name"); } - return new VariableInfo[]{new VariableInfo(id, classname, true, - VariableInfo.AT_END)}; + return new VariableInfo[] { new VariableInfo(id, classname, true, VariableInfo.AT_END) }; } } diff --git a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/package-info.java b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/package-info.java index c40a0a955..0c9e72cd0 100644 --- a/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/package-info.java +++ b/plugins/tiles/src/main/java/org/apache/tiles/web/jsp/taglib/package-info.java @@ -18,8 +18,6 @@ */ /** * The "tiles-jsp" tag library contains tags that are useful to create - * templates, subpages other reusable view parts using the "tiles-core" - * package. + * templates, subpages other reusable view parts using the "tiles-core" package. */ package org.apache.tiles.web.jsp.taglib; - diff --git a/plugins/tiles/src/main/resources/META-INF/tld/tiles-extras-jsp.tld b/plugins/tiles/src/main/resources/META-INF/tld/tiles-extras-jsp.tld index dfdb15332..4ba058ebe 100644 --- a/plugins/tiles/src/main/resources/META-INF/tld/tiles-extras-jsp.tld +++ b/plugins/tiles/src/main/resources/META-INF/tld/tiles-extras-jsp.tld @@ -34,11 +34,11 @@ <tag> <description> <![CDATA[ - <p><strong>Use attribute value inside page.</strong></p> - <p>Declare a Java variable, and an attribute in the specified scope, - using its attribute value.</p> - <p>Java variable and attribute will have the name specified by 'id', - or the original name if not specified.</p> + <p>Use attribute value inside page.</p> + <p>Declare a Java variable, and an attribute in the specified scope, using its attribute + value.</p> + <p>Java variable and attribute will have the name specified by 'id', or the original name + if not specified.</p> ]]> </description> <name>useAttribute</name> @@ -89,9 +89,9 @@ <description> <![CDATA[ <p> - If this attribute is set to true, and the attribute specified by the name - does not exist, simply return without error. The default value is false, which will - cause a runtime exception to be thrown. + If this attribute is set to true, and the attribute specified by the name does not exist, + simply return without error. The default value is false, which will cause a runtime + exception to be thrown. </p> ]]> </description> diff --git a/plugins/tiles/src/main/resources/META-INF/tld/tiles-jsp.tld b/plugins/tiles/src/main/resources/META-INF/tld/tiles-jsp.tld new file mode 100644 index 000000000..6a85017ac --- /dev/null +++ b/plugins/tiles/src/main/resources/META-INF/tld/tiles-jsp.tld @@ -0,0 +1,894 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/* + * 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. + */ +--> +<taglib + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" + xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + version="2.1"> + <description> + <![CDATA[ + <p>This tag library provides Tiles tags.</p> + ]]> + </description> + <tlib-version>1.2</tlib-version> + <short-name>tiles</short-name> + <uri>http://tiles.apache.org/tags-tiles</uri> + <tag> + <description> + <![CDATA[ + <p>Insert a definition.</p> + <p> + Insert a definition with the possibility to override and specify parameters (called attributes). + A definition can be seen as a (partially or totally) filled template that can override or + complete attribute values. <tiles:insertDefinition> allows to define these attributes + and pass them to the inserted jsp page, called template. Attributes are defined using nested + tag <tiles:putAttribute> or <tiles:putListAttribute>. + </p> + <p> + You must specify name tag attribute, for inserting a definition from definitions factory. + </p> + <p> + Example : + </p> + <pre> + <tiles:insertDefinition name=".my.tiles.defininition flush="true"> + <tiles:putAttribute name="title" value="My first page" /> + <tiles:putAttribute name="header" value="/common/header.jsp" /> + <tiles:putAttribute name="footer" value="/common/footer.jsp" /> + <tiles:putAttribute name="menu" value="/basic/menu.jsp" /> + <tiles:putAttribute name="body" value="/basic/helloBody.jsp" /> + </tiles:insertDefinition> + </pre> + ]]> + </description> + <name>insertDefinition</name> + <tag-class>org.apache.tiles.web.jsp.taglib.InsertDefinitionTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + The name of the definition to render. + ]]> + </description> + <name>name</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + If specified, this template will be used instead of the one used by the definition. + ]]> + </description> + <name>template</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The type of the template attribute. + ]]> + </description> + <name>templateType</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The expression to evaluate to get the value of the template. + ]]> + </description> + <name>templateExpression</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + A comma-separated list of roles. If present, the definition will be rendered only if + the current user belongs to one of the roles. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The preparer to use to invoke before the definition is rendered. If specified, it + overrides the preparer specified in the definition itself. + ]]> + </description> + <name>preparer</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + If true, the response will be flushed after the insert. + ]]> + </description> + <name>flush</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Import attribute(s) in specified context. + </p> + <p> + Import attribute(s) to requested scope. Attribute name and scope are optional. If not + specified, all attributes are imported in page scope. Once imported, an attribute can be + used as any other beans from jsp contexts. + </p> + ]]> + </description> + <name>importAttribute</name> + <tag-class>org.apache.tiles.web.jsp.taglib.ImportAttributeTag</tag-class> + <body-content>empty</body-content> + <attribute> + <description> + <![CDATA[ + The name of the attribute to import. If it is null, all the attributes will be imported. + ]]> + </description> + <name>name</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The scope into which the attribute(s) will be imported. If null, the import will go in page + scope. + ]]> + </description> + <name>scope</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The name of the attribute into which the attribute will be imported. To be used in conjunction + to name. If null, the value of name will be used. + ]]> + </description> + <name>toName</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + If true, if the attribute is not present, the problem will be ignored. + ]]> + </description> + <name>ignore</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + Selects a container to be used as the "current" container. + ]]> + </description> + <name>setCurrentContainer</name> + <tag-class>org.apache.tiles.web.jsp.taglib.SetCurrentContainerTag</tag-class> + <body-content>empty</body-content> + <attribute> + <description> + <![CDATA[ + The key of the container to be used as 'current'. If null, the default one will be used. + ]]> + </description> + <name>containerKey</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Declare a list that will be pass as an attribute. + </p> + <p> + Declare a list that will be pass as an attribute . List elements are added using the tag + 'addAttribute' or 'addListAttribute'. This tag can only be used inside 'insertTemplate', + 'insertDefinition' or 'definition' tag. + </p> + ]]> + </description> + <name>addListAttribute</name> + <tag-class>org.apache.tiles.web.jsp.taglib.AddListAttributeTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + The comma-separated list of roles that can use the list attribute. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Render the value of the specified template attribute to the current Writer + </p> + <p> + Retrieve the value of the specified template attribute property, and render it to the current + Writer as a String. The usual toString() conversions is applied on found value. + </p> + ]]> + </description> + <name>getAsString</name> + <tag-class>org.apache.tiles.web.jsp.taglib.GetAsStringTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + If true, if an exception happens during rendering, of if the attribute is null, the problem + will be ignored. + ]]> + </description> + <name>ignore</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The preparer to invoke before rendering the attribute. + ]]> + </description> + <name>preparer</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + A comma-separated list of roles. If present, the attribute will be rendered only if + the current user belongs to one of the roles. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The default value of the attribute. To use only if the attribute was not computed. + ]]> + </description> + <name>defaultValue</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.Object</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The default comma-separated list of roles. To use only if the attribute was not computed. + ]]> + </description> + <name>defaultValueRole</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The default type of the attribute. To use only if the attribute was not computed. + ]]> + </description> + <name>defaultValueType</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The name of the attribute. + ]]> + </description> + <name>name</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The attribute to use immediately, if not null. + ]]> + </description> + <name>value</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>org.apache.tiles.Attribute</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Inserts the value of an attribute into the page. + </p> + <p> + This tag can be flexibly used to insert the value of an attribute into a page. As in other + usages in Tiles, every attribute can be determined to have a 'type', either set explicitly + when it was defined, or 'computed'. If the type is not explicit, then if the attribute value + is a valid definition, it will be inserted as such. Otherwise, if it begins with a '/' character, + it will be treated as a 'template'. Finally, if it has not otherwise been assigned a type, + it will be treated as a String and included without any special handling. + </p> + <p> + Example : + </p> + <pre> + <tiles:insertAttribute name="body" /> + </pre> + ]]> + </description> + <name>insertAttribute</name> + <tag-class>org.apache.tiles.web.jsp.taglib.InsertAttributeTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + If true, if an exception happens during rendering, of if the attribute is null, + the problem will be ignored. + ]]> + </description> + <name>ignore</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The preparer to invoke before rendering the attribute. + ]]> + </description> + <name>preparer</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + A comma-separated list of roles. If present, the attribute will be rendered only if + the current user belongs to one of the roles. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The default value of the attribute. To use only if the attribute was not computed. + ]]> + </description> + <name>defaultValue</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.Object</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The default comma-separated list of roles. To use only if the attribute was not computed. + ]]> + </description> + <name>defaultValueRole</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The default type of the attribute. To use only if the attribute was not computed. + ]]> + </description> + <name>defaultValueType</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The name of the attribute. + ]]> + </description> + <name>name</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The attribute to use immediately, if not null. + ]]> + </description> + <name>value</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>org.apache.tiles.Attribute</type> + </attribute> + <attribute> + <description> + <![CDATA[ + If true, the response will be flushed after the insert. + ]]> + </description> + <name>flush</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Put an attribute in enclosing attribute container tag. + </p> + <p> + Enclosing attribute container tag can be : + <ul> + <li><initContainer></li> + <li><definition></li> + <li><insertAttribute></li> + <li><insertDefinition></li> + <li><putListAttribute></li> + </ul> + or any other tag which implements the PutAttributeTagParent interface. Exception is thrown + if no appropriate tag can be found. + </p> + <p> + Put tag can have following atributes : + <ul> + <li>name : Name of the attribute</li> + <li>value : value to put as attribute</li> + <li>type : value type. Possible type are : string (value is used as direct string), + template (value is used as a page url to insert), definition (value is used as a definition + name to insert), object (value is used as it is)</li> + <li>role : Role to check when 'insertAttribute' will be called.</li> + </ul> + </p> + <p> + Value can also come from tag body. Tag body is taken into account only if value is not set + by one of the tag attributes. In this case Attribute type is 'string', unless tag body define + another type. + </p> + ]]> + </description> + <name>putAttribute</name> + <tag-class>org.apache.tiles.web.jsp.taglib.PutAttributeTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + The name of the attribute to put. + ]]> + </description> + <name>name</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The value of the attribute. Use this parameter, or expression, or body. + ]]> + </description> + <name>value</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.Object</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The expression to calculate the value from. Use this parameter, or value, or body. + ]]> + </description> + <name>expression</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + A comma-separated list of roles. If present, the attribute will be rendered only if + the current user belongs to one of the roles. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The type (renderer) of the attribute. + ]]> + </description> + <name>type</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + If true the attribute will be cascaded to all nested attributes. + ]]> + </description> + <name>cascade</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Create a definition at runtime. + </p> + <p> + Create a new definition at runtime. Newly created definition will be available across the + entire request. + </p> + ]]> + </description> + <name>definition</name> + <tag-class>org.apache.tiles.web.jsp.taglib.DefinitionTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + The name of the definition to create. If not specified, an anonymous definition will be created. + ]]> + </description> + <name>name</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The template of this definition. + ]]> + </description> + <name>template</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + A comma-separated list of roles. If present, the definition will be rendered only if the + current user belongs to one of the roles. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The definition name that this definition extends. + ]]> + </description> + <name>extends</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The preparer to use to invoke before the definition is rendered. + ]]> + </description> + <name>preparer</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Add an element to the surrounding list. Equivalent to 'putAttribute', but for list element. + </p> + <p> + Add an element to the surrounding list. This tag can only be used inside 'putListAttribute' + or 'addListAttribute' tags. Value can come from a direct assignment (value="aValue") + </p> + ]]> + </description> + <name>addAttribute</name> + <tag-class>org.apache.tiles.web.jsp.taglib.AddAttributeTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + The value of the attribute. Use this parameter, or expression, or body. + ]]> + </description> + <name>value</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.Object</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The expression to calculate the value from. Use this parameter, or value, or body. + ]]> + </description> + <name>expression</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + A comma-separated list of roles. If present, the attribute will be rendered only if the + current user belongs to one of the roles. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The type (renderer) of the attribute. + ]]> + </description> + <name>type</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Declare a list that will be pass as attribute to tile. + </p> + <p> + Declare a list that will be pass as attribute to tile. List elements are added using the tags + 'addAttribute' or 'addListAttribute'. This tag can only be used inside 'insertTemplate', + 'insertDefinition', 'definition' tags. + </p> + ]]> + </description> + <name>putListAttribute</name> + <tag-class>org.apache.tiles.web.jsp.taglib.PutListAttributeTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + The name of the attribute to put. + ]]> + </description> + <name>name</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + A comma-separated list of roles. If present, the attribute will be rendered only if the + current user belongs to one of the roles. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + If true, the list attribute will use, as first elements, the list contained in the list + attribute, put with the same name, of the containing definition. + ]]> + </description> + <name>inherit</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + <attribute> + <description> + <![CDATA[ + If true the attribute will be cascaded to all nested attributes. + ]]> + </description> + <name>cascade</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + </tag> + <tag> + <description> + <![CDATA[ + <p> + Insert a template. + </p> + <p> + Insert a template with the possibility to pass parameters (called attributes). A template can + be seen as a procedure that can take parameters or attributes. <tiles:insertTemplate> + allows to define these attributes and pass them to the inserted jsp page, called template. + Attributes are defined using nested tag <tiles:putAttribute> or <tiles:putListAttribute>. + </p> + <p> + You must specify template attribute, for inserting a template + </p> + <p> + Example : + </p> + <pre> + <tiles:insertTemplate template="/basic/myLayout.jsp" flush="true"> + <tiles:putAttribute name="title" value="My first page" /> + <tiles:putAttribute name="header" value="/common/header.jsp" /> + <tiles:putAttribute name="footer" value="/common/footer.jsp" /> + <tiles:putAttribute name="menu" value="/basic/menu.jsp" /> + <tiles:putAttribute name="body" value="/basic/helloBody.jsp" /> + </tiles:insertTemplate> + </pre> + ]]> + </description> + <name>insertTemplate</name> + <tag-class>org.apache.tiles.web.jsp.taglib.InsertTemplateTag</tag-class> + <body-content>scriptless</body-content> + <attribute> + <description> + <![CDATA[ + The template to render. + ]]> + </description> + <name>template</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The type of the template attribute. + ]]> + </description> + <name>templateType</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The expression to evaluate to get the value of the template. + ]]> + </description> + <name>templateExpression</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + A comma-separated list of roles. If present, the template will be rendered only if the + current user belongs to one of the roles. + ]]> + </description> + <name>role</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + The preparer to use to invoke before the definition is rendered. If specified, it overrides + the preparer specified in the definition itself. + ]]> + </description> + <name>preparer</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>java.lang.String</type> + </attribute> + <attribute> + <description> + <![CDATA[ + If true, the response will be flushed after the insert. + ]]> + </description> + <name>flush</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>boolean</type> + </attribute> + </tag> +</taglib>