1) "input" attribute name is misleading. It is not actually an input
page, it is a location where control will be forwarded in case of
error, that is, if ActionForm.validate() returns non-null non-empty
object.

2) Do not navigate directly to JSP page in browser, navigate to
action. Action is supposed to be a controller that tackles with input
data, JSP page is a view that displays output data.

3) Because of (2), forward to JSP page from your action mapping only
when you want to display the page.

4) If you navigate directly to a JSP page, your action class will
never be called, even if the page is defined as "input" for some
action. In your particular case, you forward to
"/jsp/customer/CustomerConfirm.jsp". The action class will never be
called.

Michael.

On 10/9/05, Deep Chand <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'm new to Struts, so please bear with me :). I've a form asking for
> customer data with fields
> like name, address etc.  What I'm trying to achieve is this kind of 
> flow/design:
>
>  Page1) Customer enters their info. Submit button will take them to Page2.
>  Page2) They are asked to verify the same info again with read only
>  fields. Two buttons will be there, Confirm/Submit and Change. Change
>  will take them to Page1 and Confirm/Submit will take them to Page3.
>  Page3) The info is displayed to them again after entering it into the DB.
>
> What i see is the control never goes to  CustomerConfirmAction class.
> What I'm doing wrong?  Any help is appreciated.
>
> Thanks, Deep
>
> I've the following configuration and code.
>
>         <action-mappings>
>                 <action path  = "/customerCreate"
>                         type  = "customer.CustomerAction"
>                         scope = "request"
>                         input = "/jsp/customer/CustomerCreate.jsp"
>                         name  = "customerForm">
>                 <forward name="customerConfirm" 
> path="/jsp/customer/CustomerConfirm.jsp"/>
>                 </action>
>                 <action path  = "/customerConfirm"
>                         type  = "customer.CustomerConfirmAction"
>                         scope = "request"
>                         name  = "customerForm"
>                         input = "/jsp/customer/CustomerConfirm.jsp">
>                   <forward name="customerView"
> path="/jsp/customer/CustomerView.jsp"/>                         </action>
>         </action-mappings>
>
> CustomerCreate.jsp:
> <html:form action="customerCreate" method="POST">
>
>         <TABLE border="0" width="700">
>                 <TR>
>                         <TD>First Name</TD>
>                         <TD><html:text property="customer.firstName" /></TD>
>                 </TR>
>                  ... ....
>                 <TR>
>                         <TD><html:submit property="submit" /></TD>
>                         <TD><html:cancel property="cancel" /></TD>
>                 </TR>
>
> CustomerConfirm.jsp:
> <html:form action="customerConfirm" method="POST">
>
>         <TABLE border="0" width="700">
>                 <TR>
>                         <TD>First Name</TD>
>                         <TD><bean:write name="customer" property="firstName" 
> /></TD>
>                 </TR>
>
> CustomerAction.java:
>                 CustomerForm cf = (CustomerForm)form;
>                 Customer customer = cf.getCustomer();
>                 request.setAttribute("customer", customer);
>                 return mapping.findForward("customerConfirm");
>
> CustomerConfirmAction.java:
>                 Customer customer = 
> (Customer)request.getAttribute("customer");
>                 request.setAttribute("customer", customer);
>                 DAOFactory daf = 
> DAOFactory.getFactory(DAOFactory.FACTORY_MYSQL);
>
>                 CustomerDAO custDAO = daf.getCustomerDAO();
>                 if (custDAO.insertCustomer(customer) > 0) {
>                         return mapping.findForward("customerView");
>                 }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to