• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception creating bean of class

 
Simionu Ursache
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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 ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check PersonalBody_jsp.java, line 307 ? (it's the translated version of your jsp file).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts question in the Struts forum. I have moved this post there for you.
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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....
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 <htmlptionsCollection> 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
  • 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
  • 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
  • Quote
  • Report post to moderator
could it be a bug of Struts ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic