Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_cn
Articles_pt
Articles_zh
CreateActions
CreateActions_pt
CreateActions_zh
SpringControllerUnit...
SpringControllers_ko
ValidationAndListSpr...
...and 1 more




JSPWiki v2.2.33

[RSS]


Hide Menu

SpringControllers


Difference between version 53 and version 40:

At line 21 changed 1 line.
In this step, you'll generate a ''skeleton'' JSP to display information from the Person object. I say ''skeleton'' because it'll just be the <form> itself. It will contain table rows with Spring's "bind" tags for each property in Person.java. The tool that we use to do this was written by [Erik Hatcher|http://www.blogscene.org/erik/]. It's basically just a single class (FormTagsHandler.java) and a couple of XDoclet templates (FormKeys.xdt and Form_jsp.xdt). All these files are located in extras/viewgen.
In this step, you'll generate a JSP page to display information from the Person object. It will contain Spring's JSP tags that render table rows for each property in Person.java. The [AppGen] tool that's used to do this is based off a StrutsGen tool - which was originally written by [Erik Hatcher|http://www.blogscene.org/erik/]. It's basically just a couple of classes and a bunch of XDoclet templates. All these files are located in extras/appgen.
At line 23 removed 2 lines.
<div class="note" style="margin: 5px; background-color: #fcc">__WARNING:__ The "viewgen" tool has been deprecated in 1.6.1 and will be removed in 1.7. The <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=CreateDAO#appgen">appgen</a> tool provides the same functionality.</div>
At line 27 changed 6 lines.
* From the command-line, navigate to "extras/viewgen"
* Execute __ant -Dform.name=Person__ to generate three files in extras/viewgen/build:
** Person.properties (labels for your form elements)
** personForm.jsp (skeleton JSP file for viewing a single Person)
** personList.jsp (skeleton JSP file for viewing a list of People)
* Copy the contents of Person.properties into web/WEB-INF/classes/ApplicationResources_en.properties. Here is an example of what you might add to ApplicationResources_en.properties:
* From the command-line, navigate to "extras/appgen"
* Execute __ant -Dobject.name=Person -Dappgen.type=pojo -Dapp.module=__ to generate a bunch of files in extras/appgen/build/gen. In fact, it'll generate all the files you need to complete this tutorial. However, let's just grab the ones you need.
** web/WEB-INF/classes/Person.properties (labels for your form elements)
** web/pages/personForm.jsp (JSP file for viewing a single Person)
** web/pages/personList.jsp (JSP file for viewing a list of People)
* Copy the contents of Person.properties into web/WEB-INF/classes/ApplicationResources.properties. These are all the keys you will need for titles/headings and form properties. Here is an example of what you should add to ApplicationResources.properties:
At line 36 removed 1 line.
person.firstName=First Name
At line 35 added 1 line.
person.firstName=First Name
At line 37 added 12 lines.
person.added=Person has been added successfully.
person.updated=Person has been updated successfully.
person.deleted=Person has been deleted successfully.
# -- person list page --
personList.title=Person List
personList.heading=Persons
# -- person detail page --
personDetail.title=Person Detail
personDetail.heading=Person Information
At line 41 changed 1 line.
* Copy personForm.jsp to web/pages/personForm.jsp. Copy personList.jsp to web/pages/personList.jsp. ''Notice that each of the new filename's first character is lowercase.''
* Copy personForm.jsp to web/pages/personForm.jsp. Copy personList.jsp to web/pages/personList.jsp.
At line 50 changed 2 lines.
* Add keys in ApplicationResources_en.properties the titles and headings in the JSPs
In the generated JSPs, there are two keys for the title (top of the browser window) and the header (heading in the page). We now need to add these two keys (personDetail.title and personDetail.heading) to ApplicationResources_en.properties.
* Add keys in ApplicationResources.properties the titles and headings in the JSPs
In the generated JSPs, there are two keys for the title (top of the browser window) and the header (heading in the page). We now need to add these two keys (personDetail.title and personDetail.heading) to ApplicationResources.properties.
At line 121 changed 1 line.
assertNotNull(request.getSession().getAttribute("messages"));
assertNotNull(request.getSession().getAttribute("successMessages"));
At line 129 changed 1 line.
assertNotNull(request.getSession().getAttribute("messages"));
assertNotNull(request.getSession().getAttribute("successMessages"));
At line 155 added 2 lines.
import java.util.Locale;
At line 212 added 1 line.
Locale locale = request.getLocale();
At line 201 removed 3 lines.
Object[] args =
new Object[] { person.getFirstName() + ' ' + person.getLastName() };
At line 207 changed 1 line.
saveMessage(request, getText("person.deleted", args, request.getLocale()));
saveMessage(request, getText("person.deleted", locale));
At line 212 changed 1 line.
saveMessage(request, getText(key, args, request.getLocale()));
saveMessage(request, getText(key, locale));
At line 226 changed 1 line.
There are a few keys you need to add to ApplicationResources_en.properties to display the success messages. This file is located in ''web/WEB-INF/classes'' - open it and add the following:
There are a few keys you (might) need to add to ApplicationResources.properties to display the success messages. This file is located in ''web/WEB-INF/classes'' - open it and add the following:
At line 230 changed 3 lines.
{{{person.added=Information for <strong>{0}</strong> has been added successfully.
person.deleted=Information for <strong>{0}</strong> has been deleted successfully.
person.updated=Information for <strong>{0}</strong> has been updated successfully.
{{{person.added=Person has been added successfully.
person.updated=Person has been updated successfully.
person.deleted=Person has been deleted successfully.
At line 306 removed 1 line.
Now let's clean up the generated personForm.jsp by making the "id" property a hidden field. Remove the following code block from web/pages/personForm.jsp:
At line 308 removed 26 lines.
[{Java2HtmlPlugin
<tr>
<th>
<appfuse:label key="person.id"/>
</th>
<td>
<spring:bind path="person.id">
<input type="text" name="<c:out value="${status.expression}"/>"
id="<c:out value="${status.expression}"/>"
value="<c:out value="${status.value}"/>" />
<span class="fieldError"><c:out value="${status.errorMessage}"/></span>
</spring:bind>
</td>
</tr>
}]
And add the following before the &lt;table&gt; tag:
[{Java2HtmlPlugin
<spring:bind path="person.id">
<input type="hidden" name="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>" />
</spring:bind>
}]
At line 384 added 1 line.
<verifytext description="verify success message" text="${person.updated}"/>
At line 420 changed 2 lines.
<verifytext description="verify success message"
text="Information for &lt;strong&gt;Abbie Raible&lt;/strong&gt; has been added successfully."/>
<verifytext description="verify success message" text="${person.added}"/>
At line 417 added 1 line.
<prepareDialogResponse description="Confirm delete" dialogType="confirm" response="true"/>
At line 419 added 1 line.
<verifyNoDialogResponses/>
At line 436 changed 2 lines.
<verifytext description="verify success message"
text="Information for &lt;strong&gt;Matt Canoo&lt;/strong&gt; has been deleted successfully."/>
<verifytext description="verify success message" text="${person.deleted}"/>

Back to SpringControllers, or to the Page History.