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 10 and version 9:

At line 16 changed 1 line.
* [4] Display the JSP in a browser and run the ControllerTest
* [4] Run the ControllerTest
At line 37 changed 1 line.
* Copy personForm.jsp to web/personForm.jsp. Copy PersonFormList.jsp to web/personList.jsp. ''Notice that each of the new filename's first character is lowercase.''
* Copy personForm.jsp to web/pages/personForm.jsp. Copy PersonFormList.jsp to web/pages/personList.jsp. ''Notice that each of the new filename's first character is lowercase.''
At line 39 changed 1 line.
We copy the JSPs to the ''web'' folder instead of ''web/pages'' because the ''pages'' directory ends up in ''WEB-INF/pages'' when the application is packaged into a [WAR|http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/WCC3.html#69310] file. This is a [recommended practice|http://husted.com/struts/catalog.html] when building secure web applications.
;: ''The files in the "pages" directory will end up in "WEB-INF/pages" at deployment time. The container provides security for all files below WEB-INF. This applies to client requests, but not to forwards from the DispatchServlet. Placing all JSPs below WEB-INF ensures they are only accessed through Controllers, and not directly by the client or each other. This allows security to be moved up into the Controller, where it can be handled more efficiently, and out of the base presentation layer.''
At line 41 removed 2 lines.
;: ''The container provides security for all files below WEB-INF. This applies to client requests, but not to forwards from the DispatchServlet. Placing all JSPs below WEB-INF ensures they are only accessed through Controllers, and not directly by the client or each other. This allows security to be moved up into the Controller, where it can be handled more efficiently, and out of the base presentation layer.''
At line 45 removed 2 lines.
All this is to say that __putting the personForm.jsp in the ''web'' folder will allow us to view it without making a Tile for it__. ''We'll get to that in the next tutorial.''
At line 56 changed 2 lines.
public class PersonControllerTest extends BaseControllerTestCase {
private static Log log = LogFactory.getLog({personFormControllerTest.class);
public class PersonFormControllerTest extends BaseControllerTestCase {
private static Log log = LogFactory.getLog(PersonFormControllerTest.class);
At line 145 added 15 lines.
We also need to add the <bean> definition for personFormController in this same file:
[{Java2HtmlPlugin
<bean id="personFormController" class="org.appfuse.webapp.action.PersonFormController">
<property name="commandName"><value>person</value></property>
<property name="commandClass"><value>org.appfuse.model.Person</value></property>
<property name="validator"><ref bean="beanValidator"/></property>
<property name="formView"><value>personForm</value></property>
<property name="successView"><value>editPerson.html</value></property>
<property name="personManager"><ref bean="personManager"/></property>
</bean>
}]
At line 155 changed 2 lines.
<html:form action="editPerson" method="post" styleId="personForm"
focus="" onsubmit="return validatePersonForm(this)">
<form action="editPerson" method="post" styleId="person"
focus="" onsubmit="return validatePersonForm(this)">
At line 161 changed 1 line.
!!Display the JSP in a browser and run the ActionTest [#5]
!!Run the ControllerTest [#5]'
At line 163 changed 1 line.
To test the JSP visually in your browser, save everything, run __ant deploy__, start Tomcat, and navigate to [http://localhost:8080/appfuse/personForm.jsp]. You should see something similar to the following image in your browser:
Now, if you stop Tomcat, cd ../.. to the base directory and run __ant test-web -Dtestcase=PersonController__, you should get a success message from Ant.
At line 165 removed 8 lines.
%%(border: 1px solid black; height: 125px; width: 270px; margin: 0 auto;)
[personForm-plain.png]
%%
;:''There is also a __deploy-web__ target in build.xml that will allow you to just deploy the files in the web directory. Nothing gets compiled or generated when you use this target.''
Now, if you stop Tomcat and run __ant test-cactus -Dtestcase=PersonAction__, that should work too!

Back to SpringControllers, or to the Page History.