• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception creating bean of class

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there !

I am getting this error when accesing pages/tiles/bodys/PersonalBody.jsp (see stuts-config.xml)


I have the following configuration:

struts-config.xml:


class databeans.Personal:


Is there a problem because my Personal class extentds ObiectPersonal class and it should extend ActionForm ?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you check PersonalBody_jsp.java, line 307 ? (it's the translated version of your jsp file).
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask Struts question in the Struts forum. I have moved this post there for you.
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, your form bean must sub class of ActionForm.
 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so if i extend the class to ActionForm how can i still use the relation to ObiectPersistent class ?
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am not getting your problem actually why you want to relate ObiectPersistent in actionForm bean. ....
use ActionForm only for communicate controller and view....
Please describe your problem....
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Struts, it's generally a good idea to have two different objects -- one that is part of the Model, and may be persistent, such as your Personal bean. The other is the ActionForm. They may have the same property names, but the ActionForm properties will be Strings, while the model object properties may be numeric datatypes. The commons BeanUtils class that is included with Struts has a handy method copyProperties that will copy all properties of the same name from one bean to another.

A Struts ActionForm bean does not handle data types like BigDecimal. So, your Personal bean wouldn't work as an ActionForm anyway, even aside from the inheritance problem.
 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok...so here is the scenario :

I have two tables that keeps info's about Departments(Compartimente) of a company and staff (Personal) of every department. The relation between these two is held by relational column compartid.

For every table i have created a control class (Personal.class , Compartimente.class) with setter and getter methods. This classes are extending the ObiectPersistent.class in which i do the insert, update, delete methods of the records.

Personal.class


Compartimente.class


I would like to see in a page all the staff from one department. so i have a first form with a select option that show all the departments and a refresh button. When i click the refresh button, the second form on the page load the info about the staff from the compartiment selected.

Here is the source:


I can see the list of compartiments, but when i click the refreh button i get the error.

Other files:
struts-config.xml


CompartPersSelectedBean.class


SelectAngajatAction.class


getObjects from ObiectPersistent.class
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you're not using the Personal bean as the form bean for an Action class, it is completely unneccessary to define it as a form bean at all. Remove the line:

from your struts-config.xml file and it should work.

A couple of observations, though:

1. It is considered very bad form to include database access code in a JSP as you have done. Struts is a Model/View/Controller framework that helps you separate these three functions into separate componenents. By putting database access code in your JSP, you're mixing model logic into a view component.

2. If you read a bit about the <html:optionsCollection> tag, you will see that it is much easier to use this tag than the method you're using. Here is the link to the documentation.
[ February 01, 2007: Message edited by: Merrill Higginson ]
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you are using struts...you should follow struts rules..you are breaking struts rules here...
 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have solved the problems but got into another one. Now when i submit the date i get a blank .do page

If i go back and the refresh(F5) the data that should be displayed is displayed!

And this happens at all pages. I have done a very simple login page that just outputs the entered data and everything is ok.

Do you have any ideas ?
 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could it be a bug of Struts ?
reply
    Bookmark Topic Watch Topic
  • New Topic