husted      2002/12/29 09:00:16

  Modified:    src/share/org/apache/struts/taglib/html LinkTag.java
                        FormTag.java
  Log:
  Apply patch for PR #13645 contributed by James Turner.
  
  Revision  Changes    Path
  1.28      +24 -7     
jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java
  
  Index: LinkTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- LinkTag.java      23 Sep 2002 05:13:43 -0000      1.27
  +++ LinkTag.java      29 Dec 2002 17:00:15 -0000      1.28
  @@ -76,6 +76,7 @@
    * Generate a URL-encoded hyperlink to the specified URI.
    *
    * @author Craig R. McClanahan
  + * @author James Turner
    * @version $Revision$ $Date$
    */
   
  @@ -187,9 +188,24 @@
   
   
       /**
  -     * The single-parameter request parameter name to generate.
  +     * The module-relative action (beginning with a slash) which will be
  +     * called by this link
        */
  -    protected String paramId = null;
  +    protected String action = null;
  +
  +    public String getAction() {
  +        return (this.action);
  +    }
  +
  +    public void setAction(String action) {
  +        this.action = action;
  +    }
  +
  +
  +    /**
  +      * The single-parameter request parameter name to generate.
  +      */
  +     protected String paramId = null;
   
       public String getParamId() {
           return (this.paramId);
  @@ -417,6 +433,7 @@
           linkName = null;
           name = null;
           page = null;
  +        action = null;
           paramId = null;
           paramName = null;
           paramProperty = null;
  @@ -476,7 +493,7 @@
           String url = null;
           try {
               url = RequestUtils.computeURL(pageContext, forward, href,
  -                                          page, params, anchor, false);
  +                                          page, action, params, anchor, false);
           } catch (MalformedURLException e) {
               RequestUtils.saveException(pageContext, e);
               throw new JspException
  
  
  
  1.41      +15 -95    
jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java
  
  Index: FormTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- FormTag.java      13 Dec 2002 02:36:47 -0000      1.40
  +++ FormTag.java      29 Dec 2002 17:00:15 -0000      1.41
  @@ -86,6 +86,7 @@
    *
    * @author Craig R. McClanahan
    * @author Martin Cooper
  + * @author James Turner
    * @version $Revision$ $Date$
    */
   
  @@ -115,8 +116,8 @@
   
       /**
        * The index in the focus field array to receive focus.  This only applies if 
the field
  -     * given in the focus attribute is actually an array of fields.  This allows a 
specific 
  -     * field in a radio button array to receive focus while still allowing indexed 
field 
  +     * given in the focus attribute is actually an array of fields.  This allows a 
specific
  +     * field in a radio button array to receive focus while still allowing indexed 
field
        * names like "myRadioButtonField[1]" to be passed in the focus attribute.
        * @since Struts 1.1
        */
  @@ -504,13 +505,13 @@
           results.append(" name=\"");
           results.append(beanName);
           results.append("\"");
  -        results.append(" method=\"");
  -        results.append(method == null ? "post" : method);
  -        results.append("\" action=\"");
  -        results.append(response.encodeURL(getActionMappingURL()));
  -        results.append("\"");
  -        if (styleClass != null) {
  -            results.append(" class=\"");
  +         results.append(" method=\"");
  +         results.append(method == null ? "post" : method);
  +         results.append("\" action=\"");
  +         results.append(response.encodeURL(RequestUtils.getActionMappingURL(action, 
pageContext)));
  +         results.append("\"");
  +         if (styleClass != null) {
  +             results.append(" class=\"");
               results.append(styleClass);
               results.append("\"");
           }
  @@ -695,87 +696,6 @@
   
       // ------------------------------------------------------ Protected Methods
   
  -    /**
  -     * Return the form action converted into an action mapping path.  The
  -     * value of the <code>action</code> property is manipulated as follows in
  -     * computing the name of the requested mapping:
  -     * <ul>
  -     * <li>Any filename extension is removed (on the theory that extension
  -     *     mapping is being used to select the controller servlet).</li>
  -     * <li>If the resulting value does not start with a slash, then a
  -     *     slash is prepended.</li>
  -     * </ul>
  -     */
  -    protected String getActionMappingName() {
  -
  -        String value = action;
  -        int question = action.indexOf("?");
  -        if (question >= 0) {
  -            value = value.substring(0, question);
  -        }
  -        int slash = value.lastIndexOf("/");
  -        int period = value.lastIndexOf(".");
  -        if ((period >= 0) && (period > slash)) {
  -            value = value.substring(0, period);
  -        }
  -        if (value.startsWith("/")) {
  -            return (value);
  -        } else {
  -            return ("/" + value);
  -        }
  -
  -    }
  -
  -    /**
  -     * Return the form action converted into a server-relative URL.
  -     */
  -    protected String getActionMappingURL() {
  -
  -        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
  -        StringBuffer value = new StringBuffer(request.getContextPath());
  -        ModuleConfig config =
  -            (ModuleConfig) 
pageContext.getRequest().getAttribute(Globals.MODULE_KEY);
  -        if (config != null) {
  -            value.append(config.getPrefix());
  -        }
  -
  -        // Use our servlet mapping, if one is specified
  -        String servletMapping =
  -            (String) pageContext.getAttribute(Globals.SERVLET_KEY, 
PageContext.APPLICATION_SCOPE);
  -        if (servletMapping != null) {
  -            String queryString = null;
  -            int question = action.indexOf("?");
  -            if (question >= 0) {
  -                queryString = action.substring(question);
  -            }
  -            String actionMapping = getActionMappingName();
  -            if (servletMapping.startsWith("*.")) {
  -                value.append(actionMapping);
  -                value.append(servletMapping.substring(1));
  -            } else if (servletMapping.endsWith("/*")) {
  -                value.append(servletMapping.substring(0, servletMapping.length() - 
2));
  -                value.append(actionMapping);
  -            } else if (servletMapping.equals("/")) {
  -                value.append(actionMapping);
  -            }
  -            if (queryString != null) {
  -                value.append(queryString);
  -            }
  -        }
  -
  -        // Otherwise, assume extension mapping is in use and extension is
  -        // already included in the action property
  -        else {
  -            if (!action.startsWith("/")) {
  -                value.append("/");
  -            }
  -            value.append(action);
  -        }
  -
  -        // Return the completed value
  -        return (value.toString());
  -
  -    }
   
       /**
        * Look up values for the <code>name</code>, <code>scope</code>, and
  @@ -798,7 +718,7 @@
                   Globals.ACTION_SERVLET_KEY);
   
           // Look up the action mapping we will be submitting to
  -        String mappingName = getActionMappingName();
  +        String mappingName = RequestUtils.getActionMappingName(action);
           mapping = (ActionMapping) moduleConfig.findActionConfig(mappingName);
           if (mapping == null) {
               JspException e = new 
JspException(messages.getMessage("formTag.mapping", mappingName));
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to