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

POST Support #232

Open
cepage opened this issue Nov 20, 2013 · 0 comments
Open

POST Support #232

cepage opened this issue Nov 20, 2013 · 0 comments
Assignees

Comments

@cepage
Copy link
Member

cepage commented Nov 20, 2013

From Eric Meltzer:

When using method POST, org.skyscreamer.yoga.springmvc.view.YogaSpringView renders org.springframework.validation.BindingResult instead of object returned from controller.
It looks like the order of the objects in the Model are different for POST.

// I’m doing something like this

@RequestMapping(value = "/test", method = RequestMethod.POST)
public List test() {
return domainObjectDao.findAll();
}

original render method

@Override
public void render( Map<String, ?> model, HttpServletRequest request, HttpServletResponse response )
        throws Exception
{
    response.setContentType( getContentType() );
    yogaView.render( request, response, model.isEmpty() ? null : model.values().iterator().next(), response.getOutputStream() );
}

updated render method

@Override
public void render( Map<String, ?> model, HttpServletRequest request, HttpServletResponse response )
        throws Exception
{
    response.setContentType( getContentType() );
    Object value=null;
    if(!model.isEmpty()){
        Iterator valueIterator =  model.values().iterator();

        while(valueIterator.hasNext()){
            value = valueIterator.next();
            // when posting the BindingResult comes first
            if( !(value instanceof org.springframework.validation.BindingResult) ){
                yogaView.render( request, response,  value , response.getOutputStream() );
                return;
            }
        }
    }
    yogaView.render( request, response,  null , response.getOutputStream() );
}
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

1 participant