Foren

Portlet URL forged in a XSL

Gael de Chalendar, geändert vor 15 Jahren.

Portlet URL forged in a XSL

New Member Beiträge: 3 Beitrittsdatum: 25.02.09 Neueste Beiträge
Hello,

I'm porting an existing application based on xml data and xsl pages. As a first step, I want to make it work with the less changes as possible. So, currently, the portlets use a jsp to call the xsl transform like that:

Portlet:

    String jspName = getPortletConfig().getInitParameter("jspView");
    PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(jspName);
    rd.include(req,res);


JSP:

<c:import url="/data.xml" var="d" charEncoding="UTF-8" />
<c:import url="/datachange.xslt" var="s" charEncoding="UTF-8" />
<x:transform xml="${d}" xslt="${s}">
  <x:param name="submitUrl" value="${submitUrl}" />
  <x:param name="v" value="${v}" />
</x:transform>



In the xsl, there is links with forged URLs using data coming from the xml files as parameters, like that:
XSL:

 <xsl:template name="t">
  <xsl:param name="x" />

             <a href="thispage?v={$x}" border="0">
</a></xsl:template>


So, in the port, I have to forge portlet urls inside the xsl sheet. Itried several solutions, like this one:
Modified XSL:

        <xsl:variable name="href"><portlet:renderurl portletmode="view">
                <portlet:param name="v" value="{$x}" />
                </portlet:renderurl></xsl:variable>

              <a href="{$href}" style="text-decoration:none">
</a>


But that don't work. So, is there a possibility in my xsl to forge poprtlet URLs to be used in links in the generated page ?
Gael de Chalendar, geändert vor 15 Jahren.

RE: Portlet URL forged in a XSL

New Member Beiträge: 3 Beitrittsdatum: 25.02.09 Neueste Beiträge
I was finaly able to find a solution/workaround myself. Being a newbie with these tools, I don't know if I did the right way.

In the Java code, Ido:

    req.setAttribute("a",req.getParameter("a"));


In the JSP:

<jsp:usebean id="a" class="java.lang.String" scope="request" />


<c:set var="ns"><portlet:namespace /></c:set>


<x:transform xml="..." xslt="...">
... 
 <x:param name="a" value="${a}" />
  <x:param name="namespace" value="${ns}" />
</x:transform>



and in the xsl:

              <xsl:variable name="a">
                <xsl:value-of select="$d" />
              </xsl:variable>
              
              <a href="{$submitUrl}&amp;{$namespace}a={$a}" border="0" style="text-decoration:none" target="_top">
</a>


I would prefer a way to programatically change the submitUrl or the request parameter, but I did not find anything to do that, except maybe the use of Java code in the xsl, but I was not able to do that with liferay.