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_pt
CreateActions
CreateActions_de
SpringControllers_ko
ValidationAndList_pt




JSPWiki v2.2.33

[RSS]


Hide Menu

ValidationAndList


Difference between version 85 and version 76:

At line 21 changed 1 line.
To use the Struts Validator, normally you have to write a validation.xml file by hand. If you're not using AppFuse, you also have to configure the Validator Plugin and error keys in your ApplicationResources_en.properties. For more information on this, see the [Validation Made Easy Tutorial|http://www.reumann.net/struts/lesson3/step8.do] (there's also a [rich set of tutorials|http://www.reumann.net/struts/main.do] for Struts itself).
To use the Struts Validator, normally you have to write a validation.xml file by hand. If you're not using AppFuse, you also have to configure the Validator Plugin and error keys in your ApplicationResources.properties. For more information on this, see the [Validation Made Easy Tutorial|http://www.learntechnology.net/struts-lesson-3.do] (there's also a [rich set of tutorials|http://www.learntechnology.net/struts-lesson-1.do] for Struts itself).
At line 71 changed 1 line.
To enable client-side validation in our personForm.jsp, a javascript JSP tag and script is required at the bottom of personForm.jsp. The following should already exist (thanks to appgen) - you just need to uncomment it. The reason it's commented out is that the Validator will throw an exception if a formName is specified and no validation rules exist for it.
Client-side validation is enabled by default in personForm.jsp. There is an <html:javascript> JSP tag and script at the bottom of this page that enables it. The following should already exist (thanks to AppGen) - but you might need to uncomment it if you commented it out in the last tutorial.
At line 73 removed 2 lines.
;:''Personally, I think this is [a bug|http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27316], but the Struts Committers disagreed.''
At line 100 changed 1 line.
To make sure things are ''really'' working as expected, you can turn off JavaScript and ensure the server-side validation is working. This is easy in [Mozilla Firebird|http://www.mozilla.org/products/firebird/] (my favorite browser), just go to Tools → Options → Web Features and uncheck "Enable JavaScript". Now if you clear the fields and save the form, you should see the following:
To make sure things are ''really'' working as expected, you can turn off JavaScript and ensure the server-side validation is working. This is easy in [Firefox|http://www.mozilla.org/products/firefox/] (my favorite browser), just go to Tools → Options → Web Features and uncheck "Enable JavaScript". Now if you clear the fields and save the form, you should see the following:
At line 187 changed 1 line.
Example ex = Example.create(person).ignoreCase().enableLike(MatchMode.ANYWHERE);
Example ex = Example.create(person).ignoreCase().ignoreZeroes()
.enableLike(MatchMode.ANYWHERE);
At line 280 changed 1 line.
Open the personList.jsp file in ''web/pages''. At the top of the file is a <bean:struts> tags that exposes the edit screen's forward as a page-scoped variable. This should already have a value of "editPerson".
Open the personList.jsp file in ''web/pages''. You'll probably want to change the code to show the plural form of the items you're listing. The generated name in this example is "persons" and it should probably be people. At or near line 31, you should have the following line:
At line 282 removed 16 lines.
[{Java2HtmlPlugin
<%-- For linking to edit screen --%>
<bean:struts id="editURL" forward="editPerson"/>
}]
Add this to the metadata/web/global-forwards.xml, as well as one for viewing the list. This way, they will get included in our struts-config.xml file.
[{Java2HtmlPlugin
<forward name="editPerson" path="/editPerson.html"/>
<forward name="viewPeople" path="/editPerson.html?method=Search"/>
}]
Another thing you'll probably want to change is the plural form of the items you're listing. The generated name in this example is "persons" and it should probably be people. At or near line 31, you should have the following line:
At line 304 changed 1 line.
Finally, add the title and heading keys (personList.title and personList.heading) to web/WEB-INF/classes/ApplicationResources_en.properties. Open this file and add the following:
Finally, add the title and heading keys (personList.title and personList.heading) to web/WEB-INF/classes/ApplicationResources.properties. Open this file and add the following:
At line 344 changed 1 line.
We use "viewPeople" instead of "list" so that the search method will be executed, rather than simply forwarding to the personForm.jsp (which the "list" forward points to).
Finally, declare the viewPeople forward in metadata/web/global-forwards.xml after viewUsers as below:
At line 329 added 4 lines.
{{{<forward name="viewPeople" path="/editPerson.html?method=Search"/>}}}
The name "viewPeople" is used instead of "list" so that the search method will be executed, rather than simply forwarding to the personForm.jsp (which the "list" forward points to).
At line 371 added 1 line.
At line 374 added 1 line.
At line 395 changed 1 line.
Where ''menu.viewPeople'' is an entry in web/WEB-INF/classes/ApplicationResources_en.properties.
Where ''menu.viewPeople'' is an entry in web/WEB-INF/classes/ApplicationResources.properties.

Back to ValidationAndList, or to the Page History.