You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yuriy Zubarev <yu...@yahoo.ca> on 2001/07/15 02:57:26 UTC

validation problem

Salutation to everyne!

I have a form (extends ActionForm) that has a property "countriesList"
which holds a list of beans. In jsp form page I have a code:

<bean:define id="cl" name="userForm" property="countriesList"/>

which is executed without problems when the page is shown first time,
but when I click submit without entering values into textboxes,
"valiate" method of my "UserForm" works out and redirects the flaw
back to "user.jsp" and here I get exception. Looks like "countryList"
property vanishes from "userForm".

<Jul 14, 2001 5:43:43 PM PDT> <Info> <HTTP>
<[WebAppServletContext(2485833,haa)] action:   Validation error(s), redire
cting to: /user.jsp>
<Jul 14, 2001 5:43:43 PM PDT> <Error> <HTTP>
<[WebAppServletContext(2485833,haa)] Servlet failed with Exception
java.lang.NullPointerException
        at weblogic.utils.UnsyncHashtable.put(UnsyncHashtable.java:272)
        at
weblogic.servlet.jsp.PageContextImpl.setAttribute(PageContextImpl.java:124)
        at
weblogic.servlet.jsp.PageContextImpl.setAttribute(PageContextImpl.java:149)
        at
org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:210)
        at jsp_servlet._user._jspService(_user.java:1899)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
        at
weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:157)
        at
org.apache.struts.action.ActionServlet.processValidate(ActionServlet.java:2149)
        at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564)
        at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
        at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
        at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1631)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

Any help will be highly appreciated.

Thank you for your time.

Best of luck,
Yuriy Zubarev


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: validation problem

Posted by Gregor Rayman <gr...@gmx.net>.
"Yuriy Zubarev" <yu...@hotmail.com> wrote:


> David,
>
> Yes it is. I think that userForm exists after the validation
> process (otherwise I would have gotten an error earlier), but something is
> wrong
> with countriesList. The form is quite big so I'll post part of it.

The problem might be that your form is in the request scope and your
countries list does not get populated from the submitted data. I've
similar "problems" when I used the ActionForm for displaying read
only properties which did not have an <html:hidden> on the jsp page.

In request scope it works something like this:

The ActionForm instace (A1) is used to fill jour JSP. A1 has been
probably prepared by some Action. After delivering the response
(JSP) the instace A1 is forgotten and eventually garbage collected.

The teh user sumbits your JSP. New instace (A2) of your ActionForm is
created and filled with the sumbitted values. If the countries
list is neither filled in the reset() method, nor the constructor,
nor the sumbitted HTTP parameters, than it might be empty or null.

Because the instace A1 and A2 are different.

If the form is in session scope, than A1 is preserved.

--
gR


Re: validation problem

Posted by Yuriy Zubarev <yu...@hotmail.com>.
David,

Yes it is. I think that userForm exists after the validation
process (otherwise I would have gotten an error earlier), but something is
wrong
with countriesList. The form is quite big so I'll post part of it.

<html:html>
...
<html:form action="/saveUser">
<html:hidden property="action"/>
<html:hidden property="id"/>
...
<html:text property="lastName" size="20"/>
...
<bean:define id="cl" name="userForm" property="countriesList"/>
<html:select property="country">
  <html:options collection="cl" property="code"
labelProperty="description"/>
</html:select>
...
</html:form>
...
</html:html>


Thank you for your time.

Best of luck,
Yuriy Zubarev


----- Original Message -----
From: "David Winterfeldt" <dw...@yahoo.com>
To: <st...@jakarta.apache.org>
Sent: Saturday, July 14, 2001 8:48 PM
Subject: Re: validation problem


> Is your bean:define inside your html:form tags?  If
> the userForm doesn't exist, you would get a null
> pointer exception trying to call it.  If this doesn't
> help, seeing the whole form might.
>
> David
>
> --- Yuriy Zubarev <yu...@yahoo.ca> wrote:
> > Salutation to everyne!
> >
> > I have a form (extends ActionForm) that has a
> > property "countriesList"
> > which holds a list of beans. In jsp form page I have
> > a code:
> >
> > <bean:define id="cl" name="userForm"
> > property="countriesList"/>
> >
> > which is executed without problems when the page is
> > shown first time,
> > but when I click submit without entering values into
> > textboxes,
> > "valiate" method of my "UserForm" works out and
> > redirects the flaw
> > back to "user.jsp" and here I get exception. Looks
> > like "countryList"
> > property vanishes from "userForm".
> >
> > <Jul 14, 2001 5:43:43 PM PDT> <Info> <HTTP>
> > <[WebAppServletContext(2485833,haa)] action:
> > Validation error(s), redire
> > cting to: /user.jsp>
> > <Jul 14, 2001 5:43:43 PM PDT> <Error> <HTTP>
> > <[WebAppServletContext(2485833,haa)] Servlet failed
> > with Exception
> > java.lang.NullPointerException
> >         at
> >
> weblogic.utils.UnsyncHashtable.put(UnsyncHashtable.java:272)
> >         at
> >
>
weblogic.servlet.jsp.PageContextImpl.setAttribute(PageContextImpl.java:124)
> >         at
> >
>
weblogic.servlet.jsp.PageContextImpl.setAttribute(PageContextImpl.java:149)
> >         at
> >
> org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:210)
> >         at
> > jsp_servlet._user._jspService(_user.java:1899)
> >         at
> >
> weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
> >         at
> >
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
> >         at
> >
>
weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImp
l.java:157)
> >         at
> >
>
org.apache.struts.action.ActionServlet.processValidate(ActionServlet.java:21
49)
> >         at
> >
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564)
> >         at
> >
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
> >         at
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> >         at
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >         at
> >
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
> >         at
> >
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1265)
> >         at
> >
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1631)
> >         at
> >
> weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
> >         at
> >
> weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >
> > Any help will be highly appreciated.
> >
> > Thank you for your time.
> >
> > Best of luck,
> > Yuriy Zubarev
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail
> > http://personal.mail.yahoo.com/
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/

Re: validation problem

Posted by David Winterfeldt <dw...@yahoo.com>.
Is your bean:define inside your html:form tags?  If
the userForm doesn't exist, you would get a null
pointer exception trying to call it.  If this doesn't
help, seeing the whole form might.

David

--- Yuriy Zubarev <yu...@yahoo.ca> wrote:
> Salutation to everyne!
> 
> I have a form (extends ActionForm) that has a
> property "countriesList"
> which holds a list of beans. In jsp form page I have
> a code:
> 
> <bean:define id="cl" name="userForm"
> property="countriesList"/>
> 
> which is executed without problems when the page is
> shown first time,
> but when I click submit without entering values into
> textboxes,
> "valiate" method of my "UserForm" works out and
> redirects the flaw
> back to "user.jsp" and here I get exception. Looks
> like "countryList"
> property vanishes from "userForm".
> 
> <Jul 14, 2001 5:43:43 PM PDT> <Info> <HTTP>
> <[WebAppServletContext(2485833,haa)] action:  
> Validation error(s), redire
> cting to: /user.jsp>
> <Jul 14, 2001 5:43:43 PM PDT> <Error> <HTTP>
> <[WebAppServletContext(2485833,haa)] Servlet failed
> with Exception
> java.lang.NullPointerException
>         at
>
weblogic.utils.UnsyncHashtable.put(UnsyncHashtable.java:272)
>         at
>
weblogic.servlet.jsp.PageContextImpl.setAttribute(PageContextImpl.java:124)
>         at
>
weblogic.servlet.jsp.PageContextImpl.setAttribute(PageContextImpl.java:149)
>         at
>
org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:210)
>         at
> jsp_servlet._user._jspService(_user.java:1899)
>         at
>
weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
>         at
>
weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:157)
>         at
>
org.apache.struts.action.ActionServlet.processValidate(ActionServlet.java:2149)
>         at
>
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564)
>         at
>
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
>         at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>         at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
>         at
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
>         at
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1631)
>         at
>
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>         at
>
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> 
> Any help will be highly appreciated.
> 
> Thank you for your time.
> 
> Best of luck,
> Yuriy Zubarev
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/