> > > Another solution (not tested either) could be to set a render > parameter on the Jetspeed Request Context, and then just check for it > with a JSP, so that you don't include the script twice > > <%@page import="org.apache.jetspeed.request.RequestContext"%> > ... > <% > RequestContext ctx = > request.getAttribute(RequestContext.REQUEST_PORTALENV); > if (ctx.getAttribute("com.griffith.app.googleportletRendered") == null) { > ctx.setAttribute("com.griffith.app.googleportletRendered", "true"); > %> > <script type="text/javascript" language="javascript" > > src="/googleportletapp/googleportletapp/googleportletapp.nocache.js"></script> > <% } %> > I tried this approach to avoid duplicate common code in my application and ran into interesting scenario. Say i have two portlet in my PSML portletA and portletB. In psml file the PortletA is set to display at row=0 and col=0 while PortletB at row=0 and col=1. However <fragment> entry for portletB is written before the <framgment> entry of portletB in PSML page.
Now J2 will request portletB first and common resources are rendered as flag attribute is null initially. Then J2 request portletB. Now while merging output of two portlets, the output is written in reverse order occording to row and col position in PSML page. This put the included common code/script (that was generated byportletB) at end of page while output of portletA is on top of page. If portletA tries to use a function/object from common code/script it throws Javascript error becuse required javascript is not included in page at that point. Reversing the <fragment> definition in psml page fixes the issue.