|
From: Colin S. <col...@ex...> - 2004-11-10 19:18:40
|
That should still work fine. This is an indirect subclass of
UrlBasedViewResolver, where the 'redirect:' prefix support was actually
added...
Dion Almaer wrote:
>Actually I just have a
>org.springframework.web.servlet.view.velocity.VelocityViewResolver right
>now.
>
>D
>
>-----Original Message-----
>From: Colin Sampaleanu [mailto:col...@ex...]
>Sent: Wednesday, November 10, 2004 11:00 AM
>To: spr...@li...
>Subject: Re: [Springframework-developer] successView changes
>
>No. I am assuming right now you are using InternalResourceViewResolver.
>All you would need to do is define the view name literal (which should still
>be in the config, not hardcoded in the controller) as
>
>redirect:viewFoo.html
>
>in this particular case. Then the controller can just do
>
>return new ModelAndView(getSuccessView(), "id", theId));
>
>InternalResourceViewResolver (or rather its superclass
>UrlBasedViewResolver) will see the 'redirect:' prefix, and create and use a
>RedirectView itself. So the nice thing is that that controller no longer
>needs to know that there is a redirect. Now keep in mind that there's
>limitations to the opacity though, in terms of whether control will go to an
>internal view or to a redirect, since on a redirect all the model params
>need to go on the URL. So same as before, you can't stick in any arbitrary
>complex property into the model and expect to be able to do a redirect...
>
>Colin
>
>
>Dion Almaer wrote:
>
>
>
>>So to use the new redirect: I would change from onSubmit to
>>doSubmitAction right?
>>
>>And then it will magically put the form object as the model and will
>>create the url from that?
>>
>>Cheers,
>>
>>Dion
>>
>>-----Original Message-----
>>From: Colin Sampaleanu [mailto:col...@ex...]
>>Sent: Wednesday, November 10, 2004 8:08 AM
>>To: spr...@li...
>>Subject: Re: [Springframework-developer] successView changes
>>
>>Also, if you're willing to go to CVS code (which will be 1.1.2 in a few
>>days), you can rely on the new redirect: prefix support, and get away
>>
>>
>>from the controller knowing that a RedirectView is used at all.
>
>
>>Dion Almaer wrote:
>>
>>
>>
>>
>>
>>>Colin -
>>>
>>>You are the man :)
>>>
>>>return new ModelAndView(new RedirectView(getSuccessView(), true),
>>>"id", theId));
>>>
>>>Is all I needed.
>>>
>>>Cheers,
>>>
>>>Dion
>>>
>>>
>>>-----Original Message-----
>>>From: Colin Sampaleanu [mailto:col...@ex...]
>>>Sent: Tuesday, November 09, 2004 11:03 PM
>>>To: spr...@li...
>>>Subject: Re: [Springframework-developer] successView changes
>>>
>>>Dion,
>>>
>>>I presume you are actually using this view as a RedirectView? That's
>>>the only thing that makes sense, given that you're playing around with
>>>the name as if it's a URL, and the fact that it has .html at the end;
>>>I presume this is mapped to another controller?
>>>
>>>In any case, you shouldn't be manipulating the view name at all. What
>>>you should be doing is just setting the id as a model object, and
>>>letting RedirectView build the URL for you:
>>>return new ModelAndView(new RedirectView(getSuccessView(), true),
>>>"id", theId));
>>>
>>>Now do you have a problem with the controller itself knowing the name
>>>of the param?
>>>
>>>Colin
>>>
>>>
>>>Dion Almaer wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>Hi guys -
>>>>
>>>>I run into the following use case a lot:
>>>>
>>>>- Create a new FOO
>>>>- On success I want to SHOW that FOO
>>>>
>>>>Ideally I would want to:
>>>>
>>>><property
>>>>name="successView"><value>viewFoo.html?id=$request['id']</value></pro
>>>>p
>>>>e
>>>>rty>
>>>>
>>>>viewFoo.html?id=$request['id]
>>>>
>>>>Could of course be something else like: id=$id or
>>>>$request.getParameter("id") or whatever.
>>>>
>>>>But it would be really nice to be able to do something like this
>>>>instead of having my controller do a
>>>>
>>>>.... getSuccessView() + "id=" + theId ....
>>>>
>>>>If there another clean way to do this that I am missing?
>>>>
>>>>Cheers,
>>>>
>>>>Dion
>>>>
>>>>
>>>>
>>>>
|