struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ritchie Warsito <ritch...@spymac.com>
Subject Re: [Tiles] Action class to retrieve list and send to tile
Date Wed, 22 Dec 2004 19:29:15 GMT
I'm gonna give a small bump here, cuz I'm really still troubling with 
this (for work). So if anyone have any idea or any other approach, please...
Tnx,
Ritchie



Ritchie Warsito wrote:

> Hi I'm new to all of this. I'll try to keep it clear.
> I've playing around with tiles in a struts application that does 
> mostly getters.
>
> My tiles-defs.xml looks like:
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD 
> Tiles Configuration 1.1//EN" "tiles-config_1_1.dtd" >
> <tiles-definitions>
>  <definition name="mslDefLayout" path="/layouts/mslDefaultLayout.jsp" >
>      <put name="title" value="Hypotheekbank Curacao" />
>      <put name="header" value="/jsp/header.jsp" />
>      <put name="footer" value="/jsp/footer.jsp" />
>      <put name="menu" value="/jsp/officeMenu.jsp" />
>  </definition>
>  <definition name="index" extends="mslDefLayout">
>        <put name="body" value="/jsp/huiskopen.jsp"/>
>    </definition>
>    <definition name="account" extends="mslDefLayout">
>        <put name="body" value="/jsp/accOptions.jsp"/>
>    </definition>
> </tiles-definitions>
>
> This setup is to reduce the amount of jsp pages, the ones that only 
> define your content and in what definition to load it in.
> I'm calling on for instance, accOptions.do. This will call on an 
> action DoTiles that has nothing more than a forward mapping in it to 
> the right definition, in this case "account"
>
> Here is my struts-config.xml:
> <action-mappings >
>      <action path="/index" type="com.frontier.action.doTiles">
>         <forward name="success" path="index" />
>      </action>
>      <<action path="/accOptions" type="com.frontier.action.doTiles">
>         <forward name="success" path="account" />
>      </action>
>      <action path="/getAccountAction" 
> type="com.frontier.action.getAccountAction">
>         <forward name="success" path="/accOptions" />
>      </action>
>      <action path="/getMortgageAction" 
> type="com.frontier.action.getMortgageAction">
>          <forward name="sucess" path="mortgage" />
>      </action>
>   </action-mappings>
>
>   <controller bufferSize="4096" debug="0" />
>   <message-resources parameter="com.tiles.struts.ApplicationResources" />
>   <plug-in className="org.apache.struts.tiles.TilesPlugin" >
>       <set-property property="definitions-config" 
> value="/WEB-INF/tiles-defs.xml" />
>       <set-property property="moduleAware" value="true" />
>       <set-property property="definitions-parser-validate" 
> value="true" />
>   </plug-in>
>
> Now that works. What I'm trying now is the following:
> I have one DTO class Customer.java, one Business/Service class 
> CustomerDAO.java and one action class getAccountAction.java
> The CustomerDAO has a public List getCustomerList method in it I want 
> to call on in the Action like this:
> public ActionForward execute(
>        ActionMapping mapping,
>        ActionForm form,
>        HttpServletRequest request,
>        HttpServletResponse response) {
>
>        List customerList = CustomerDAO.getInstance().getCustomerList();
>        request.setAttribute("customer", customerList);
>        return (mapping.findForward("success"));
>    }
>
> So this forward (as you can see in my struts-config) should call on 
> the accOptions action that loads the "account" definition, so the List 
> will show in the jsp I defined in the tiles-defs for "account".
> That jsp looks like this:
> <logic:iterate name="customer" id="customer" scope="request" 
> type="com.frontier.action.getAccountAction">
>   <table>
>   <tr><td>Name:</td><td><bean:write name="customer" property="name"

> scope="request" /></td></tr>
>   <tr><td>Address:</td><td><bean:write name="customer" 
> property="address" scope="request" /></td></tr>
>   <tr><td>City:</td><td><bean:write name="customer" property="city"

> scope="request" /></td></tr>
>   <tr><td>Number of Mortgages:</td><td><bean:write name="customer"

> property="noofmortgages" scope="request"  /></td></tr>
>    </table>
> </logic:iterate>
>
> Only problem is, it ain't working. Seems like by calling a double 
> action forward it loses it's session or something.
> So how can I accomplish what I want? Any idea's on this. It might be 
> simple, but it's all new for me, so I have no clue anymore.
> I hope it isn't too long, but I wanted to give as much needed detail 
> as possible.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message