You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by di...@jpmorgan.com on 2006/02/09 22:53:25 UTC

Parent/Child lists in DispathAction possible ?

Hello All;
        I have jsp with two distinct list of related objects displayed in 
Parent/Child relationship

        When one of the item from Parent list is selected it should 
populate details about that Parent object in child Table.
        sectors list is parent list and instruments list is child list in 
my case.

        Parent list (sectors) is displayed correctly but when I click on 
child url(instrument)  for one of the parent object, w/o any errors Only 
parent list (sectors) comes back on jsp.
        Can some one give suggestion what can be done to achieve this ?

        Thanks.
Digant




 
        My Jsp code looks like this
            <c:forEach var="sector" items="${sectors}" varStatus="status">
                <tr class="${status.index%2==0?'even':'odd'}">
              <td class="nowrap"><c:out 
value="${sector.sectorName}"/></td>
                <td class="nowrap"><c:out 
value="${sector.startDate}"/></td>
            </c:forEach>
 
           <c:url var="url" scope="page" value="/instrumentSetUp.do">
                    <c:param name="sectorId" value="${sector.sectorId}"/>
                    <c:param name="dispatch" value="getInstrumentsFromQ"/>
           </c:url>
           <a href="${url}">Instruemnt</a> 
 
 

        <c:forEach var="instrument" items="${instruments}" varStatus="status">
                <tr class="${status.index%2==0?'even':'odd'}">
                        <td class="nowrap"><c:out 
value="${instrument.bucketName}"/></td>
                <td class="nowrap"><c:out 
value="${instrument.sectorName}"/></td>
        </c:forEach>

in DispatchAction class I want some info from sectors list and based on 
that I want to populate instrument list.

    public ActionForward getInstrumentsFromQ(ActionMapping mapping, 
ActionForm form, HttpServletRequest                             request, 
HttpServletResponse response) throws Exception {
 
                SectorForm sectForm = (SectorForm)form;
                Long sectorId = Long.valueOf(sectForm.getSectorId());
            initialize(request,sectorId);
        List instruments = instService.getAllinstruments(sectorId);
                request.setAttribute(Constants.INSTRUMENTS, instruments);  
 
   }

and Finally struts config looks like this.

           <action
                path="/sectorProcess"
                name="sectorForm"
                type="com.jpmc.dice.web.action.SectorAction"
                scope="request"
                parameter="dispatch">
            <forward name="failure" path="/sectorForm.jsp"/>
            <forward name="success" path="/sectors.jsp"/>
        </action>
 

           <action
                path="/instrumentSetUp"
                name="instrumentForm"
                type="com.jpmc.dice.web.action.InstrumentAction"
                scope="request"
                parameter="dispatch">
            <forward name="failure" path="/instrumentForm.jsp"/>
            <forward name="success" path="/sectors.jsp"/>
        </action>


This communication is for informational purposes only. It is not intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All market prices,
data and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein 
do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries 
and affiliates