The main page has link to create new record and one to show all the existing records.
On the create_new_record
page I am writing all the data to a file in an action class method called saveRecords
and populating a List<Records>
in retriveRecords
methods.
My action class code:
public class MyRecordes{
List<RecoredInfo> recoreds= new ArrayList<RecoredInfo>();
}
I have getters and setters for the same records
in my action class(I am using Struts 2),
but on the main page when I click to show all records (which shows a different JSP page), nothing is displayed. Do I have to use servlets and/or doGet
, etc. methods?
EDIT:
Adding code for showList.jsp
:
<table>
<s:iterator value="arrayList" status="status">
<tr>
<td><s:property value="firstName"/> <s:property value="lastName"/>
</td>
</tr>
</s:iterator>
</table>
My action class has an arraylist named arrayList
and I am using getters/setters to set the value.
The different action will populate the list and return a result of the different JSP page. In the different JSP you can show records
using
iterator
Iterator will iterate over a value. An iterable value can be any of:
java.util.Collection
, java.util.Iterator
, java.util.Enumeration
,
java.util.Map
, or an array.
Whatever you show on the JSP the data should be bound to the beans properties that you can retrieve via OGNL expression and written to the JSP output.
OGNL
OGNL is the Object Graph Navigation Language (see
commons-ognl for the full
documentation of OGNL). Here, we will cover a few examples of OGNL
features that co-exist with the framework. To review basic concepts,
refer to OGNL Basics.
If you are using Struts2 you don't need servlets and/or doGet
etc. methods. Struts2 framework implements MVC pattern that you can follow while writing your web application. If you are new to the framework, then better get started from the Tutorials.
Tutorials
The framework documentation is written for active web developers and
assumes a working knowledge about how Java web applications are built.
For more about the underlying nuts and bolts, see the Key
Technologies Primer.