开发者

Return a JSON object from doview method of a basic portlet

开发者 https://www.devze.com 2023-01-15 07:33 出处:网络
I want to return a JSON object from the doview method of a basic portlet to dojo.rawXhrPost (开发者_如何学Pythonhandle as:xml) method of Javascript. How to do that?I am going to guess that you are wor

I want to return a JSON object from the doview method of a basic portlet to dojo.rawXhrPost (开发者_如何学Pythonhandle as:xml) method of Javascript. How to do that?


I am going to guess that you are working with Java portlets. There may be other solutions specific to your container, but you don't say what that is.

The correct way to serve a resource from a portlet context is via the serveResource method by using a resource URL. If you're still using JSR 168 portlets, you'll have to resort to using a servlet.

Any AJAX calls to a render URL to invoke doView are likely to re-render all your page's portlets and the surrounding theme. You'll have to deal with a load of junk data in your JavaScript and there may be unintended side-effects.


The way to handle ajax calls is to use resourceURL.In serveResource send the result of ajax call as response.getWriter().write(result). But if you want to use renderURL or actionURL you cannot handle the ajax calls as they'll load entire the portal page ( or can say as all the portlets in the portal page are loaded )

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号