Results 1 to 7 of 7

Thread: Redirect question

  1. #1
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default Redirect question

    I know, there is an abundance of questions cencerning the redirct problem area, but..


    After submitting a form, a Controller implementation returns 'successView'
    So far so good. But I need to include a string with a message to be displayed first thing in this success view.

    But; my 'successView' also is a redirect one, which seem to cause this string so carefully sent in the Model object.

    How do one solve this?

    RedirectView, and in that case; could you give an example of code?

    Thanks!
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  2. #2
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    Hmm..

    "But; my 'successView' also is a redirect one, which seem to cause this string so carefully sent in the Model object. disappear"
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  3. #3
    Join Date
    Aug 2004
    Posts
    25

    Default

    If you're using a redirect, any information you want to send to the view has to be included as a request parameter.

  4. #4
    Join Date
    Aug 2004
    Location
    Boston MA
    Posts
    27

    Default

    From the JavaDoc:

    "View that redirects to an internal or external URL, exposing all model attributes as HTTP query parameters."

    I would assume then you could obtain this string using request.getParameter("strSuccess") or whatever you called it in your model. Although this would assume you are using JSPs for a view, if not, you will have to consult your view documentation on how to obtain parameters from the query string.

    Also, an alternative would be to place the string in the session object, depending on what your session requirements are.

  5. #5
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    OK, thanks.

    Problem is I'm terminating the HttpSession before rendering the view. Would like to place the string to be displayed in the request.

    I understand that RedirectView has methods for adding parameters to the request. Is this correct?
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  6. #6
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    Have I got it right?

    The code

    Code:
    RedirectView view = new RedirectView("/welcome.htm", true);
    		Map map = new HashMap();
    		map.put("nextMsg","Avvikelsen har sparats");
    		view.setAttributesMap(map); 
    		resultView = new ModelAndView(view, errors.getModel());
    		return resultView;
    results in a redirection to

    /<whatevercontext>/welcome.htm?nextMsg=Avvikelsen har sparats

    ??

    The it should be possible to retrieve with JSTL like this

    Code:
    <body 
    <c&#58;if test="$&#123;not empty requestScope.nextMsg&#125;">
    	onLoad="javascript&#58; modalDialog&#40;$&#123;requestScope.nextMsg&#125;&#41;; return true;">
    </c&#58;if>
    I can't get it to work properly. Any ideas what I'm missing here?
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  7. #7
    Join Date
    Aug 2004
    Location
    Roeselare, Belgium
    Posts
    16

    Default

    I don't think setAttributes is correct. This method is for static parameters.

    I think you need to do something like

    Code:
    RedirectView view = new RedirectView&#40;"/welcome.htm", true&#41;; 
    Map map = new HashMap&#40;&#41;; 
    map.put&#40;"nextMsg","Avvikelsen har sparats"&#41;; 
    map.putAll&#40;errors.getModel&#40;&#41;&#41;;
    resultView = new ModelAndView&#40;view, map&#41;;
    return resultView;
    Pieter Coucke
    Onthoo.com

Similar Threads

  1. Forgot password (e.g. secret question) using Acegi
    By lowerymb77 in forum Security
    Replies: 1
    Last Post: Oct 16th, 2005, 10:46 PM
  2. Redirect expose jsp path?
    By jackysee in forum Web
    Replies: 2
    Last Post: Jun 28th, 2005, 10:01 PM
  3. Redirect issue
    By neeraj_cmu in forum Web
    Replies: 4
    Last Post: Jun 7th, 2005, 09:38 AM
  4. redirect: prefix and view resolver
    By sjivan in forum Web
    Replies: 2
    Last Post: Dec 20th, 2004, 03:28 PM
  5. Replies: 6
    Last Post: Oct 8th, 2004, 02:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •