• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BeanUtil Exception

 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I am having a problem trying to submit my JSP. It causes an Exception

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:469)
org.apache.struts.chain.commands.servlet.PopulateActionForm.populate(PopulateActionForm.java:50)
java.lang.IllegalArgumentException: No bean specified
org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)


My JSP looks like this:




And here is my form. My form has a Data Bean Attribute



My field StripMap references a POJO class.




Basically I'm trying to display a table with checkbox in it and during the first time that my JSP load, everything went fine and it displays what I have expected. The problem is when I am submitting the form, it causes the exception.

My Mainform is in request scope. I have read the Struts FAQ regarding changing my object into STRING but I dont know how will I implement such. Is it not advisable to use Bean Object into ActionForm and should I just place all my StripMap property directly into the actionform?

Thanks for the help..
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's OK to reference a bean property in a Struts tag, but the bean must be instantiated. Struts won't instantiate it for you. Therefore change the declaration of the stripMap property in MainForm to:
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Merill,

Thanks for the help as always. I miss that instantiation part..

I'm just wondering, while trying to solve my problem, I browse into the Search of previous struts post and found some good advise regarding this exception.

One of which is to place my actionform into session scope instead of the request scope. I have tried it and it worked fine. But I am not into session scope and would prefer request scope.

Does it mean when I place my actionform into session scope, Struts takes care of all the instantiation of every databean in my form? Thanks again..
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by mark reyes:
Does it mean when I place my actionform into session scope, Struts takes care of all the instantiation of every databean in my form?

No, it doesn't. The same rules apply. The only difference is that once you instantiate a property of a session-scoped bean, it stays instantiated as long as the user remains signed on. With a request-scoped bean, the properties have to be re-instantiated with every new request.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic