WebSphere Portal Server - Encode URL with <h:outputLink> in WSRP Portlets

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > August 2007 > Encode URL with <h:outputLink> in WSRP Portlets





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Encode URL with <h:outputLink> in WSRP Portlets

2007-08-16, 7:21 am

Hi All,

Our project uses WSRP Portlets for development.
At a plain jsf level this does not pose a problem at all for me.
But in our project we use WSRP Portlets.Which has a producer and consumer framework.
Its a very simple requirement there is a pdf icon onclick of that i need to download the report from the database.

I used <h:outputLink> in the following manner to hit the download servlet.
But i need to encode the URL we do in our javascript.
String encodedURL_dtd = response.encodeURL(request.getContextPath()+ "/DownloadServlet");


<h:datatable var="item" value="databean.list" >
...............
<h:outputLink rendered="#{(item.strreportFormat == 'P') value="#{facesContext.externalContext.requestContextPath}/DownloadServlet">

<h:graphicImage value="/images/icon/icon_small_pdf.gif" alt="View Reports"></h:graphicImage>
<f:param id="id1" value="item.id" />
<f:param id="sys1" value="item.sysName" />
</h:outputLink>
.......
</h:datatable>


Any suggestions are welcome....
yurykats

2007-08-16, 1:25 pm

You can use the same EL expression in the JS code if it's in the tag's attribute.

2007-08-17, 1:23 pm

I hope i understood you correctly but i tried to do something like this and it gave me the following error.
JSPG0124E: Custom tag attribute value cannot be runtime expression. value: "[%= renderResponse.encodeURL(renderRequest.getContextPath() + "/ReconProcessorServlet") %]"

When i tried replacing this.
value="#{facesContext.externalContext.requestContextPath}/ReconProcessorServlet"> with
value="<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/ReconProcessorServlet") %>" >

I couldn't find any corresponding EL for renderResponse.encodeURL.

yurykats

2007-08-17, 1:23 pm

You can't use JSP expressions, only EL expressions on JSF tags, so <%= isn't goping to work.

Maybe I didn't quite understand what you are trying to do. You mentioned JavaScript, so I thought you were trying to move the same EL expression you had for 'value' into some JavaScript code.

If you are just trying to replace the expression for value, then what you can do is use a method of a managed bean (pagecode bean, for example) that does what you need and use that method for the expression on the value attribute.

For example:
value="#{pc_MyPage.servletUrl}"
and
public String getServletUrl() {
return ((RenderRequest)getFacesContext().getExternalContext().getRequest()).encodeURL(... and so on
}
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com