On 6/14/05, Zarar Siddiqi <[EMAIL PROTECTED]> wrote:
> Where do you see the af.setURL(String) method in the ActionForward class?
> http://struts.apache.org/api/org/apache/struts/action/ActionForward.html
> 
> I had a similar problem where dynamic values needed to be passed in via an
> ActionForward but I wasn't able to find something as simple as you suggest.
> I had to store the values in session scope (because the ActionForward had
> redirect=true) and then clean up the session in my receiving code.
> 
> So you store the values that you are passing in session scope for a quick
> millisecond while you forward and then clean up once you're in the called
> method.
> 
> Zarar

This is the one that I use. To make it proper, it should be urlencoded too.

    /**
     * Creates ActionForward object with URL parameters.
     *
     * @param actionMapping  action mapping object
     * @param forwardName    mapping name
     * @param urlParams      array of "key=value" strings which
     *                       should be added to actionForward path
     *                       as HTTP GET parameters
     *
     * @return ActionForward object with GET parameters
     */
    public static ActionForward goForward(ActionMapping actionMapping,
                                          String forwardName,
                                          String[] urlParams)
    {
        /*
         * Find ActionForward object, defined in struts-config.xml
         */
        ActionForward actionForward = actionMapping.findForward(forwardName);
        if (actionForward == null) return null;

        /*
         * Build URL parameters
         */
        String actionPath = actionForward.getPath();
        if (actionPath != null) {
            for (int i = 0; i < urlParams.length; i++) {
                actionPath += i==0 ? "?" : "&";
                actionPath += urlParams[i];
            }
        }

        /*
         * Create new ActionForward object. Stuts does not
         * allow to modify ActionForward objects, statically
         * defined in struts-config.xml
         */
        ActionForward patchedForward =
                new ActionForward(actionForward.getName(),
                                  actionPath,
                                  actionForward.getRedirect()
                );

        return patchedForward;
    }

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

Reply via email to