You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Narasimha Raju Naidu <fe...@gmail.com> on 2008/08/09 08:52:06 UTC
not displaying Action errors
hi to all,
im sending my code please check where i am doing mistake
form.jsp
---------------
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<html:errors/>
<div style="background-color:#fcc;border: 1px dashed
blue;width:280px;margin:2px;">
<html:form action="/login.do">
<table cellpadding=2 align=center style="font-family:verdana;font-size:15;">
<tr><td><b>User Name</b></td>
<td><html:text property="userName"/></td></tr>
<tr>
<td><b>Password</b></td>
<td><html:password property="pwd"/></td></tr>
<tr><td>
<html:submit property="submit" value="Connect"/></td><td>
<html:reset property="reset" value="Re-Try"/></td></tr>
</table>
</html:form>
</div>
-------------------------------------------------------------------------
formbean
---------------------------
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginBean extends ActionForm
{
private String userName;
private String pwd;
public void setUserName(String userName)
{
this.userName=userName;
}
public String getUserName()
{
return userName;
}
public void setPwd(String pwd)
{
this.pwd=pwd;
}
public String getPwd()
{
return pwd;
}
public void reset(ActionMapping mapping,HttpServletRequest request)
{
System.out.println("--reset LoginForm--");
this.userName="";
this.pwd="";
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest
request)
{
ActionErrors aes=new ActionErrors();
if(userName==null||userName=="")
{
aes.add("userName",new ActionError("UserName is Required"));
}
if(pwd==null||pwd=="")
{
aes.add("pwd",new ActionError("Password is Required"));
}
return aes;
}
}
--------------------------------------------------------------
action class
----------------------
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response) throws
Exception
{
LoginBean login= (LoginBean)form;
return mapping.findForward("succ");
}
}
-------------------------------------------------------------------
struts-config.xml code
------------------------------
<form-beans>
<form-bean name="LBBean" type="LoginBean"/>
</form-beans>
<action path="/login" type="LoginAction" name="LBBean" scope="request"
input="/pages/login.jsp" validate="true">
<forward name="succ" path="/pages/succ.jsp"/>
</action>
while compiling im not getting any errors while running if i did not give
any input i am getting bullet not the exact error what i gave. waiting for
you people's valuable replys.
Regards,
Narasimha Raju
uni...
Re: not displaying Action errors
Posted by Narasimha Raju Naidu <fe...@gmail.com>.
Thanks to all. my problem was resolved. thanks a lot.
Regards,
On Tue, Aug 12, 2008 at 11:51 AM, Umar Bilal <ub...@xavient.com> wrote:
>
>
> Hello this is regarding your Bean Validation. Yesterday I only checked
> if everything was right meaning that it wont submit the form until you
> pass the validation. I didn't realize you wanted the messages to come on
> the page anyway do the following
>
> Add these lines to your ApplicationProperties
>
> null.checkId = {0} cannot be null or empty
>
> null.checkPwd ={0} does not pass the validation rules
>
> And this is your valiadtion Method
>
> public ActionErrors validate
> (
> ActionMapping mapping,
> HttpServletRequest request )
> {
>
> ActionErrors errors = new ActionErrors();
>
> if( getUserName().length()<1 )
> {
> errors.add("name",new ActionError("null.checkId","UserName"));
> }
>
> if( getPwd().length()<1 )
> {
> errors.add("password",new
> ActionError("null.checkPwd","Password"));
> }
> return errors;
> }
> And write this on your login jsp infront of your fields or anywhere else
> where you want to display the message
>
> <html:errors property="name"/>
> <html:password property="pwd" />
>
> That will solve your issue
> take care
> Bye
>
> -----Original Message-----
> From: Richard Yee [mailto:ryee@cruzio.com]
> Sent: Tuesday, August 12, 2008 7:48 AM
> To: Struts Users Mailing List
> Subject: Re: not displaying Action errors
>
> Have you debugged your code with a source level debugger? Are you sure
> that the error messages are getting added?
>
> -R
>
> Narasimha Raju Naidu wrote:
> > thanks for your reply. but itz not working. im getting the same
> > output. for reference im sending screen shot of that output please
> check once.
> >
> >
> > Regards,
> > -------------
> >
> > On Sun, Aug 10, 2008 at 9:55 PM, Richard Yee <ry...@cruzio.com> wrote:
> >
> >
> >> You are using == to test string equality instead of equals() -R
> >>
> >> Sent from my iPhone
> >>
> >>
> >> On Aug 8, 2008, at 11:52 PM, "Narasimha Raju Naidu"
> >> <fe...@gmail.com>
> >> wrote:
> >>
> >> hi to all,
> >>
> >>> im sending my code please check where i am doing mistake
> >>>
> >>> form.jsp
> >>> ---------------
> >>> <%@ taglib uri="/tags/struts-html" prefix="html"%> <html:errors/>
> >>> <div style="background-color:#fcc;border: 1px dashed
> >>> blue;width:280px;margin:2px;"> <html:form action="/login.do"> <table
>
> >>> cellpadding=2 align=center
> >>> style="font-family:verdana;font-size:15;">
> >>>
> >>> <tr><td><b>User Name</b></td>
> >>> <td><html:text property="userName"/></td></tr> <tr>
> >>> <td><b>Password</b></td> <td><html:password
> >>> property="pwd"/></td></tr> <tr><td> <html:submit property="submit"
> >>> value="Connect"/></td><td> <html:reset property="reset"
> >>> value="Re-Try"/></td></tr> </table> </html:form> </div>
> >>>
> >>> --------------------------------------------------------------------
> >>> -----
> >>> formbean
> >>> ---------------------------
> >>> import javax.servlet.http.*;
> >>> import org.apache.struts.action.*;
> >>>
> >>> public class LoginBean extends ActionForm {
> >>> private String userName;
> >>> private String pwd;
> >>>
> >>> public void setUserName(String userName)
> >>> {
> >>> this.userName=userName;
> >>> }
> >>> public String getUserName()
> >>> {
> >>> return userName;
> >>> }
> >>> public void setPwd(String pwd)
> >>> {
> >>> this.pwd=pwd;
> >>> }
> >>> public String getPwd()
> >>> {
> >>> return pwd;
> >>> }
> >>>
> >>> public void reset(ActionMapping mapping,HttpServletRequest
> request)
> >>> {
> >>> System.out.println("--reset LoginForm--");
> >>> this.userName="";
> >>> this.pwd="";
> >>> }
> >>>
> >>> public ActionErrors validate(ActionMapping
> >>> mapping,HttpServletRequest
> >>> request)
> >>> {
> >>> ActionErrors aes=new ActionErrors();
> >>> if(userName==null||userName=="")
> >>> {
> >>> aes.add("userName",new ActionError("UserName is Required"));
> >>> }
> >>> if(pwd==null||pwd=="")
> >>> {
> >>> aes.add("pwd",new ActionError("Password is Required"));
> >>> }
> >>> return aes;
> >>> }
> >>> }
> >>>
> >>> --------------------------------------------------------------
> >>> action class
> >>> ----------------------
> >>>
> >>> import javax.servlet.http.*;
> >>> import org.apache.struts.action.*;
> >>>
> >>>
> >>> public class LoginAction extends Action {
> >>> public ActionForward execute(ActionMapping mapping,ActionForm
> >>> form,HttpServletRequest request,HttpServletResponse response) throws
>
> >>> Exception
> >>> {
> >>> LoginBean login= (LoginBean)form;
> >>> return mapping.findForward("succ");
> >>> }
> >>> }
> >>>
> >>> -------------------------------------------------------------------
> >>> struts-config.xml code
> >>> ------------------------------
> >>> <form-beans>
> >>> <form-bean name="LBBean" type="LoginBean"/> </form-beans>
> >>>
> >>>
> >>> <action path="/login" type="LoginAction" name="LBBean"
> scope="request"
> >>> input="/pages/login.jsp" validate="true">
> >>> <forward name="succ" path="/pages/succ.jsp"/>
> >>> </action>
> >>>
> >>>
> >>> while compiling im not getting any errors while running if i did not
> give
> >>> any input i am getting bullet not the exact error what i gave.
> waiting for
> >>> you people's valuable replys.
> >>>
> >>> Regards,
> >>>
> >>> Narasimha Raju
> >>>
> >>>
> >>>
> >>>
> >>> uni...
> >>>
> >>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >>
> >
> >
> >
> > uni...
> >
> >
>
>
> ---------------------------------------------------------------------
> 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
>
>
--
uni...
RE: not displaying Action errors
Posted by Umar Bilal <ub...@xavient.com>.
Hello this is regarding your Bean Validation. Yesterday I only checked
if everything was right meaning that it wont submit the form until you
pass the validation. I didn't realize you wanted the messages to come on
the page anyway do the following
Add these lines to your ApplicationProperties
null.checkId = {0} cannot be null or empty
null.checkPwd ={0} does not pass the validation rules
And this is your valiadtion Method
public ActionErrors validate
(
ActionMapping mapping,
HttpServletRequest request )
{
ActionErrors errors = new ActionErrors();
if( getUserName().length()<1 )
{
errors.add("name",new ActionError("null.checkId","UserName"));
}
if( getPwd().length()<1 )
{
errors.add("password",new
ActionError("null.checkPwd","Password"));
}
return errors;
}
And write this on your login jsp infront of your fields or anywhere else
where you want to display the message
<html:errors property="name"/>
<html:password property="pwd" />
That will solve your issue
take care
Bye
-----Original Message-----
From: Richard Yee [mailto:ryee@cruzio.com]
Sent: Tuesday, August 12, 2008 7:48 AM
To: Struts Users Mailing List
Subject: Re: not displaying Action errors
Have you debugged your code with a source level debugger? Are you sure
that the error messages are getting added?
-R
Narasimha Raju Naidu wrote:
> thanks for your reply. but itz not working. im getting the same
> output. for reference im sending screen shot of that output please
check once.
>
>
> Regards,
> -------------
>
> On Sun, Aug 10, 2008 at 9:55 PM, Richard Yee <ry...@cruzio.com> wrote:
>
>
>> You are using == to test string equality instead of equals() -R
>>
>> Sent from my iPhone
>>
>>
>> On Aug 8, 2008, at 11:52 PM, "Narasimha Raju Naidu"
>> <fe...@gmail.com>
>> wrote:
>>
>> hi to all,
>>
>>> im sending my code please check where i am doing mistake
>>>
>>> form.jsp
>>> ---------------
>>> <%@ taglib uri="/tags/struts-html" prefix="html"%> <html:errors/>
>>> <div style="background-color:#fcc;border: 1px dashed
>>> blue;width:280px;margin:2px;"> <html:form action="/login.do"> <table
>>> cellpadding=2 align=center
>>> style="font-family:verdana;font-size:15;">
>>>
>>> <tr><td><b>User Name</b></td>
>>> <td><html:text property="userName"/></td></tr> <tr>
>>> <td><b>Password</b></td> <td><html:password
>>> property="pwd"/></td></tr> <tr><td> <html:submit property="submit"
>>> value="Connect"/></td><td> <html:reset property="reset"
>>> value="Re-Try"/></td></tr> </table> </html:form> </div>
>>>
>>> --------------------------------------------------------------------
>>> -----
>>> formbean
>>> ---------------------------
>>> import javax.servlet.http.*;
>>> import org.apache.struts.action.*;
>>>
>>> public class LoginBean extends ActionForm {
>>> private String userName;
>>> private String pwd;
>>>
>>> public void setUserName(String userName)
>>> {
>>> this.userName=userName;
>>> }
>>> public String getUserName()
>>> {
>>> return userName;
>>> }
>>> public void setPwd(String pwd)
>>> {
>>> this.pwd=pwd;
>>> }
>>> public String getPwd()
>>> {
>>> return pwd;
>>> }
>>>
>>> public void reset(ActionMapping mapping,HttpServletRequest
request)
>>> {
>>> System.out.println("--reset LoginForm--");
>>> this.userName="";
>>> this.pwd="";
>>> }
>>>
>>> public ActionErrors validate(ActionMapping
>>> mapping,HttpServletRequest
>>> request)
>>> {
>>> ActionErrors aes=new ActionErrors();
>>> if(userName==null||userName=="")
>>> {
>>> aes.add("userName",new ActionError("UserName is Required"));
>>> }
>>> if(pwd==null||pwd=="")
>>> {
>>> aes.add("pwd",new ActionError("Password is Required"));
>>> }
>>> return aes;
>>> }
>>> }
>>>
>>> --------------------------------------------------------------
>>> action class
>>> ----------------------
>>>
>>> import javax.servlet.http.*;
>>> import org.apache.struts.action.*;
>>>
>>>
>>> public class LoginAction extends Action {
>>> public ActionForward execute(ActionMapping mapping,ActionForm
>>> form,HttpServletRequest request,HttpServletResponse response) throws
>>> Exception
>>> {
>>> LoginBean login= (LoginBean)form;
>>> return mapping.findForward("succ");
>>> }
>>> }
>>>
>>> -------------------------------------------------------------------
>>> struts-config.xml code
>>> ------------------------------
>>> <form-beans>
>>> <form-bean name="LBBean" type="LoginBean"/> </form-beans>
>>>
>>>
>>> <action path="/login" type="LoginAction" name="LBBean"
scope="request"
>>> input="/pages/login.jsp" validate="true">
>>> <forward name="succ" path="/pages/succ.jsp"/>
>>> </action>
>>>
>>>
>>> while compiling im not getting any errors while running if i did not
give
>>> any input i am getting bullet not the exact error what i gave.
waiting for
>>> you people's valuable replys.
>>>
>>> Regards,
>>>
>>> Narasimha Raju
>>>
>>>
>>>
>>>
>>> uni...
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
>
> uni...
>
>
---------------------------------------------------------------------
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
Re: not displaying Action errors
Posted by Richard Yee <ry...@cruzio.com>.
Have you debugged your code with a source level debugger? Are you sure
that the error messages are getting added?
-R
Narasimha Raju Naidu wrote:
> thanks for your reply. but itz not working. im getting the same output. for
> reference im sending screen shot of that output please check once.
>
>
> Regards,
> -------------
>
> On Sun, Aug 10, 2008 at 9:55 PM, Richard Yee <ry...@cruzio.com> wrote:
>
>
>> You are using == to test string equality instead of equals()
>> -R
>>
>> Sent from my iPhone
>>
>>
>> On Aug 8, 2008, at 11:52 PM, "Narasimha Raju Naidu" <fe...@gmail.com>
>> wrote:
>>
>> hi to all,
>>
>>> im sending my code please check where i am doing mistake
>>>
>>> form.jsp
>>> ---------------
>>> <%@ taglib uri="/tags/struts-html" prefix="html"%>
>>> <html:errors/>
>>> <div style="background-color:#fcc;border: 1px dashed
>>> blue;width:280px;margin:2px;">
>>> <html:form action="/login.do">
>>> <table cellpadding=2 align=center
>>> style="font-family:verdana;font-size:15;">
>>>
>>> <tr><td><b>User Name</b></td>
>>> <td><html:text property="userName"/></td></tr>
>>> <tr>
>>> <td><b>Password</b></td>
>>> <td><html:password property="pwd"/></td></tr>
>>> <tr><td>
>>> <html:submit property="submit" value="Connect"/></td><td>
>>> <html:reset property="reset" value="Re-Try"/></td></tr>
>>> </table>
>>> </html:form>
>>> </div>
>>>
>>> -------------------------------------------------------------------------
>>> formbean
>>> ---------------------------
>>> import javax.servlet.http.*;
>>> import org.apache.struts.action.*;
>>>
>>> public class LoginBean extends ActionForm
>>> {
>>> private String userName;
>>> private String pwd;
>>>
>>> public void setUserName(String userName)
>>> {
>>> this.userName=userName;
>>> }
>>> public String getUserName()
>>> {
>>> return userName;
>>> }
>>> public void setPwd(String pwd)
>>> {
>>> this.pwd=pwd;
>>> }
>>> public String getPwd()
>>> {
>>> return pwd;
>>> }
>>>
>>> public void reset(ActionMapping mapping,HttpServletRequest request)
>>> {
>>> System.out.println("--reset LoginForm--");
>>> this.userName="";
>>> this.pwd="";
>>> }
>>>
>>> public ActionErrors validate(ActionMapping mapping,HttpServletRequest
>>> request)
>>> {
>>> ActionErrors aes=new ActionErrors();
>>> if(userName==null||userName=="")
>>> {
>>> aes.add("userName",new ActionError("UserName is Required"));
>>> }
>>> if(pwd==null||pwd=="")
>>> {
>>> aes.add("pwd",new ActionError("Password is Required"));
>>> }
>>> return aes;
>>> }
>>> }
>>>
>>> --------------------------------------------------------------
>>> action class
>>> ----------------------
>>>
>>> import javax.servlet.http.*;
>>> import org.apache.struts.action.*;
>>>
>>>
>>> public class LoginAction extends Action
>>> {
>>> public ActionForward execute(ActionMapping mapping,ActionForm
>>> form,HttpServletRequest request,HttpServletResponse response) throws
>>> Exception
>>> {
>>> LoginBean login= (LoginBean)form;
>>> return mapping.findForward("succ");
>>> }
>>> }
>>>
>>> -------------------------------------------------------------------
>>> struts-config.xml code
>>> ------------------------------
>>> <form-beans>
>>> <form-bean name="LBBean" type="LoginBean"/>
>>> </form-beans>
>>>
>>>
>>> <action path="/login" type="LoginAction" name="LBBean" scope="request"
>>> input="/pages/login.jsp" validate="true">
>>> <forward name="succ" path="/pages/succ.jsp"/>
>>> </action>
>>>
>>>
>>> while compiling im not getting any errors while running if i did not give
>>> any input i am getting bullet not the exact error what i gave. waiting for
>>> you people's valuable replys.
>>>
>>> Regards,
>>>
>>> Narasimha Raju
>>>
>>>
>>>
>>>
>>> uni...
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
>
> uni...
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: not displaying Action errors
Posted by Narasimha Raju Naidu <fe...@gmail.com>.
thanks for your reply. but itz not working. im getting the same output. for
reference im sending screen shot of that output please check once.
Regards,
-------------
On Sun, Aug 10, 2008 at 9:55 PM, Richard Yee <ry...@cruzio.com> wrote:
> You are using == to test string equality instead of equals()
> -R
>
> Sent from my iPhone
>
>
> On Aug 8, 2008, at 11:52 PM, "Narasimha Raju Naidu" <fe...@gmail.com>
> wrote:
>
> hi to all,
>>
>>
>> im sending my code please check where i am doing mistake
>>
>> form.jsp
>> ---------------
>> <%@ taglib uri="/tags/struts-html" prefix="html"%>
>> <html:errors/>
>> <div style="background-color:#fcc;border: 1px dashed
>> blue;width:280px;margin:2px;">
>> <html:form action="/login.do">
>> <table cellpadding=2 align=center
>> style="font-family:verdana;font-size:15;">
>>
>> <tr><td><b>User Name</b></td>
>> <td><html:text property="userName"/></td></tr>
>> <tr>
>> <td><b>Password</b></td>
>> <td><html:password property="pwd"/></td></tr>
>> <tr><td>
>> <html:submit property="submit" value="Connect"/></td><td>
>> <html:reset property="reset" value="Re-Try"/></td></tr>
>> </table>
>> </html:form>
>> </div>
>>
>> -------------------------------------------------------------------------
>> formbean
>> ---------------------------
>> import javax.servlet.http.*;
>> import org.apache.struts.action.*;
>>
>> public class LoginBean extends ActionForm
>> {
>> private String userName;
>> private String pwd;
>>
>> public void setUserName(String userName)
>> {
>> this.userName=userName;
>> }
>> public String getUserName()
>> {
>> return userName;
>> }
>> public void setPwd(String pwd)
>> {
>> this.pwd=pwd;
>> }
>> public String getPwd()
>> {
>> return pwd;
>> }
>>
>> public void reset(ActionMapping mapping,HttpServletRequest request)
>> {
>> System.out.println("--reset LoginForm--");
>> this.userName="";
>> this.pwd="";
>> }
>>
>> public ActionErrors validate(ActionMapping mapping,HttpServletRequest
>> request)
>> {
>> ActionErrors aes=new ActionErrors();
>> if(userName==null||userName=="")
>> {
>> aes.add("userName",new ActionError("UserName is Required"));
>> }
>> if(pwd==null||pwd=="")
>> {
>> aes.add("pwd",new ActionError("Password is Required"));
>> }
>> return aes;
>> }
>> }
>>
>> --------------------------------------------------------------
>> action class
>> ----------------------
>>
>> import javax.servlet.http.*;
>> import org.apache.struts.action.*;
>>
>>
>> public class LoginAction extends Action
>> {
>> public ActionForward execute(ActionMapping mapping,ActionForm
>> form,HttpServletRequest request,HttpServletResponse response) throws
>> Exception
>> {
>> LoginBean login= (LoginBean)form;
>> return mapping.findForward("succ");
>> }
>> }
>>
>> -------------------------------------------------------------------
>> struts-config.xml code
>> ------------------------------
>> <form-beans>
>> <form-bean name="LBBean" type="LoginBean"/>
>> </form-beans>
>>
>>
>> <action path="/login" type="LoginAction" name="LBBean" scope="request"
>> input="/pages/login.jsp" validate="true">
>> <forward name="succ" path="/pages/succ.jsp"/>
>> </action>
>>
>>
>> while compiling im not getting any errors while running if i did not give
>> any input i am getting bullet not the exact error what i gave. waiting for
>> you people's valuable replys.
>>
>> Regards,
>>
>> Narasimha Raju
>>
>>
>>
>>
>> uni...
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
uni...
Re: not displaying Action errors
Posted by Richard Yee <ry...@cruzio.com>.
You are using == to test string equality instead of equals()
-R
Sent from my iPhone
On Aug 8, 2008, at 11:52 PM, "Narasimha Raju Naidu"
<fe...@gmail.com> wrote:
> hi to all,
>
>
> im sending my code please check where i am doing mistake
>
> form.jsp
> ---------------
> <%@ taglib uri="/tags/struts-html" prefix="html"%>
> <html:errors/>
> <div style="background-color:#fcc;border: 1px dashed
> blue;width:280px;margin:2px;">
> <html:form action="/login.do">
> <table cellpadding=2 align=center style="font-family:verdana;font-
> size:15;">
>
> <tr><td><b>User Name</b></td>
> <td><html:text property="userName"/></td></tr>
> <tr>
> <td><b>Password</b></td>
> <td><html:password property="pwd"/></td></tr>
> <tr><td>
> <html:submit property="submit" value="Connect"/></td><td>
> <html:reset property="reset" value="Re-Try"/></td></tr>
> </table>
> </html:form>
> </div>
>
> ---
> ----------------------------------------------------------------------
> formbean
> ---------------------------
> import javax.servlet.http.*;
> import org.apache.struts.action.*;
>
> public class LoginBean extends ActionForm
> {
> private String userName;
> private String pwd;
>
> public void setUserName(String userName)
> {
> this.userName=userName;
> }
> public String getUserName()
> {
> return userName;
> }
> public void setPwd(String pwd)
> {
> this.pwd=pwd;
> }
> public String getPwd()
> {
> return pwd;
> }
>
> public void reset(ActionMapping mapping,HttpServletRequest request)
> {
> System.out.println("--reset LoginForm--");
> this.userName="";
> this.pwd="";
> }
>
> public ActionErrors validate(ActionMapping
> mapping,HttpServletRequest
> request)
> {
> ActionErrors aes=new ActionErrors();
> if(userName==null||userName=="")
> {
> aes.add("userName",new ActionError("UserName is Required"));
> }
> if(pwd==null||pwd=="")
> {
> aes.add("pwd",new ActionError("Password is Required"));
> }
> return aes;
> }
> }
>
> --------------------------------------------------------------
> action class
> ----------------------
>
> import javax.servlet.http.*;
> import org.apache.struts.action.*;
>
>
> public class LoginAction extends Action
> {
> public ActionForward execute(ActionMapping mapping,ActionForm
> form,HttpServletRequest request,HttpServletResponse response) throws
> Exception
> {
> LoginBean login= (LoginBean)form;
> return mapping.findForward("succ");
> }
> }
>
> -------------------------------------------------------------------
> struts-config.xml code
> ------------------------------
> <form-beans>
> <form-bean name="LBBean" type="LoginBean"/>
> </form-beans>
>
>
> <action path="/login" type="LoginAction" name="LBBean" scope="request"
> input="/pages/login.jsp" validate="true">
> <forward name="succ" path="/pages/succ.jsp"/>
> </action>
>
>
> while compiling im not getting any errors while running if i did not
> give
> any input i am getting bullet not the exact error what i gave.
> waiting for
> you people's valuable replys.
>
> Regards,
>
> Narasimha Raju
>
>
>
>
> uni...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: not displaying Action errors
Posted by Umar Bilal <ub...@xavient.com>.
Hi I went through your code it looks absolutely fine except that
ActionError is obsolute now use ActionMessage instead. That could be a
reason since your error is on validation. Try this and if you couldn't
get the desired result is suggest you do the validation using
ResourceBundle.
Take care
bye
-----Original Message-----
From: Narasimha Raju Naidu [mailto:feel2work@gmail.com]
Sent: Saturday, August 09, 2008 12:22 PM
To: user@struts.apache.org
Subject: not displaying Action errors
hi to all,
im sending my code please check where i am doing mistake
form.jsp
---------------
<%@ taglib uri="/tags/struts-html" prefix="html"%> <html:errors/> <div
style="background-color:#fcc;border: 1px dashed
blue;width:280px;margin:2px;"> <html:form action="/login.do"> <table
cellpadding=2 align=center style="font-family:verdana;font-size:15;">
<tr><td><b>User Name</b></td>
<td><html:text property="userName"/></td></tr> <tr>
<td><b>Password</b></td> <td><html:password property="pwd"/></td></tr>
<tr><td> <html:submit property="submit" value="Connect"/></td><td>
<html:reset property="reset" value="Re-Try"/></td></tr> </table>
</html:form> </div>
------------------------------------------------------------------------
-
formbean
---------------------------
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginBean extends ActionForm {
private String userName;
private String pwd;
public void setUserName(String userName)
{
this.userName=userName;
}
public String getUserName()
{
return userName;
}
public void setPwd(String pwd)
{
this.pwd=pwd;
}
public String getPwd()
{
return pwd;
}
public void reset(ActionMapping mapping,HttpServletRequest request)
{
System.out.println("--reset LoginForm--");
this.userName="";
this.pwd="";
}
public ActionErrors validate(ActionMapping
mapping,HttpServletRequest
request)
{
ActionErrors aes=new ActionErrors();
if(userName==null||userName=="")
{
aes.add("userName",new ActionError("UserName is Required"));
}
if(pwd==null||pwd=="")
{
aes.add("pwd",new ActionError("Password is Required"));
}
return aes;
}
}
--------------------------------------------------------------
action class
----------------------
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response) throws
Exception
{
LoginBean login= (LoginBean)form;
return mapping.findForward("succ");
}
}
-------------------------------------------------------------------
struts-config.xml code
------------------------------
<form-beans>
<form-bean name="LBBean" type="LoginBean"/> </form-beans>
<action path="/login" type="LoginAction" name="LBBean" scope="request"
input="/pages/login.jsp" validate="true">
<forward name="succ" path="/pages/succ.jsp"/>
</action>
while compiling im not getting any errors while running if i did not
give any input i am getting bullet not the exact error what i gave.
waiting for you people's valuable replys.
Regards,
Narasimha Raju
uni...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org