| Author |
Exception creating bean of class
|
Simionu Ursache
Greenhorn
Joined: Jan 28, 2007
Posts: 20
|
|
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
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Did you check PersonalBody_jsp.java, line 307 ? (it's the translated version of your jsp file).
|
[My Blog]
All roads lead to JavaRanch
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56233
|
|
|
Please be sure to ask Struts question in the Struts forum. I have moved this post there for you.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Milan Jagatiya
Ranch Hand
Joined: Jan 01, 2007
Posts: 164
|
|
|
well, your form bean must sub class of ActionForm.
|
Milan.<br />I can because I think I can...
|
 |
Simionu Ursache
Greenhorn
Joined: Jan 28, 2007
Posts: 20
|
|
|
so if i extend the class to ActionForm how can i still use the relation to ObiectPersistent class ?
|
 |
Milan Jagatiya
Ranch Hand
Joined: Jan 01, 2007
Posts: 164
|
|
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
Joined: Feb 15, 2005
Posts: 4864
|
|
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.
|
Merrill
Consultant, Sima Solutions
|
 |
Simionu Ursache
Greenhorn
Joined: Jan 28, 2007
Posts: 20
|
|
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
Joined: Feb 15, 2005
Posts: 4864
|
|
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 ptionsCollection> 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
Joined: Jan 01, 2007
Posts: 164
|
|
|
if you are using struts...you should follow struts rules..you are breaking struts rules here...
|
 |
Simionu Ursache
Greenhorn
Joined: Jan 28, 2007
Posts: 20
|
|
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
Joined: Jan 28, 2007
Posts: 20
|
|
|
could it be a bug of Struts ?
|
 |
 |
|
|
subject: Exception creating bean of class
|
|
|