[prev in list] [next in list] [prev in thread] [next in thread]
List: xml-cocoon-cvs
Subject: cvs commit: xml-cocoon2/src/org/apache/cocoon/acting RequestParamAction.java
From: cziegeler () apache ! org
Date: 2001-09-26 13:16:20
[Download RAW message or body]
cziegeler 01/09/26 06:16:20
Modified: src/org/apache/cocoon/acting Tag: cocoon_20_branch
RequestParamAction.java
Log:
Default value support for RequestParamAction
Submitted by: Sergio Carvalho [sergio.carvalho@acm.org]
Revision Changes Path
No revision
No revision
1.1.2.6 +18 -1 \
xml-cocoon2/src/org/apache/cocoon/acting/RequestParamAction.java
Index: RequestParamAction.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/RequestParamAction.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- RequestParamAction.java 2001/08/22 12:08:20 1.1.2.5
+++ RequestParamAction.java 2001/09/26 13:16:20 1.1.2.6
@@ -38,6 +38,9 @@
* (A variable is created for each request parameter (only if it doesn't exist)
* with the same name as the parameter itself)
*
+ * Default values can be set for request parameters, by including sitemap \
parameters + * named "default.<parameter-name>".
+ *
* Sitemap definition:
*
* <pre>
@@ -52,6 +55,7 @@
* <map:match pattern="some-resource">
* <map:act type="request">
* <map:parameter name="parameters" value="true"/>
+ * <map:parameter name="default.dest" value="invalid-destination.html"/>
* <map:redirect-to uri="{context}/somewhereelse/{dest}"/>
* </map:act>
* </map:match>
@@ -74,7 +78,7 @@
*
* @author <a href="mailto:Marcus.Crafter@osa.de">Marcus Crafter</a>
* @author <a href="mailto:tcurdt@dff.st">Torsten Curdt</a>
- * @version CVS $Revision: 1.1.2.5 $
+ * @version CVS $Revision: 1.1.2.6 $
*/
public class RequestParamAction extends ComposerAction implements ThreadSafe {
@@ -83,6 +87,8 @@
public final static String MAP_CONTEXTPATH = "context";
public final static String PARAM_PARAMETERS = "parameters";
+ public final static String PARAM_DEFAULT_PREFIX = "default.";
+
public Map act( Redirector redirector, SourceResolver resolver, Map \
objectModel, String source, Parameters param ) throws Exception
@@ -113,10 +119,21 @@
while(e.hasMoreElements()){
String name = (String) e.nextElement();
String value = request.getParameter(name);
+
if (value != null && !map.containsKey(name)){
map.put(name, value);
}
}
+
+ String[] paramNames = param.getNames();
+ for (int i=0; i< paramNames.length; i++) {
+ if (paramNames[i].startsWith(PARAM_DEFAULT_PREFIX) &&
+ (request.getParameter(paramNames[i].substring(PARAM_DEFAULT_PREFIX.length())) \
== null)) { + map.put(paramNames[i].substring(PARAM_DEFAULT_PREFIX.length()), \
param.getParameter(paramNames[i])); + }
+ }
+
+
}
return(map);
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic