Torsten,
Checked in your patch. Please cross-check.
Thanks,
dims
--- Torsten Curdt <[EMAIL PROTECTED]> wrote:
> Ok, guys,
>
> I modified the RequestParamAction so the
> - request URI
> - request Query
> - servlet context
> becomes available in the sitemap.
>
> I also made the populating of the parameters to
> the substitution map configurable (true/false)
>
> Maybe we should rename the action to RequestDetailsAction
> or something since now it make request detail available
> to the sitemap.
>
> Hope all this is fine with you Marcus?
> --
> Torsten
> > Index: RequestParamAction.java
> ===================================================================
> RCS file:
>/home/cvspublic/xml-cocoon2/src/org/apache/cocoon/acting/RequestParamAction.java,v
> retrieving revision 1.2
> diff -u -r1.2 RequestParamAction.java
> --- RequestParamAction.java 2001/07/06 21:35:01 1.2
> +++ RequestParamAction.java 2001/07/11 12:26:40
> @@ -25,10 +25,18 @@
> import org.apache.avalon.framework.parameters.Parameters;
>
> /**
> - * This action makes all request parameters available for use in the sitemap.
> - * A variable is created for each request parameter (only if it doesn't exist)
> - * with the same name as the parameter itself.
> + * This action makes some request details available to the sitemap via parameter
> + * substitution.
> *
> + * {context} - is the context path of the servlet (usually "/cocoon")
> + * {requestURI} - is the requested URI without parameters
> + * {requestQuery} - is the query string like "?param1=test" if there is one
> + *
> + * Additionlly all request parameters can be made available for use in the sitemap.
> + * if the parameter "parameters" is set to true.
> + * (A variable is created for each request parameter (only if it doesn't exist)
> + * with the same name as the parameter itself)
> + *
> * Sitemap definition:
> *
> * <pre>
> @@ -42,7 +50,8 @@
> * <pre>
> * <map:match pattern="some-resource">
> * <map:act type="request">
> - * <map:redirect-to uri="{dest}"/>
> + * <map:parameter name="parameters" value="true"/>
> + * <map:redirect-to uri="{context}/somewhereelse/{dest}"/>
> * </map:act>
> * </map:match>
> * </pre>
> @@ -52,6 +61,7 @@
> * <pre>
> * <map:match pattern="some-resource">
> * <map:act type="request">
> + * <map:parameter name="parameters" value="true"/>
> * <map:generate src="users/menu-{id}.xml"/>
> * </map:act>
> * <map:transform src="menus/personalisation.xsl"/>
> @@ -62,43 +72,52 @@
> * etc, etc.
> *
> * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
> + * @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a>
> * @version CVS $Revision: 1.2 $
> */
> public class RequestParamAction extends ComposerAction {
> -
> - /**
> - * Action which makes all request parameters available for xpath
> - * substitution.
> - */
> - public Map act(
> - Redirector redirector,
> - SourceResolver resolver,
> - Map objectModel,
> - String source,
> - Parameters par
> - ) throws Exception {
> -
> - Request request =
> - (Request) objectModel.get(Constants.REQUEST_OBJECT);
> -
> - Enumeration e = request.getParameterNames();
> -
> - if (e.hasMoreElements()) {
> -
> - Map map = new HashMap();
>
> - while(e.hasMoreElements())
> - {
> - String name = (String) e.nextElement();
> - String value = request.getParameter(name);
> -
> - if (value != null && !map.containsKey(name))
> - map.put(name, value);
> + public final static String MAP_URI = "requestURI";
> + public final static String MAP_QUERY = "requestQuery";
> + public final static String MAP_CONTEXTPATH = "context";
> +
> + public final static String PARAM_PARAMETERS = "parameters";
> +
> + public Map act( Redirector redirector, SourceResolver resolver, Map
>objectModel, String
> source, Parameters param )
> + throws Exception
> + {
> +
> + Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
> + if (request == null) {
> + getLogger().error("RequestInfoAction: no request object!");
> + return(null);
> + }
> +
> + Map map = new HashMap();
> +
> + map.put(MAP_URI, request.getRequestURI());
> +
> + String query = request.getQueryString();
> + if (query != null && query.length() > 0){
> + map.put(MAP_QUERY, "?" + query);
> + }
> + else{
> + map.put(MAP_QUERY, "");
> + }
> +
> + map.put(MAP_CONTEXTPATH, request.getContextPath());
> +
> + if ("true".equalsIgnoreCase(param.getParameter(PARAM_PARAMETERS, null))){
> + Enumeration e = request.getParameterNames();
> + while(e.hasMoreElements()){
> + String name = (String) e.nextElement();
> + String value = request.getParameter(name);
> + if (value != null && !map.containsKey(name)){
> + map.put(name, value);
> }
> -
> - return map;
> + }
> }
> -
> - return null;
> +
> + return(map);
> }
> }
> > ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]