Several months ago I wrote an
article on using AJAX with portlets. There were a couple of comments that came in that I wanted to try to address.
1. Multiple AJAX portlets on the same page will have their Javascript conflict.The Javascript variables and functions should be namespaced to avoid conflicts between multiple AJAX portlets on the same page. For instance,
var <portlet:namespace/>portletReq;
function <portlet:namespace/>asynchGet(updateURL){ ...
Generates Javascript something like:
var AJAXPortlet_AJAXPortlet_AJAXPortletportletReq;
function AJAXPortlet_AJAXPortlet_AJAXPortletasynchGet(updateURL){ ...
|
In this way, each portlet that might include similar Javascript functions (or variables) would have them namespaced appropriately to avoid conflicts.
2. An AJAX portlet will not work with WSRP.The reference to the InvoiceServlet must be encoded in order to be resolved correctly with WSRP. For instance,
<%=renderResponse.encodeURL("/AJAXPortlet/InvoiceServlet")%>
Returns something like:
http://host.com/portal/wsrpconsumer/resourceproxy?
wsrp_url=http%3A%2F%2Fhost.com%2FAJAXPortlet%2FInvoiceServlet&
wsrp_rewrite=false&
namespace=N_JSPTabContainer_WSRPAJAXPortlet&
portal_server_url=http%3A%2F%2Fhost.com%2Fportal&
cookie_key=5VR2N5IAAAAABAMTGHTQAAA_cookieHandle
|
However, the encoded reference to the InvoiceServlet needs the
invoice parameter added. That will require some manipulation of the encoded URL string returned from renderResponse. In our case you will have to search the returned URL string for the
wsrp_url paramater and insert
"?invoice=" + select.value. All this would have to go in the
selectInvoice Javascript function. This should resolve the problem where this AJAX portlet does not work with WSRP.
Trackback URL: http://blogs.sun.com/gregz/entry/ajaxportlet_updates
Posted by Craig Doremus on February 01, 2006 at 03:49 PM MST #
Posted by GregZ on February 03, 2006 at 03:07 PM MST #
Posted by Craig Doremus on February 22, 2006 at 05:20 AM MST #
Posted by GregZ on February 23, 2006 at 09:51 AM MST #
Posted by Arash Rajaeeyan on August 13, 2006 at 05:46 AM MDT #
Posted by GregZ on August 16, 2006 at 05:14 PM MDT #
Posted by Paul Tran on October 19, 2006 at 02:06 PM MDT #
Posted by GregZ on October 19, 2006 at 04:28 PM MDT #