I'm using Struts 2 and FreeMarker and I'm ready to move on from the
HelloWorld example...

I would like to create a page to display a list of accounts.
Hence, the following is the action class,

public class Search extends ActionSupport implements SessionAware {

   private Map session;

   public String execute() throws Exception {
       List<Account> accounts = new ArrayList<Account>();
       for (int i = 0; i < 5; i++) {
           Account account = new Account();
           account.setUserName("name" + i);
           accounts.add(account);
       }
       session.put("accounts", accounts);
       return SUCCESS;
   }

   public void setSession(Map session) {
       this.session = session;
   }
}


Subsequently the FreeMarker template can display the accounts,

<#list accounts as account>
${account.getUserName()}
</#list>


Is this the only way we push the data to FreeMarker template?

Do we need to remove the data from the session?

Can the FreeMarker template access the request parameters directly
without us adding the parameters into the session?


/Struts newbie

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to