struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <newton.d...@yahoo.com>
Subject Re: ActionErrors in execute() method of action
Date Sun, 01 Jun 2008 15:47:29 GMT
Did you implement a validate method that returns a non-null ActionErrors? If not, why wouldn't
you just create your own instance of an ActionErrors?

http://struts.apache.org/1.2.9/api/org/apache/struts/action/ActionForm.html#validate(org.apache.struts.action.ActionMapping,%20javax.servlet.ServletRequest)

I guess I'm not sure what the issue is; you're calling a method that's documented to return
null and trying to call one of its methods.

Dave

--- On Sun, 6/1/08, (¯`·.k ! k !.·´¯) <g_f_g_5@yahoo.com> wrote:

> From: (¯`·.k ! k !.·´¯) <g_f_g_5@yahoo.com>
> Subject: Re: ActionErrors in execute() method of action
> To: "Struts Users Mailing List" <user@struts.apache.org>
> Date: Sunday, June 1, 2008, 11:04 AM
> DynaActionForm.validate() returns ActionErrors but it is
> null ... 
> see this code...
> &nbsp;
> &nbsp;&nbsp;&nbsp; public ActionForward
> execute(ActionMapping mapping, ActionForm&nbsp; form,
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> HttpServletRequest request, HttpServletResponse response)
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> throws Exception {
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> LoginBl bl = new LoginBl();
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> DynaActionForm loginForm = (DynaActionForm) form;
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> String uname = loginForm.getString("uname");
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> String upass = loginForm.getString("upass");
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> if(bl.login(uname,upass))
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> return mapping.findForward(SUCCESS);
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> else{
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> ActionErrors errors = loginForm.validate(mapping, request);
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> errors.add(null,new
> ActionMessage("login.incorrect"));
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> return mapping.getInputForward();
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> }
> &nbsp;&nbsp;&nbsp; }
> &nbsp;
> when i run the application ... if i give the right user and
> pass its ok .. but if give wrong .. instead of showing me
> the error on the input page .. it gives a
> NullPointerException.... 
> &nbsp;
> &nbsp;
> 
> 
> &nbsp;
> 
> 
> --- On Sun, 6/1/08, Dave Newton
> &lt;newton.dave@yahoo.com&gt; wrote:
> 
> From: Dave Newton &lt;newton.dave@yahoo.com&gt;
> Subject: Re: ActionErrors in execute() method of action
> To: "Struts Users Mailing List"
> &lt;user@struts.apache.org&gt;
> Date: Sunday, June 1, 2008, 9:16 AM
> 
> --- On Sun, 6/1/08, (¯`·.k ! k !.·´¯)
> &lt;g_f_g_5@yahoo.com&gt; wrote:
> &gt; but im using
> org.apache.struts.action.DynaActionForm instead of
> &gt; ActionForm so i dont have validate() method that
> would
> &gt; return ActionErrors&amp;nbsp; .
> 
> What does your version of DynaActionForm.validate() return?
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message