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 5 and version 4:

At line 97 removed 1 line.
import javax.servlet.http.HttpServletResponse;
At line 98 added 1 line.
import org.apache.commons.lang.StringUtils;
At line 101 changed 3 lines.
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.appfuse.model.Person;
import org.appfuse.service.PersonManager;
At line 106 changed 10 lines.
/**
* Implementation of <strong>Action</strong> that interacts with the {@link
* PersonForm} and retrieves values. It interacts with the {@link
* PersonManager} to retrieve/persist values to the database.
*
* @struts.action name="personForm" path="/editPerson" scope="request"
* validate="false" parameter="action" input="mainMenu"
*/
public final class PersonAction extends BaseAction {
private static Log log = LogFactory.getLog(PersonAction.class);
public class PersonFormController extends BaseFormController {
private static Log log = LogFactory.getLog(PersonFormController.class);
private PersonManager mgr = null;
public void setPersonManager(PersonManager mgr) {
this.mgr = mgr;
}
protected Object formBackingObject(HttpServletRequest request)
throws Exception {
String id = request.getParameter("id");
Person person = null;
At line 117 changed 6 lines.
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'execute' method");
if (!StringUtils.isEmpty(id)) {
person = mgr.getPerson(id);
} else {
person = new Person();
At line 125 changed 2 lines.
// return nothing (yet)
return null;
return person;
At line 131 changed 1 line.
We're not putting much in PersonAction at this point because we just want to 1) render the JSP and 2) verify our Test runs. The XDoclet tags (beginning with ''@struts.action'') will generate the following XML in the build/appfuse/WEB-INF/struts-config.xml file (when you run __ant webdoclet__):
We're not putting much in PersonController at this point because we just want to 1) render the JSP and 2) verify our Test runs. Now we need to add a url-mapping for this controller in the web/WEB-INF/action-servlet.xml file. In the block below, the new line is in green:
At line 135 changed 4 lines.
<action path="/editPerson" type="org.appfuse.webapp.action.PersonAction"
name="personForm" scope="request" input="mainMenu"
parameter="action" unknown="false" validate="false">
</action>
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/editProfile.html">userFormController</prop>
<prop key="/mainMenu.html">filenameController</prop>
<prop key="/editUser.html">userFormController</prop>
<prop key="/selectFile.html">filenameController</prop>
<prop key="/uploadFile.html">fileUploadController</prop>
<prop key="/passwordHint.xml">passwordHintController</prop>
<prop key="/signup.xml">signupController</prop>
<span style="color: green"><prop key="/editPerson.html">personFormController</prop></span>
</props>
</property>
</bean>

Back to SpringControllers, or to the Page History.