Skip to content
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

YogaSpringView selects random model attribute to render #234

Open
nikosk opened this issue Dec 18, 2013 · 3 comments
Open

YogaSpringView selects random model attribute to render #234

nikosk opened this issue Dec 18, 2013 · 3 comments

Comments

@nikosk
Copy link

nikosk commented Dec 18, 2013

YogaSpringView randomly selects the first available model attribute although it might not be the intended one.

Steps to reproduce:

  1. Create method in controller with the following signature:
@RequestMapping(method = RequestMethod.GET)
    public List<Entity> list(@Valid ParamsDTO params) {
  1. The model passed to the view will now contain at least the attribute for the bound ParamsDTO object, a BindingResult object and an attribute for the returned value in that order. In this case the ParamsDTO object will be rendered.

Relevant source code:

YogaSpringView.java:32

yogaView.render( request, response, model.isEmpty() ? null : model.values().iterator().next(), response.getOutputStream() );

Solutions (?)

Just out of the top of my head:

a) provide an annotation and have the view scan the model for objects with that annotaton? (But then what about collections? maybe pre-register entities for serialization via annotations or spring config and select the collection if its generic type is in the list of registered types?)

b) provide a filter that will scan the model for key patterns i.e. entity*. This could work because Spring has a mechanism to create names for model attributes, for example when the attribute is a list it will name it "[generic type of the list]List" i.e.: customerList.

@nikosk
Copy link
Author

nikosk commented Dec 18, 2013

#232 is relevant to this issue

@sduskis
Copy link
Member

sduskis commented Dec 18, 2013

OK I'll try to see if we're can replicate some functionality from
SpringMVC. Thank you for the catch.

-Solomon
On Dec 18, 2013 5:46 PM, "nikosk" notifications@github.com wrote:

#232 #232 is relevant to this
issue


Reply to this email directly or view it on GitHubhttps://github.com//issues/234#issuecomment-30888991
.

@mjason3
Copy link

mjason3 commented May 28, 2014

Any updates on this? when i add Yoga, all my PUT and POST are returning BindingResult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants