cancel
Showing results for 
Search instead for 
Did you mean: 

Template engine object args. Solved

joksy
Champ in-the-making
Champ in-the-making
Hi Guys,

I have red from the wiki about the object args for retrieving the URL params.
The point is that in the wiki says :
If you are accessing a template via the Template Servlet then the following special object is also available:
So is not my case. (becuase i have an error like this Errore durante il processo del modello "Expression args is undefined on line 141)

My template is for the dashbord, and i have create the custom jsp for accessing it.

<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<r:template template="/alfresco/templates/tableTest.ftl"/>

Exist a way to retrieve the URL parameters in this case for instance when I make this http request ??
http://localhost:8080/alfresco/faces/jsp/dashboards/container.jsp?index=0.

Many Thanks to all guys could be very very useful.
Have a nice day
1 REPLY 1

joksy
Champ in-the-making
Champ in-the-making
Hi guys,
After some days i finally was able to get URL parameters in freemarker in the dashboards space.
And since I see some post about this topic i will want to provide my solution and maybe some expert can tell me if could be a good one.

First of all
We have to prepare the webscript, a really simple one.
-Go to CompanyHome /data directory / webscript extension. (in web-client)

Start with the xml descriptor file. Which tell what is the argument passed in this case value.
tabella.get.desc.xml

<webscript>
      <shortname>ParametersGet</shortname>
      <description>Passing Value Tabellone</description>
      <url>/tabella?value={nameArgument}</url> 
   <transaction>required</transaction>
   <format default="html">extension</format>
   <authentication>user</authentication> 
</webscript>

Next we have to prepare the view, also in this case a very simple one.
tabella.get.html.ftl

Hello, ${args.value}!
tabella.get.html.ftl Inside this file you can put all your freemarker code.

Ok now the only things is to link this webscript into a jsp page.
(In my specific case the template is in the dashboard so you will have to follow all configuration steps.)

my jsp page is this.


<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<%– Note that this template is loaded from the classpath –%>

<%
String h = "0";
   String g = (String)request.getAttribute("cryms");
   if(request.getQueryString() != null){
       h = request.getQueryString().substring("value=".length(),request.getQueryString().length());
   }
      
%>

<% String link = "alfresco/service/tabella?value="+h; %>

<r:webScript scriptUrl="<%=link%>"  />   

So the point is, before calling the webscript we get the parameters from the jsp page and we build the link for the web script.

—-
There is an issue, In the dashboard container because the dashlet are inside a form, and if you did not submit the form the script are not able to get the parameters.
My solution is to create a js function update the action of the form and then submit them.

Hope this help and sorry for my English, i m not a son of the Queen Smiley Happy