Skip to main content

URL to use in Accordian?

4 replies [Last post]
Joined: 2007-06-17

I have a JSF portlet where I want to use an Accordion. Since a portlet lives inside a portal, all URL's are relative to the portlet instance. To get a reference to a resource in the war file, I can do like this:
renderResponse.encodeURL( renderRequest.getContextPath() + "/resources/images/text.gif")
in my JSP file, and it will give me the following URL:
The problem is to refer to a JSP to use in i.e an accordion. I've tried the following, with no luck:

I guess the URL must be an absolute URL? Any input on how to achive this? I want the content of each panel in the accordion to be rendered from two different jsp's.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-07-31


You will need to go through the faces servlet which invokes a phase listener to get resources out of a war file.

This means you'll need to include /faces/ or similar URI to where you have your faces servlet mapped to.

More than likely:


The accordion widgets use the built in XMLHttpRequet objects as is so if you start a URL with a "/" this will mean the server root so it is best to use absolute URLs whenever possible and relative URLs like the one above when that is not possible.

You will also need to make sure that the resources you are trying to access are packaged correctly in a jar file in the classpath.

for faces/resources/images/text.gif to be accessible for example you will need to place text.gif
in a jar file under the directory /META-INF/resources/images/text.gif

I would suggest you look at how we put together the Dojo JSF unit test application which you may find at:

One other thing you can do is look at the page source how the URLs are being generated for the jMaki resources like the jmaki.js which are loaded from the classpath in JSF.

Joined: 2007-06-17

Hi again!

The example with the resource text.gif was just an example of how I already fetch resources from a war-file.
My actual problem is to create the url in the accordion widget. Let me give you two examples, one working, and not that's not working.

part of my web.xml:


Faces Servlet


Faces Servlet

My war-file tree structure:
   (and all other jmaki resources..)
      (my JSF backing bean)
      Search_view.jsp (my initial jsp used in my portlet, and where the jmaki widget I'm trying to use is referred to, as shown below)
      (all dependent libraries)

Then my Search_view.jsp:

(on top of the jsp)
<%-- jMaki taglib --%>
<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsp" %>

<%-- JSF taglibs --%>
<%@taglib prefix="f" uri=""%>
<%@taglib prefix="h" uri=""%>

<%-- portlet taglibs --%>
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="" prefix="portlet"%>

<%-- A portlet custom tag exposing three portlet API objects:
- RenderRequest object, where I can get the context path to the actual portlet by calling renderRequest.getContextPath()
- RenderResponse object
- PortletConfig object

<%PortletPreferences prefs = renderRequest.getPreferences();%>

Working example which will display the content of the two jsp files inside the accordion:

Non-working example where I have replaced the hardcoded context path, /portlet-search-java :

This isn't working, and will display
Unable to load URL <%=renderRequest.getContextPath()%>/jsp/textdetails.jsp.
Unable to load URL <%=renderRequest.getContextPath()%>/jsp/summary.jsp.

So, the problem is that renderRequest.getContextPath() isn't replaced by /portlet-search-java when the widget is rendered.

Joined: 2007-06-17

I'm also having the same problem trying to use the yahoo.tabbedview widget. When referring to an existing jsp in my war file, it can't find it unless I hardcode the portlet context path into the URL, like this:
{label : 'My Tab', content : 'Some Content'},
{label : 'My Tab 2', include : '/portlet-search-java//jsp/test.jsp' },
{label : 'My Tab 3', content : 'More Content', selected: true}
}" />

I've looked at the tabbelview-jsf.jsp example from the downloaded jmaki-dojo-jsf war file, where you do it like this:
{label:'Tab 1', url: 'tab1-jsf.faces'},
{label:'Tab 2', url: 'tab2-jsf.faces'},
{label:'Tab 3', url: 'tab3-jsf.faces'},
{label:'Static Tab', content: 'Tab 2 Content'} ]}" />

and in web.xml you have the servlet-mappings

Faces Servlet

Faces Servlet

but still I'm not able to retrieve the jsp's.

Joined: 2003-07-31


I'd suggest using the latest version of jMaki and use include 'include' instread of 'url' if you are using the latest.

Is normally I would think your FacesServlet mapping not set right but it seems alright..

Are the JSP / JSF pages hosted in the same context? If not you are going to have propblems with the same origin policy.

You should be able to use fully qualified URLs to the resources outside of the domain if you set a property 'iframe' to true which will use iframes instread and allow you to include external content.

For more on the same origin policy see: