You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by tc...@apache.org on 2002/02/15 11:27:34 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/environment/http HttpEnvironment.java
tcurdt 02/02/15 02:27:34
Modified: src/documentation/xdocs tutorial.xml
src/documentation/xdocs/userdocs/concepts actions.xml
src/java/org/apache/cocoon Constants.java
src/webapp/docs/samples/forms employee.xsp
src/webapp/tutorial/stylesheets apache.xsl
src/java/org/apache/cocoon/environment/http
HttpEnvironment.java
Log:
introduced the new cocoon-action-ACTIONNAME syntax. the original cocoon-action
syntax should be considered deprecated now since there are some i18n issues with it.
(but it is still supported)
Revision Changes Path
1.2 +4 -4 xml-cocoon2/src/documentation/xdocs/tutorial.xml
Index: tutorial.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/tutorial.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- tutorial.xml 3 Jan 2002 12:31:01 -0000 1.1
+++ tutorial.xml 15 Feb 2002 10:27:33 -0000 1.2
@@ -326,8 +326,8 @@
]]>
</source>
<p>It is important to note that the "submit" tag is transformed
- into an HTML submit button with the name "cocoon-action".
- The "cocoon-action" form parameter is a magic value that
+ into an HTML submit button with the name "cocoon-action-ACTIONNAME".
+ The "cocoon-action-ACTIONNAME" form parameter is a magic value that
Cocoon uses to select a specific action from a group of actions that
only gets executed during that time. You will find that this page
displays correctly, but does not do anything yet. The handler is
@@ -441,8 +441,8 @@
<p>Lastly, we want to create an action set. An action set is a group of
actions that will be applied at once. If the action set entry has an
"action" parameter, then the specific action is only
- executed when the magic "cocoon-action" request parameter
- matches the value of the "action" parameter. For our
+ executed when the ACTIONNAME of the magic "cocoon-action-ACTIONNAME"
+ request parameter matches the value of the "action" parameter. For our
purposes, the action set we are defining is listed below (defined in
the sitemap):</p>
<source>
1.3 +9 -2 xml-cocoon2/src/documentation/xdocs/userdocs/concepts/actions.xml
Index: actions.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/userdocs/concepts/actions.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- actions.xml 15 Jan 2002 21:27:40 -0000 1.2
+++ actions.xml 15 Feb 2002 10:27:33 -0000 1.3
@@ -236,8 +236,15 @@
call an action only if the Environments getAction method returns
a String identical to the value supplied with an action attribute.
In the current implementation of the HttpEnvironment the value
- returned by the getAction method is determined by a http parameter
- called "cocoon-action".</p>
+ returned by the getAction method is determined by a http request
+ parameter. The Environment looks for a request parameter with a
+ prefix "cocoon-action-" followed by an action name.</p>
+ <source>
+<![CDATA[
+<input type="submit" name="cocoon-action-ACTIONAME" value="click here to do something">
+]]>
+ </source>
+ <p>Please note: the orginal "cocoon-action" syntax is deprecated but still supported!</p>
<p> Above we have seen that a successfully executed action
returns a Map object that can be used to communicate with the
sitemap. In case of an action set this is similar. With action
1.8 +8 -1 xml-cocoon2/src/java/org/apache/cocoon/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Constants.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Constants.java 14 Feb 2002 09:30:13 -0000 1.7
+++ Constants.java 15 Feb 2002 10:27:33 -0000 1.8
@@ -60,7 +60,7 @@
*
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:proyal@managingpartners.com">Peter Royal</a>
- * @version CVS $Id: Constants.java,v 1.7 2002/02/14 09:30:13 cziegeler Exp $
+ * @version CVS $Id: Constants.java,v 1.8 2002/02/15 10:27:33 tcurdt Exp $
*/
public interface Constants {
@@ -106,6 +106,13 @@
* FIXME(GP): Isn't this Servlet specific?
*/
String ACTION_PARAM = "cocoon-action";
+
+ /**
+ * The request parameter prefix to trigger a specific action.
+ *
+ * FIXME(GP): Isn't this Servlet specific?
+ */
+ String ACTION_PARAM_PREFIX = "cocoon-action-";
/** The name of the property where temporary files will be written to. */
String TEMPDIR_PROPERTY = "org.apache.cocoon.properties.tempdir";
1.2 +3 -3 xml-cocoon2/src/webapp/docs/samples/forms/employee.xsp
Index: employee.xsp
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/webapp/docs/samples/forms/employee.xsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- employee.xsp 3 Jan 2002 12:31:39 -0000 1.1
+++ employee.xsp 15 Feb 2002 10:27:33 -0000 1.2
@@ -80,10 +80,10 @@
<![CDATA[
if (empID != null && !empID.equals("-1")) {
]]>
- <input type="submit" name="cocoon-action" value="Update"/>
- <input type="submit" name="cocoon-action" value="Delete"/>
+ <input type="submit" name="cocoon-action-Update" value="click here to update"/>
+ <input type="submit" name="cocoon-action-Delete" value="click here to delete"/>
} else {
- <input type="submit" name="cocoon-action" value="Add"/>
+ <input type="submit" name="cocoon-action-Add" value="click here to add"/>
}
</xsp:logic>
</form>
1.2 +1 -1 xml-cocoon2/src/webapp/tutorial/stylesheets/apache.xsl
Index: apache.xsl
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/webapp/tutorial/stylesheets/apache.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- apache.xsl 3 Jan 2002 12:31:49 -0000 1.1
+++ apache.xsl 15 Feb 2002 10:27:33 -0000 1.2
@@ -272,7 +272,7 @@
</xsl:template>
<xsl:template match="submit">
- <input type="submit" name="cocoon-action" value="{@name}"/>
+ <input type="submit" name="cocoon-action-{@name}" value="{@name}"/>
</xsl:template>
<xsl:template match="reset">
1.7 +25 -2 xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
Index: HttpEnvironment.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HttpEnvironment.java 13 Feb 2002 09:35:11 -0000 1.6
+++ HttpEnvironment.java 15 Feb 2002 10:27:34 -0000 1.7
@@ -68,10 +68,11 @@
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Enumeration;
/**
* @author ?
- * @version CVS $Id: HttpEnvironment.java,v 1.6 2002/02/13 09:35:11 froehlich Exp $
+ * @version CVS $Id: HttpEnvironment.java,v 1.7 2002/02/15 10:27:34 tcurdt Exp $
*/
public class HttpEnvironment extends AbstractEnvironment implements Redirector {
@@ -107,7 +108,7 @@
String containerEncoding,
String defaultFormEncoding)
throws MalformedURLException, IOException {
- super(uri, req.getParameter(Constants.VIEW_PARAM), rootURL, req.getParameter(Constants.ACTION_PARAM));
+ super(uri, req.getParameter(Constants.VIEW_PARAM), rootURL, extractAction(req));
this.request = new HttpRequest (req, this);
this.request.setCharacterEncoding(defaultFormEncoding);
@@ -122,6 +123,28 @@
this.objectModel.put(HTTP_REQUEST_OBJECT, req);
this.objectModel.put(HTTP_RESPONSE_OBJECT, res);
this.objectModel.put(HTTP_SERVLET_CONTEXT, servletContext);
+ }
+
+ /**
+ * extract the action portion from the request
+ * (must be static because it's called in the super() constructor.
+ * should maybe go into a helper or directly into sitemap)
+ */
+ private final static String extractAction(HttpServletRequest req) {
+ String action = req.getParameter(Constants.ACTION_PARAM);
+ if (action != null) {
+ /* TC: still support the deprecated syntax */
+ return(action);
+ }
+ else {
+ for(Enumeration e = req.getParameterNames(); e.hasMoreElements(); ) {
+ String name = (String)e.nextElement();
+ if (name.startsWith(Constants.ACTION_PARAM_PREFIX)) {
+ return(name.substring(Constants.ACTION_PARAM_PREFIX.length()));
+ }
+ }
+ return(null);
+ }
}
/**
----------------------------------------------------------------------
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