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_de
Articles_pt
Articles_zh
JSFBeans




JSPWiki v2.2.33

[RSS]


Hide Menu

ValidationAndListJSF


Difference between version 10 and version 1:

At line 11 changed 1 line.
* [1] View validation settings in personForm.jsp
* [1] View validation settings in personForm.xhtml
At line 17 changed 1 line.
* [7] Create people.jsp and Canoo test
* [7] Create people.xhtml and Canoo test
At line 23 changed 1 line.
The validation integration for the personForm.html page is already done by AppGen in the personForm.page. If you open web/personForm.jsp, you should see the following JSP Tags. I've highlighted the portions that are relevant to validation.
The validation integration for the form page is already done by AppGen in the personForm.xhtml. If you open web/personForm.xhtml, you should see the following JSP Tags. I've highlighted the portions that are relevant to validation.
At line 33 changed 1 line.
There are a [number of different validators|http://www.marinschek.com/myfaces/tiki/tiki-index.php?page=Features] you can use, this example just shows a way to validate Strings are entered. The userForm.jsp contains examples of validation e-mail and validating with regular expressions. All input fields generated by AppGen are required by default. You can change this by modifying the extras/appgen/src/**/Form_jsp.xdt file.
There are a [number of different validators|http://www.marinschek.com/myfaces/tiki/tiki-index.php?page=Features] you can use, this example just shows a way to validate Strings are entered. The userForm.xhtml contains examples of validation e-mail and validating with regular expressions. All input fields generated by AppGen are required by default. You can change this by modifying the extras/appgen/src/**/Form_xhtml.xdt file.
At line 48 changed 1 line.
%%(border: 1px solid black; margin: 0 auto; height: 215px; width: 571px)
%%(border: 1px solid black; margin: 0 auto; height: 215px; width: 462px)
At line 72 changed 3 lines.
public void testGetPeople() {
List results = mgr.getPeople(new Person());
assertTrue(results.size() > 0);
public void testGetPeople() throws Exception {
List results = new ArrayList();
person = new Person();
results.add(person);
// set expected behavior on dao
personDao.expects(once()).method("getPeople")
.will(returnValue(results));
List people = personManager.getPeople(null);
assertTrue(people.size() == 1);
personDao.verify();
At line 113 added 2 lines.
At line 136 changed 1 line.
In the last couple of tutorials, you've been working with the PersonForm to interact with your form JSP. Now you need to create a new Managed Bean that'll simply handle getting and displaying a list of people in the database.
In the last couple of tutorials, you've been working with the PersonForm to interact with your form view page. Now you need to create a new Managed Bean that'll simply handle getting and displaying a list of people in the database.
At line 157 added 1 line.
At line 167 added 1 line.
At line 156 changed 1 line.
assertTrue(bean.getPersons().size() >= 1);
assertTrue(bean.getPeople().size() >= 1);
At line 189 changed 1 line.
Now if you run __ant test-web -Dtestcase=PersonList__, the test should pass.
Now you need to add the managed-bean definition for the PersonList class. Open web/WEB-INF/faces-config.xml and add the following managed-bean definition:
At line 204 added 15 lines.
[{Java2HtmlPlugin
<managed-bean>
<managed-bean-name>personList</managed-bean-name>
<managed-bean-class>org.appfuse.webapp.action.PersonList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>personManager</property-name>
<value>#{personManager}</value>
</managed-property>
</managed-bean>
}]
If you run __ant test-web -Dtestcase=PersonList__, the test should pass.
At line 196 changed 1 line.
There should already be a persons.jsp file in your ''web'' directory. If not, you can create it using AppGen. From the command-line, navigate to extras/appgen and run __ant -Dobject.name=Person -Dappgen.type=pojo__. This will generate a Persons.jsp file in __extras/appgen/build/gen/web__.
There should already be a persons.xhtml file in your ''web'' directory. If not, you can create it using AppGen. From the command-line, navigate to extras/appgen and run __ant -Dobject.name=Person -Dappgen.type=pojo__. This will generate a personList.xhtml file in __extras/appgen/build/gen/web__.
At line 198 changed 1 line.
Copy Persons.jsp to ''web'' and rename it to __people.jsp__. Open it for for editing. There are two references to "personList.persons". Change those to be "personList.people".
Copy personList.xhtml to ''web'' and rename it to __people.xhtml__. Open it for for editing. There are two references to "personList.persons". Change those to be "personList.people".
At line 210 changed 1 line.
You should already have the title and heading keys (personList.title and personList.heading) for the personList.html page in web/WEB-INF/classes/ApplicationResources_en.properties. You should've added these keys in the previous tutorial.
You should already have the title and heading keys (personList.title and personList.heading) for the personList.html page in web/WEB-INF/classes/ApplicationResources.properties. You should've added these keys in the previous tutorial.
At line 212 changed 1 line.
Now you need to add the managed-bean definition for the PersonList class. Open web/WEB-INF/faces-config.xml and add the following managed-bean definition:
Now you need to add the navigation-rules for this page (near the top of web/WEB-INF/faces-config.xml):
At line 216 removed 15 lines.
<managed-bean>
<managed-bean-name>personList</managed-bean-name>
<managed-bean-class>org.appfuse.webapp.action.PersonList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>personManager</property-name>
<value>#{personManager}</value>
</managed-property>
</managed-bean>
}]
Also, add the navigation-rules for this page (near the top of faces-config.xml):
[{Java2HtmlPlugin
At line 232 changed 1 line.
<from-view-id>/people.jsp</from-view-id>
<from-view-id>/people.xhtml</from-view-id>
At line 235 changed 1 line.
<to-view-id>/personForm.jsp</to-view-id>
<to-view-id>/personForm.xhtml</to-view-id>
At line 239 changed 1 line.
<to-view-id>/personForm.jsp</to-view-id>
<to-view-id>/personForm.xhtml</to-view-id>
At line 246 changed 1 line.
Now that you have a List Screen, let's change the pages that are displayed after adding and deleting a new Person. In the faces-config.xml file, change the references for the personForm.jsp from "mainMenu" to "people".
Now that you have a List Screen, let's change the pages that are displayed after adding and deleting a new Person. In the faces-config.xml file, change the references for the personForm.xhtml from "mainMenu" to "people".
At line 251 changed 1 line.
<from-view-id>/personForm.jsp</from-view-id>
<from-view-id>/personForm.xhtml</from-view-id>
At line 254 changed 1 line.
<to-view-id>/people.jsp</to-view-id>
<to-view-id>/people.xhtml</to-view-id>
At line 259 changed 1 line.
<to-view-id>/people.jsp</to-view-id>
<to-view-id>/people.xhtml</to-view-id>
At line 328 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.
At line 337 changed 1 line.
<Menu name="PeopleMenu" title="menu.viewPeople" forward="viewPeople"/>
<Menu name="PeopleMenu" title="menu.viewPeople" page="/people.html"/>
At line 357 added 1 line.
At line 385 added 1 line.

Back to ValidationAndListJSF, or to the Page History.