Portlet URL Generation From AJAX Servlet

人走茶凉 提交于 2020-01-04 11:03:03

问题


I am trying to modify a portlet to load data for a table over AJAX because the WS calls take a ridiculous amount of time to complete. The table is basically an overview with one entry per table row and a link in each row to more detailed information on the entry.

Here is how I am currently creating the URLs for each row in the table:

<portlet:renderURL portletMode="VIEW" windowState="maximized" var="showURL">
    <portlet:param name="id" value="${entry.ID}"/>
</portlet:renderURL>

I have created an AJAX servlet to receive the AJAX calls and return JSON which will be added to the table dynamically using jQuery callbacks. The servlet works fine and the rows are added to the table with no real problems. The problem I am having is currently with the links that should be in the table.

My question is how do I mimic the above JSP code in the servlet to generate the correct portlet URLs?!?! I'm a bit new to portlets and their URLs seem to be a serialized mess of gibberish to me.


回答1:


Take a look at this JSP page for an example of how this is done -- one good method, anyway. Look at the definition for editPortletUrl near the top of the page, then look at how it's used later.

There's a PORTLETID token embedded in the URL, which is later replaced with a real value by JS.

This portlet uses Fluid Infusion, which I recommend highly for powerful, accessible, higher-order widgets based on jQuery.

Brian said

Thanks for the idea. I tried doing what you had but I don't see how the JS will be able to sub the real ID for the placeholder. Using renderURL I get this in the JS:

var baseShowUrl = "/wps/myportal/portalname/!ut/p/c5/hY7NCoJAFEafpSe4X_Pf0hJ0Sied6M9NCEVIWS2ioqdvwo2b6H7LczhcqijsUj-aY31vrpf6TFuq9C52yJ32DAZCworYz_V0DIDRqq1fTdu8D_tOFUra0oqgZoKD-VLabBpzQPXVDVWqV9UjE6qFzGcmD1XQ-vtHz0jSQgVjmXnr5xxm2HH8uAgdnyRRKnQGJJpJMCcXLI9WSLj6wwW59Noe6NYafjr59BkNBh8sH-CA/dl3/d3/L0lDU0NsQ1FvS1VRIS9JSFNBQ0l3a1FBd3FibTZtLzRDMWI5WUF4RW1TUVVnZyEvN19ETjBNTjdSMjA4MDQ1MEk0RFJPN0pCMDAwMi92aWV3L0NPTlRSQUNUSUQ!/";

UPDATE from Drew Wills

Could you show me how your or tag?



来源:https://stackoverflow.com/questions/2222948/portlet-url-generation-from-ajax-servlet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!