You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ha...@apache.org on 2003/08/15 17:54:15 UTC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/acting InputModuleAction.java
haul 2003/08/15 08:54:15
Modified: src/java/org/apache/cocoon/acting InputModuleAction.java
Log:
results used Integers as index which could not be resolved from sitemap parameters. Change to strings.
Revision Changes Path
1.2 +38 -8 cocoon-2.1/src/java/org/apache/cocoon/acting/InputModuleAction.java
Index: InputModuleAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/acting/InputModuleAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InputModuleAction.java 20 May 2003 14:22:01 -0000 1.1
+++ InputModuleAction.java 15 Aug 2003 15:54:15 -0000 1.2
@@ -51,6 +51,7 @@
package org.apache.cocoon.acting;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.environment.Redirector;
@@ -65,12 +66,14 @@
* Sitemap evaluation of input modules using the curly bracket syntax e.g.
* {defaults:skin} suffers from the fact that it is not
* possible to use a sitemap variable as part of the invocation like
- * {defaults:{1})}. This action takes two parameters, the name
- * of the input module and the attribute name. Thus the above becomes
+ * {defaults:{1})}. This action takes three parameters, the name
+ * of the input module, the attribute name, and whether to call getAttribute() or
+ * getAttributeValues(). Thus the above becomes
* <pre>
* <map:act type="inputmodule">
* <map:parameter name="module" value="defaults"/>
* <map:parameter name="attribute" value="{1}"/>
+ * <map:parameter name="single-value" value="false"/>
*
* <!-- do something with the result: "{1}" -->
*
@@ -87,6 +90,7 @@
* src="org.apache.cocoon.acting.InputModuleAction"
* logger="sitemap.action.inputmodule">
* <module>defaults</module>
+ * <single-value>false</single-value>
* </map:action>
* </pre>
*
@@ -112,26 +116,52 @@
HashMap map = null;
Configuration conf = null;
String module = parameters.getParameter("module", (String) this.settings.get("module"));
- String attrib = parameters.getParameter("attribute", (String) this.settings.get("attribute"));
+ String attrib =
+ parameters.getParameter("attribute", (String) this.settings.get("attribute"));
+ boolean single =
+ parameters.getParameterAsBoolean(
+ "single-value",
+ ((Boolean) this.settings.get("single-value")).booleanValue());
if (module != null && attrib != null) {
XSPModuleHelper mhelper = new XSPModuleHelper();
mhelper.setup(manager);
- Object[] result = mhelper.getAttributeValues(objectModel, conf, module, attrib, null);
+ Object[] result = null;
+ if (!single) {
+ result = mhelper.getAttributeValues(objectModel, conf, module, attrib, null);
+ } else {
+ Object tmp = mhelper.getAttribute(objectModel, conf, module, attrib, null);
+ if (tmp != null){
+ result = new Object[1];
+ result[0] = tmp;
+ }
+ }
mhelper.releaseAll();
if (result != null && result.length != 0) {
map = new HashMap();
for (int i = 0; i < result.length; i++) {
- map.put(new Integer(i), result[i]);
+ map.put(Integer.toString(i), result[i]);
}
}
} else {
- if (getLogger().isErrorEnabled()){
- getLogger().error("Parameter is missing: module="+module+" attribute="+attrib);
+ if (getLogger().isErrorEnabled()) {
+ getLogger().error(
+ "Parameter is missing: module=" + module + " attribute=" + attrib);
}
}
return map;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration conf) throws ConfigurationException {
+ super.configure(conf);
+ boolean result = false;
+ String tmp = (String) this.settings.get("single-value", "false");
+ result = tmp.equalsIgnoreCase("true") || tmp.equalsIgnoreCase("yes");
+ this.settings.put("single-value", new Boolean(result));
}
}