You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Skariah <ms...@anshinsoft.com> on 2001/07/09 20:54:28 UTC

Retaining values for the page.....

Hello all,
Please have the patience to go thru'..

Assume that I have 2 pages... test1.jsp and test2.jsp. A link present in
test1.jsp opens up a child window with test2.jsp. I also have the following
in the config file:

<action   path="/test2"
	type="com.nri.xenos.uibase.ui.Test2Action"
	name="test1ActionForm"
	scope="request"
	validate="false"
	input="/test1.jsp">
	<forward name="failure"              path="/test1.jsp"/>
	<forward name="success"              path="/test2.jsp"/>
</action>

In Test2Action.java I am populating a List<String> by using values from the
database which is to be used in test2.jsp
.
But, here is my problem.
Every time I click on the link to open test2.jsp, a fetch from the database
is made.
If the test2.jsp link is more than once, fetch should not be made every time
I click on the link, but rather the first time only, and also when the
test1.jsp is reopened or refreshed.

I hope you all understand my question.

Thanks a lot,
-Michael.


Re: Retaining values for the page.....

Posted by Peter Alfors <pe...@irista.com>.
Here is one option:

When you retrieve the data from the database in Test2Action, place it in the
session.  Then the next time Test2Action is
executed, check for its existence in the session.  If it exists, use it,
otherwise, refresh from the database.
When Test1Action is executed, remove the session attribute storing the list of
strings.  This way, when Test2Action is executed, it will be forced to refresh
from the database.

HTH,
    Pete

Michael Skariah wrote:

> Hello all,
> Please have the patience to go thru'..
>
> Assume that I have 2 pages... test1.jsp and test2.jsp. A link present in
> test1.jsp opens up a child window with test2.jsp. I also have the following
> in the config file:
>
> <action   path="/test2"
>         type="com.nri.xenos.uibase.ui.Test2Action"
>         name="test1ActionForm"
>         scope="request"
>         validate="false"
>         input="/test1.jsp">
>         <forward name="failure"              path="/test1.jsp"/>
>         <forward name="success"              path="/test2.jsp"/>
> </action>
>
> In Test2Action.java I am populating a List<String> by using values from the
> database which is to be used in test2.jsp
> .
> But, here is my problem.
> Every time I click on the link to open test2.jsp, a fetch from the database
> is made.
> If the test2.jsp link is more than once, fetch should not be made every time
> I click on the link, but rather the first time only, and also when the
> test1.jsp is reopened or refreshed.
>
> I hope you all understand my question.
>
> Thanks a lot,
> -Michael.