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
Spring Portlet MVC - Unable to return JSON data from @ResourceMapping [SPR-7344] #12003
Comments
Josef Vychtrle commented Could please anybody collaborate ? I'm just pointing to the related forum threads: http://forum.springsource.org/showthread.php?t=83673 |
Josef Vychtrle commented This is also relevant issue http://stackoverflow.com/questions/4782971/handling-ajax-requests-with-spring-portlet |
Josef Vychtrle commented MessageConverters is also the concern, as in spring-web <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonConverter" />
<ref bean="marshallingConverter" />
<ref bean="atomConverter" />
</list>
</property>
</bean> |
Wendy Cameron commented I have had a close look at this problem and have actually implemented the I found that the org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter required enhancements in-line with: I also found that you needed to create I did not find you needed to make any changes to the MessageConverters. I did also implement:
And the call to getMediaTypes to:
I did not implement the BTW: I am the Same Wendy Cameron, I used to be in New Zealand however now contracting at Optus in Sydney. The following are my full code listings (the most complex to write was the AnnotationMethodHandlerAdapter. They reside in a package that fits in with out structure. This would obviously need to be changed to be put into correct structure for Spring.\ Replacement org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter
New PortletServerHttpRequest
New
Replacement org.springframework.web.servlet.view.ContentNegotiatingViewResolver
|
Wendy Cameron commented I also looked into supporting ResponseBody in the exception resolved and have created the following
I not the use with the ResponseStatus annotation it doesnt make sense to send an error redirect from a portlet so have lopped that code off. |
Wendy Cameron commented I also notice in order to support
Added and possibly need to create a portlet version of ResponseStatusExceptionResolver. |
Wendy Cameron commented Tested out the following code:
This appears to work adding a header I wonder if the solution for replacing sendError(statusCode, reason) is to create a header And set that instead. |
Michał Mela commented Was there any progress on the subject? I am especially interested in any development in the areas of
|
Eugene Petruhin commented I can't believe it's been open for 2.5 years and still no implementation is available. Please consider adding this functionality to the next release. |
Abdulrhman Nabih ALKoptan commented Any Update ? |
Patrick Bergner commented Happy new year, portlet people! Will we see the feature in the currently set 4.2 fix version or will it be bumped further and further? |
Ram Chinnakuzhandai commented Can we have this feature to be part of upcoming release + 1, at least. This has been sitting in the rack for a long time, and would be a huge help for the portlet community. |
Sébastien Deleuze commented Hi everybody, While working on this issue, I figured out that rendering JSON data from @ResourceMapping("json")
public ModelAndView listBooksJson() {
ModelAndView mav = new ModelAndView();
mav.addObject("books", bookService.getAllBooks());
mav.setView(new MappingJackson2JsonView());
return mav;
} You can test this sample application and have a look to this commit that introduced such functionality in the sample application. While this is not Thanks in advance for your feedbacks. |
Sébastien Deleuze commented Since there are no feedback more than one week after my last comment, I resolve this issue as "Works as designed" since it is already possible to return JSON in Portlets using Supporting also |
Ashish Sarin opened SPR-7344 and commented
In many scenarios it is required to support returning JSON data from the
@ResourceMapping
annotated method of controller. The@ResponseBody
and ContentNegotiatingViewResolver currently work only in the servlet environment.Affects: 3.0.3
Issue Links:
@Valid
@RequestBody
in a@ResourceMapping
method@resourceMapping
doesn't work.60 votes, 46 watchers
The text was updated successfully, but these errors were encountered: