I am a beginner in Struts and got a doubt. I have got a page which redirects it to a .do file which in turn calls a struts page.
The above page forward calls the below specified page:
<display:table name="sessionScope.LocationLoadActionForm.loadList" class="dataTable" style="width:101%;" id="row"
pagesize="5" cellspacing="0">
<display:column title="<input type='checkbox' name='selectall' id='selectall' value='all'/>">
<html:checkbox styleClass="case" name="LocationLoadActionForm" property="id" value="${row.locid}"/>
</display:column>
<display:column property="locid" title="Location ID" media="html" />
<display:column property="locname" title="Location Name" group="1" sortable="true"/>
<display:column property="loc_city" title="Location City" group="2" sortable="true" />
<display:setProperty name="paging.banner.full">
<div class="pagelinks" align="right"> [<a href="{1}">First</a>/ <a href="{2}">Prev</a>] {0} [ <a href="{3}">Next</a>/ <a href="{4}">Last </a>]</div>
</display:setProperty>
<display:setProperty name="paging.banner.first">
<div class="pagelinks" align="right"> [First/Prev] {0} [ <a href="{3}">Next</a>/ <a href="{4}">Last</a>] </div>
</display:setProperty>
<display:setProperty name="paging.banner.last">
<div class="pagelinks" align="right">[ <a href="{1}">First</a>/ <a href="{2}">Prev</a>] {0} [Next/Last] </div>
</display:setProperty>
<display:setProperty name="paging.banner.onepage">
<div class="pagelinks" align="right"> {0} </div>
</display:setProperty>
<display:setProperty name="paging.banner.all_items_found" value="" />
<display:setProperty name="paging.banner.some_items_found" value="" />
<display:setProperty name="paging.banner.one_item_found" value="" />
</display:table>
Now there is a button which redirects to a delete page and forwards it to Locationload.do . Now when i perform the delete operation, though my record is deleted from the database however the displaytag displays the old value. How to solve the problem.
The details of struts config file are as follows:
<form-bean name="LocationDetailAddActionForm" type="Location.LocationDetailAddActionForm"/>
<form-bean name="LocationLoadActionForm" type="Location.LocationLoadActionForm"/>
<form-bean name="CountryActionForm" type="Country.CountryActionForm"/>
<form-bean name="LocationActionForm" type="Location.LocationActionForm"/>
<form-bean name="OrganizationActionForm" type="Organization.OrganizationActionForm"/>
</form-beans>
<global-exceptions>
</global-exceptions>
<action-mappings>
<action input="/" name="OrganizationActionForm" path="/addOrganizationGeneral" scope="session" type="Organization.OrganizationAction">
<forward name="success" path="/Administrator/OrganizationDetail.jsp"/>
</action>
<action input="/" name="CountryActionForm" path="/addCountry" scope="session" type="Country.CountryAction">
<forward name="success" path="/Administrator/Country.jsp"/>
<forward name="validate" path="/Administrator/Country_validate.jsp"/>
</action>
<action input="/" name="LocationActionForm" path="/addLocation" scope="session" type="Location.LocationAction">
<forward name="success" path="/Administrator/AdminLocation/LocationDetail.jsp"/>
</action>
<action input="/" name="LocationLoadActionForm" path="/LocationLoad" scope="session" type="Location.LocationLoadAction">
<forward name="success" path="/Administrator/AdminLocation/LocationDetail.jsp"/>
</action>
<action input="/" name="LocationDetailAddActionForm" path="/LocationAdd" scope="session" type="Location.LocationDetailAddAction">
<forward name="success" path="/Administrator/AdminLocation/Location.jsp"/>
</action>
<action input="/" name="LocationLoadActionForm" path="/LocationDelete" scope="session" type="Location.LocationDeleteAction">
<forward name="success" path="/Administrator/AdminLocation/LocationDelete.jsp"/>
</action>
</action-mappings>
The display tag displays the list of values that you tell it to show. If the value is dsplayed, it means that it’s still in the list. Maybe you deleted the item from the database, but forgot to remove it from the list stored in the session and displayed by the table:
The session should be used to store objects that have a session life-time (the user name, a shopping cart, etc.) If you used the request to store the list of data to display in the table, you would waste less memory, and wouldn’t risk displaying stale values as you are doing now. Struts chose to use session-scoped action forms by default snce the beginning, and this was a very bad choice. Make sure to use request-scoped form beans by default.