At line 24 changed 1 line. |
* [5] Display the JSP in a browser and run the ActionTest |
* [5] Run PersonActionTest |
* [6] Clean up the JSP to make it presentable |
* [7] Create Canoo WebTests to test browser-like actions |
At line 94 added 3 lines. |
import org.appfuse.Constants; |
import org.appfuse.webapp.form.PersonForm; |
|
At line 176 added 2 lines. |
import org.appfuse.model.Person; |
import org.appfuse.webapp.form.PersonForm; |
At line 174 changed 1 line. |
* validate="false" parameter="action" input="mainMenu" |
* validate="false" parameter="method" input="mainMenu" |
At line 281 changed 1 line. |
;:''If you are running Eclipse, you might have to "refresh" the project in order to see PersonForm. It lives in build/web/gen, which should be one of your project's source folders. This is the only way for Eclipse to see and import PersonForm, since it is generated by XDoclet and does not live in your regular source tree. If you are not running Eclipse, you will need to manually add "import org.appfuse.webapp.form.PersonForm;" to PersonAction.java and PersonActionTest.java for the generated PersonForm class to be resolved. You will find it in build/web/gen/org/appfuse/webapp/form/PersonForm.java.'' |
;:''If you are running Eclipse, you might have to "refresh" the project in order to see PersonForm. It lives in build/web/gen, which should be one of your project's source folders. This is the only way for Eclipse to see and import PersonForm, since it is generated by XDoclet and does not live in your regular source tree. You can find it at build/web/gen/org/appfuse/webapp/form/PersonForm.java.'' |
At line 285 changed 1 line. |
Now we need to add the ''edit'' forward and the ''savePerson'' action-mapping, both with are specified in in our PersonActionTest. To do this, we'll add a couple more XDoclet tags to the top of the PersonAction.java file. Do this right above the class declaration. You should already have the XDoclet tag for the ''editPerson'' action-mapping, but I'm showing it here so you can see all the XDoclet tags at the top of this class. |
Now you need to add the ''edit'' forward and the ''savePerson'' action-mapping, both which are specified in in the PersonActionTest. To do this, add a couple more XDoclet tags to the top of the PersonAction.java file. Do this right above the class declaration. You should already have the XDoclet tag for the ''editPerson'' action-mapping, but I'm showing it here so you can see all the XDoclet tags at the top of this class. |
At line 291 changed 1 line. |
* validate="false" parameter="action" input="mainMenu" |
* validate="false" parameter="method" input="mainMenu" |
At line 294 changed 1 line. |
* validate="true" parameter="action" input="edit" |
* validate="true" parameter="method" input="edit" |
At line 312 changed 1 line. |
You could use generic ''added'', ''deleted'' and ''updated'' messages, whatever works for you. It's nice to have separate messages in case these need to change on a per-entity basis. |
;:''You could use generic ''added'', ''deleted'' and ''updated'' messages, whatever works for you. It's nice to have separate messages in case these need to change on a per-entity basis.'' |
At line 314 changed 1 line. |
You might notice that the code we're using to call the PersonManager is the same as the code we used in our PersonManagerTest. Both PersonAction and PersonManagerTest are ''clients'' of PersonManagerImpl, so this makes perfect sense. |
You might notice that the code you're using to call the PersonManager is the same as the code used in the PersonManagerTest. Both PersonAction and PersonManagerTest are ''clients'' of PersonManagerImpl, so this makes perfect sense. |
At line 316 changed 1 line. |
Everything is almost done for this tutorial, let's get to running our tests! |
Everything is almost done for this tutorial, let's get to running the tests! |
At line 318 changed 1 line. |
!!Run PersonActionTest [#6] |
!!Run PersonActionTest [#5] |
At line 320 changed 1 line. |
If you look at our PersonActionTest, all our tests depend on having a record with id=1 in the database (and testRemove depends on id=2), so let's add that to our sample data file (metadata/sql/sample-data.xml). I'd just add it at the bottom - order is not important since it (currently) does not relate to any other tables. |
If you look at our PersonActionTest, all the tests depend on having a record with id=1 in the database (and testRemove depends on id=2), so add that to our sample data file (metadata/sql/sample-data.xml). I'd add it at the bottom - order is not important since it (currently) does not relate to any other tables. |
At line 340 changed 1 line. |
DBUnit loads this file before we run any of our tests, so this record will be available to our Action test. |
DBUnit loads this file before we run any of our tests, so this record will be available to the PersonActionTest. |
At line 347 changed 1 line. |
!!Clean up the JSP to make it presentable [#7] |
!!Clean up the JSP to make it presentable [#6] |
At line 369 changed 1 line. |
You should probably also change the ''action'' of the <html:form> to be "savePerson" so validation will be turned on when saving. Also, change the ''focus'' attribute from focus="" to focus="firstName" so the cursor will be in the firstName field when the page loads (this is done with JavaScript). |
You should change the ''action'' of the <html:form> to be "savePerson" so validation will be turned on when saving. Also, change the ''focus'' attribute from focus="" to focus="firstName" so the cursor will be in the firstName field when the page loads (this is done with JavaScript). |
At line 388 changed 1 line. |
* Delete - [http://localhost:8080/appfuse/editPerson.html?action=Delete&id=1] (or edit and click on the Delete button). |
* Delete - [http://localhost:8080/appfuse/editPerson.html?method=Delete&id=1] (or edit and click on the Delete button). |
At line 488 changed 1 line. |
''Next Up:'' __Part V:__ [Adding Validation and List Screen|ValidationAndList] - Adding validation logic to the personForm so that firstName and lastName are required fields and adding a list screen to display all person records in the database. |
''Next Up:'' __Part IV:__ [Adding Validation and List Screen|ValidationAndList] - Adding validation logic to the personForm so that firstName and lastName are required fields and adding a list screen to display all person records in the database. |