-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support View annotation on Controller methods returning non void types (except Viewable) #33
Comments
Comment by beryozkin_sergey: Please assign to Santiago |
Comment by Santiago Pericas-Geertsen: It is certainly possible to consider using @view this way. However, MVC is now "reserving" the return type for view (or Viewable). In fact, the current behavior in the latest spec is to call toString() on a returned object to get a view path. Having said that, perhaps there should be a new Viewable constructor that takes a name/model pair to avoid the need for Models in that case. As for using a controller to return non-HTML representations, it's better to separate that into two: a resource and a controller at this point. |
Comment by beryozkin_sergey: The whole idea of this proposal is for users be able to avoid dealing directly with all the (JSP/etc) paths and MVC API (Viewable) directly. I'm not sure what is wrong with such an approach, at the very least it can be considered a reasonable design practice... I'm not against giving users a direct/fine-grained control but a less 'intrusive' option is not bad at all ? You mentioned the current API calls toString() but specifying a rule that if @view is available on a method returning a type (non-void, non-Viewable) then it is a not a resource path but the content can work ? It would simply relax the current statement that View is ignored for non-void responses without introducing any contradiction into the text. It would integrate well with all the spec ? Please ignore my reference to CDI here. |
Comment by Christian Kaltepoth: Let me explain the reason why I suggested to call However, I also see that providing some other default behavior could make sense. What we are currently talking about is something like this, right? {quote} I see that this may also be a reasonable default behavior. BUT it basically prevents to implement typesafe navigation as I described before. |
Comment by Santiago Pericas-Geertsen: I generally like the suggestion, but I think we need to be careful not to add more complexity in the form of rules that developers would need to understand that don't really add new capabilities to the API. Sometimes adding more ways of doing something is not necessarily a good thing. Having said that, if we don't need name in @view, and use of a default name as suggested, that may be a little better. |
Comment by Christian Kaltepoth: I agree that we should avoid too much complexity. If we add support for something like this, we shouldn't support customizing the name. I see no good reason for this feature. We should choose one of these approaches to generate the name:
|
Comment by beryozkin_sergey: Hi Christian, Santiago Thanks for the comments, I agree having an extra View name attribute adds to the complexity (it can always be reviewed later on if needed should users start asking). Cheers, Sergey |
I don't think that we can provide this feature in version 1.0. So moving this to "Future". But we should make sure that something like this can be implemented later without breaking backwards compatibility. |
Friday Aug 07, 2015 at 10:04 GMT
Originally opened as mvc-spec/mvc-spec#63
Original issue MVC_SPEC-51 created by beryozkin_sergey:
given that it is very typical in JAX-RS to have a single method with multiple Produces values.
I think this style is very important to support because it is more natural to write than having to use a @nAmed sync such as Greetings in the spec example or dealing with Models directly, in both cases the application directly having to be aware of the MVC semantics.
IMHO it is not difficult to support it at a spec level. It is also another good example why a strict CDI binding requirement may need to be relaxed and limited to a subset of styles.
The text was updated successfully, but these errors were encountered: