How to get request attribute value at *.ftl?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get request attribute value at *.ftl?

Chen Xi
Hi:
    May I know how to retrieve value from the request.

    I have retrieve the value at one java class. like
    List projects = (List) result.get("projects");  // It is not null
    request.setAttribute("projects", projects);

    However, at the *.ftl file, i try to use
    <#if projects?has_content>
                   <#list projects as Project>
                       <tr>
                          <td>${Project.project_id}</td>
                          <td>${Project.name}</td>
                       </tr>
                    </#list>
    </#if>

    there is no result to display. Seems projects is empty, is it any
important steps i missed?

Regards
    Chen Xi
Reply | Threaded
Open this post in threaded view
|

RE: How to get request attribute value at *.ftl?

Nikita Shinde
Hi,

  In your ftl, you will need to fetch the attribute set in the request as
follows:

    <#assign projects = requestAttributes.projects?if_exists >

    <#if projects?has_content>
       <#list projects as Project>
          <tr>
        <td>${Project.project_id}</td>
             <td>${Project.name}</td>
          </tr>
       </#list>
    </#if>



Thanks,
Nikita
Amicon Technologies Pvt. Ltd.
Mumbai, India.



-----Original Message-----
From: Chen Xi [mailto:[hidden email]]
Sent: Tuesday, July 31, 2007 9:36 PM
To: [hidden email]
Subject: How to get request attribute value at *.ftl?

Hi:
    May I know how to retrieve value from the request.

    I have retrieve the value at one java class. like
    List projects = (List) result.get("projects");  // It is not null
    request.setAttribute("projects", projects);

    However, at the *.ftl file, i try to use
    <#if projects?has_content>
                   <#list projects as Project>
                       <tr>
                          <td>${Project.project_id}</td>
                          <td>${Project.name}</td>
                       </tr>
                    </#list>
    </#if>

    there is no result to display. Seems projects is empty, is it any
important steps i missed?

Regards
    Chen Xi