You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2008/03/04 22:19:43 UTC
svn commit: r633650 - in
/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib:
AttributeTagSupport.java ImportAttributeTag.java UseAttributeTag.java
Author: apetrelli
Date: Tue Mar 4 13:19:41 2008
New Revision: 633650
URL: http://svn.apache.org/viewvc?rev=633650&view=rev
Log:
TILES-48
JSP tags connected to TilesContainer.evaluate.
Modified:
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/UseAttributeTag.java
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java?rev=633650&r1=633649&r2=633650&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java Tue Mar 4 13:19:41 2008
@@ -20,9 +20,12 @@
*/
package org.apache.tiles.jsp.taglib;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.tiles.Attribute;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
import org.apache.tiles.access.TilesAccess;
import javax.servlet.jsp.JspException;
@@ -39,6 +42,10 @@
*/
public abstract class AttributeTagSupport extends TagSupport {
+ /**
+ * The logging object.
+ */
+ private static final Log LOG = LogFactory.getLog(AttributeTagSupport.class);
/**
* Maps scope names to their constants.
@@ -90,6 +97,12 @@
*/
protected Attribute attribute;
+ /**
+ * The attribute value.
+ *
+ * @since 2.1.0
+ */
+ protected Object attributeValue;
/**
* Set the scope.
@@ -113,6 +126,10 @@
public void release() {
scopeName = null;
scope = PageContext.PAGE_SCOPE;
+ ignore = false;
+ attribute = null;
+ attributeValue = null;
+ attributeContext = null;
}
/** {@inheritDoc} */
@@ -133,7 +150,19 @@
throw new JspException("Attribute with name '" + name + "' not found");
}
- if (attribute.getValue() == null) {
+ try {
+ attributeValue = container.evaluate(attribute, pageContext);
+ } catch (TilesException e) {
+ if (!ignore) {
+ throw new JspException("Attribute with name '" + name
+ + "' has a value of '" + attribute.getValue()
+ + "' that cannot be evaluated");
+ } else if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring Tiles Exception", e);
+ }
+ }
+
+ if (attributeValue == null) {
throw new JspException("Attribute with name '" + name + "' has a null value.");
}
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java?rev=633650&r1=633649&r2=633650&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java Tue Mar 4 13:19:41 2008
@@ -20,7 +20,10 @@
*/
package org.apache.tiles.jsp.taglib;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.tiles.Attribute;
+import org.apache.tiles.TilesException;
import javax.servlet.jsp.JspException;
@@ -38,6 +41,11 @@
public class ImportAttributeTag extends AttributeTagSupport {
/**
+ * The logging object.
+ */
+ private static final Log LOG = LogFactory.getLog(ImportAttributeTag.class);
+
+ /**
* The destination attribute name.
*/
private String toName;
@@ -72,9 +80,9 @@
* @throws JspException On errors processing tag.
*/
public void execute() throws JspException {
- if (attribute != null) {
+ if (attributeValue != null) {
pageContext.setAttribute(toName != null ? toName : name,
- attribute.getValue(), scope);
+ attributeValue, scope);
} else {
importAttributes(attributeContext.getCascadedAttributeNames());
importAttributes(attributeContext.getLocalAttributeNames());
@@ -102,14 +110,28 @@
Attribute attr = attributeContext.getAttribute(name);
- if ((attr == null || attr.getValue() == null) && !ignore) {
+ if (attr != null) {
+ try {
+ Object attributeValue = container.evaluate(attr, pageContext);
+ if (attributeValue == null) {
+ throw new JspException("Error importing attributes. "
+ + "Attribute '" + name + "' has a null value ");
+ }
+ pageContext.setAttribute(name, attributeValue, scope);
+ } catch (TilesException e) {
+ if (!ignore) {
+ throw new JspException("Attribute with name '" + name
+ + "' has a value of '" + attr.getValue()
+ + "' that cannot be evaluated");
+ } else if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring Tiles Exception", e);
+ }
+ }
+ } else if (!ignore) {
throw new JspException("Error importing attributes. "
- + "Attribute '" + name + "' has a null value ");
- } else if (attr == null || attr.getValue() == null) {
- continue;
+ + "Attribute '" + name + "' is null");
}
- pageContext.setAttribute(name, attr.getValue(), scope);
}
}
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/UseAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/UseAttributeTag.java?rev=633650&r1=633649&r2=633650&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/UseAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/UseAttributeTag.java Tue Mar 4 13:19:41 2008
@@ -76,7 +76,7 @@
* @throws JspException if a JSP exception has occurred
*/
public void execute() throws JspException {
- pageContext.setAttribute(getScriptingVariable(), attribute.getValue(), scope);
+ pageContext.setAttribute(getScriptingVariable(), attributeValue, scope);
}
/**