Where to put a call to the database in a struts2+springapp
Hello guys!Hope you could help me with some giudelines with struts2 and spring.
I would like to get som text from a database, but I can not figure out how to do that at the right place in my struts2 app.
I got this "LinkAction":
<action name="*Link" method="{1}" class="test.LinkAction">
<result name="page1" type="tiles">tiles_for_page1</result>
<result name="page2" type="tiles">tiles_for_page2</result>
</action>
...that responds on links like:
<a href="<s:url action="page1Link"/>" >Page 1</a>
How ever in one page that tiles_for_page1 consists of I would like to fetch some data (list of products) from the database for example like:
<s:iterator value="products">
<tr id="row_<s:property value="id"/>">
<td>
<s:property value="name" />
</td>
<td>
<s:property value="description" />
</td>
</tr>
</s:iterator>
I guess I should do the call, for example, findAll in the ProductsServiceImpl in a *Action class.
But where should I put this call so this data is fetched and populated in the page before the page is rendered?
Hope I made this description of the problem understandable,
Best regards
Fredrik