I think this is why frameworks like VRaptor return a Result object instead.
I wish Enums supported inheritance... But perhaps we define an Outcome
object that has properties like redirect, etc., and the value is either an
enum or a String.
___
Kito D. Mann | @kito99 | Author, JSF in Action
Virtua, Inc. |
http://www.virtua.com | JSF/Java EE training and consulting
http://www.JSFCentral.com | @jsfcentral
+1 203-998-0403
* Listen to the Enterprise Java Newscast: *http://
<
http://blogs.jsfcentral.com/JSFNewscast/>enterprisejavanews.com
<
http://ww.enterprisejavanews.com>*
* JSFCentral Interviews Podcast:
http://www.jsfcentral.com/resources/jsfcentralpodcasts/
* Sign up for the JSFCentral Newsletter:
http://oi.vresp.com/?fid=ac048d0e17
On Fri, Apr 17, 2015 at 11:11 AM, Bauke Scholtz <balusc_at_gmail.com> wrote:
> I like the general idea. But how would you toggle redirect=true|false when
> returning an enum?
>
> Cheers, B
>
> On Fri, Apr 17, 2015 at 4:51 PM, Kito Mann <kito.mann_at_virtua.com> wrote:
>
>> One of the things I've never really liked about JSF are the string-based
>> outcomes. As a matter of fact, I often use enums instead. What do people
>> thing about providing a type-safe alternative like the one brought up on
>> the MVC EG below?
>>
>> ---------- Forwarded message ----------
>> From: Christian Kaltepoth <christian_at_kaltepoth.de>
>> Date: Fri, Apr 17, 2015 at 10:38 AM
>> Subject: [jsr371-experts] Re: [mvc-spec users] Re: Sample application
>> To: "<jsr371-experts_at_mvc-spec.java.net>" <
>> jsr371-experts_at_mvc-spec.java.net>
>>
>>
>> I agree with Rodrigo that we could think about ways that are more
>> typesafe.
>>
>> I'm very impressed by what is possible with VRaptor4:
>>
>> http://www.vraptor.org/en/docs/ten-minute-guide/#create-form-redirecting
>> http://www.vraptor.org/en/docs/view-and-ajax/#redirect-and-forward
>>
>> Perhaps someone from the VRaptor could describe it in more detail?
>>
>> Christian
>>
>>
>>
>>
>> 2015-04-17 16:05 GMT+02:00 Rodrigo Turini <rodrigo.turini_at_caelum.com.br>:
>>
>>> IMO it's not that nice depending on a String to do this job. A simple
>>> typo will cause problems. Why not working in a type safe solution?
>>>
>>> just like result.redirectTo("/items") or even result.forwardTo("/items")
>>> .
>>>
>>> What do you think? And Christian, great work! Thanks for doing this.
>>>
>>> Rodrigo Turini
>>> Caelum | Ensino e Inovação
>>> www.caelum.com.br
>>>
>>> 2015-04-17 10:56 GMT-03:00 Kito Mann <kito.mann_at_virtua.com>:
>>>
>>> (2) Redirect:
>>>>>
>>>>> /*
>>>>> * An Ozark specific way of doing redirects. Should this go into
>>>>> the spec?
>>>>> * Redirecting here is fine as the method doesn't need to render
>>>>> any
>>>>> * messages for the user which would get lost during the redirect.
>>>>> */
>>>>> return "redirect:/items";
>>>>>
>>>>> Yes, the intent was to propose this for the MVC spec. Seems pretty
>>>>> convenient. Comments?
>>>>>
>>>>
>>>> We should consider doing this like JSF, since there is precedence. JSF
>>>> does it like this:
>>>>
>>>> return "/items?faces-redirect=true";
>>>>
>>>> so we could do:
>>>>
>>>> return "/items?mvc-redirect=true";
>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>>
>> --
>> Christian Kaltepoth
>> Blog: http://blog.kaltepoth.de/
>> Twitter: http://twitter.com/chkal
>> GitHub: https://github.com/chkal
>>
>>
>>
>