tags:

views:

315

answers:

1

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  A: 

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?

Drew Wills
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!/";
Brian McManus
The tag is identical to the on in the original question but with value replaced with "ENTRYID". It appears that I can leave out the parameter completely though and simply tack on a query string like ?id=foo in the javascript and everything works.
Brian McManus
I'm glad you found a solution, but it stinks that neither your solution nor mine is standards-compliant. A protlet written with my approach that works on my portal (uPortal) wouldn't work on yours and _vice versa_.
Drew Wills