yes, martin. it works fine.

i have few .jsp pages without forms means they display reports and they work
fine with .cm mapping, so, i was thinking it would be the same for forms
also.

thanks much,
rama.


----- Original Message -----
From: "Martin Cooper" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, August 04, 2001 12:07 PM
Subject: Re: infinite loop


> Are you using extension mapping, with the extension ".cm"? If so, then
your
> infinite loop is happening because you are forwarding from the action
right
> back to the same action, instead of to the JSP page. Change your forward
to
> reference the JSP instead of the action, like this:
>
>  <forward name="success"              path="/adduser.jsp"/>
>
> and things should start working normally.
>
> --
> Martin Cooper
>
>
> ----- Original Message -----
> From: "Rama Krishna" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, August 04, 2001 11:55 AM
> Subject: infinite loop
>
>
> hi all,
>
> In continuation to my post yesterday,
>
> The following is my code. The flow is fine till Forwarding to Success
> and then instead of displaying, it starts again from the begining.
>
> If i remove the if condition in validate method then it displays the
> form with errors which is fine.
>
> am i doing something wrong????
>
>
> thanks,
> rama.
>
> Mappings:
>
> <!-- FIP User Profile Page bean -->
>   <form-bean      name="addUser"
>                      type="com.niku.cm.action.AddUser"/>
>
> <!-- FIP User Profile Page -->
>     <action    path="/adduser"
>       name="addUser"
>       validate="true"
>       input="/adduser.jsp"
>       type="com.niku.cm.action.AddUserAction">
>  <forward name="success"              path="/adduser.cm"/>
>  </action>
>
>
> adduser.jsp:
>
>
> <html:errors />
>
> <html:form action="/adduser?action=save" focus="fullname">
> <table width="55%" border="0"  cellspacing="1">
>     <tr>
>   <td class="fieldname" width="16%">Full Name*
>   </td>
>   <td class="field" width="16%"><html:text styleClass="noborder"
> property="fullname" />
>   </td></tr>
>       <tr><td class="fieldname" width="19%">Phone*
>   </td>
>   <td class="field" width="16%"><html:text styleClass="noborder"
> property="phone"/>
>       </td></tr>
>       <tr><td class="fieldname" width="19%">Email*
>   </td>
>   <td class="field" width="16%"><html:text styleClass="noborder"
> property="email"/>
>    </td></tr>
>       </table>
>      <p align=center><html:submit />&nbsp;&nbsp;<html:reset /></p>
> </html:form>
>
> AddUser.java (FormBean)
>
>
>  private String  action  = "create";
>  private String fullname = null;
>  private String phone  = null;
>  private String email  = "";
>  private String result  = "false";
>
>
>
>    public String getAction() { return (this.action); }
>    public void setAction(String action) {  this.action = action;  }
>
>   public String getFullname() {return (this.fullname); }
>   public void setFullname(String _fullname) {this.fullname = _fullname;}
>
>   public String getPhone() {return (this.phone);}
>   public void setPhone(String _phone) {this.phone = _phone;}
>
>   public String getEmail() {return (this.email); }
>   public void setEmail(String _email) {this.email = _email;}
>
>   public ActionErrors validate(ActionMapping mapping,
>                                  HttpServletRequest request) {
>      if((action.equals("create")) ||(action.equals("get"))) return null;
>
>      ActionErrors errors = new ActionErrors();
>         if ((fullname == null) || (fullname.length() < 1))
>             errors.add("fullname",
>                        new ActionError("error.fullname.required"));
>         if ((phone == null) || (phone.length() < 1))
>             errors.add("phone",
>                        new ActionError("error.phone.required"));
>         if ((email == null) || (email.length() < 1))
>             errors.add("email",
>                        new ActionError("error.email.required"));
>         return errors;
>
>     }
>
>  AddUserAction.java (action class)
>
> public final class AddUserAction extends Action {
>
>     public ActionForward perform(ActionMapping mapping,
>      ActionForm form,
>      HttpServletRequest request,
>      HttpServletResponse response)
>   throws IOException, ServletException {
>
>
>    file://get <file://get>  the application resources
>   MessageResources messages = getResources();
>
>    file://get <file://get>  the session
>   HttpSession   session = request.getSession();
>
>    file://get <file://get>  the action
>   String action = request.getParameter("action");
>   System.out.println("AddUserAction : Action is "+action);
>
>    file://if <file://if>  action is null set it to default
>   if (action == null)
>       action = "create";
>       if (servlet.getDebug() >= 1)
>           servlet.log("AddUserAction:  Processing " + action +"
> action");
>
>    file://if <file://if>  form is null then create new instance
>   if (form == null) {
>           if (servlet.getDebug() >= 1)
>               servlet.log(" Creating new AddUserForm bean under key "+
> mapping.getAttribute());
>       form = new AddUser();
>           if ("request".equals(mapping.getScope()))
>               request.setAttribute(mapping.getAttribute(), form);
>           else
>               session.setAttribute(mapping.getAttribute(), form);
>   }
>
>   AddUser addform = (AddUser) form;
>
>   if(action.equals("create")) {
>
>       /*
>             do nothing
>         */
>   }
>
>     // Forward control to the server page
>       if (servlet.getDebug() >= 1)
>               servlet.log(" Forwarding to success");
>      return (mapping.findForward("success"));
>     }
> }
>
>
>
>

Reply via email to