tnx Laurie it worked
Laurie Harper wrote:
>
> Your Department class doesn't initialize its 'program' member when the
> no-arg constructor is called so when BeanUtils tries to fill in the data
> from the request, program will be null. I suspect that is your problem.
> Two things to try:
>
> 1) turn logging up to DEBUG for BeanUtils; that should show you if this
> is indeed the problem (and if not, what is)
>
> 2) try changing the field definition to
>
> private StudyProgram program = new StudyProgram();
>
> That may not be how you want to init that member, but you can worry
> about that afterwards if it works.
>
> L.
>
> auz wrote:
>> yep both ActionFormBeans are java bean compliant here's the code
>>
>> note i didn't copy any irelevevant method (dont have reset() method for
>> any
>> bean)
>> =============================
>> bean1
>> ==============================
>> package beans.studyProgram;
>>
>>
>> public class StudyProgram extends
>> org.apache.struts.validator.ValidatorActionForm {
>>
>> private static final long serialVersionUID = -3131205735075358925L;
>>
>> private Integer id;
>> private String name;
>> private Integer duration;
>> private Integer ects;
>> private Boolean active;
>> private String description;
>>
>> public StudyProgram() {
>> super();
>> }
>>
>> public StudyProgram (Integer id) {
>> this.id = id;
>> }
>>
>> public StudyProgram(Integer id, String name, Integer duration, Integer
>> ects, Boolean active, String description) {
>> super();
>> this.id = id;
>> this.name = name;
>> this.duration = duration;
>> this.ects = ects;
>> this.active = active;
>> this.description = description;
>> }
>>
>> public StudyProgram (StudyProgram clone) {
>> super ();
>> this.id = clone.id;
>> this.name = clone.name;
>> this.duration = clone.duration;
>> this.ects = clone.ects;
>> this.active = clone.active;
>> this.description = clone.description;
>> }
>>
>> public StudyProgram clone (StudyProgram clone) {
>> return new StudyProgram (clone);
>> }
>>
>> public Integer getId() {
>> return id;
>> }
>>
>> public String getID () {
>> return id.toString();
>> }
>>
>> public String getName() {
>> return name;
>> }
>>
>> public Integer getDuration() {
>> return duration;
>> }
>>
>> public Integer getEcts() {
>> return ects;
>> }
>>
>> public Boolean getActive() {
>> return active;
>> }
>>
>> public String getDescription() {
>> return description;
>> }
>>
>> public void setId(Integer id) {
>> this.id = id;
>> }
>>
>> public void setName(String name) {
>> this.name = name;
>> }
>>
>> public void setDuration(Integer duration) {
>> this.duration = duration;
>> }
>>
>> public void setEcts(Integer ects) {
>> this.ects = ects;
>> }
>>
>> public void setActive(Boolean active) {
>> this.active = active;
>> }
>>
>> public void setDescription(String description) {
>> this.description = description;
>> }
>> }
>>
>> ================================
>> bean2 (has bean1 as a property)
>> ================================
>>
>> package beans.department;
>>
>> import beans.studyProgram.StudyProgram;
>>
>> public class Department extends
>> org.apache.struts.validator.ValidatorActionForm {
>>
>> private static final long serialVersionUID = 4766571497570970495L;
>>
>> private Integer id;
>> private String name;
>> private Boolean active;
>> private String description;
>> private StudyProgram program;
>>
>> public Department() {
>> super();
>> }
>>
>> public Department (Integer id) {
>> this.id = id;
>> }
>> public Department(Integer id, String name, Boolean active, String
>> description, StudyProgram program) {
>> super();
>> this.id = id;
>> this.name = name;
>> this.active = active;
>> this.description = description;
>> this.program = program;
>> }
>>
>> public Department (Department clone) {
>> super ();
>> this.id = clone.id;
>> this.name = clone.name;
>> this.active = clone.active;
>> this.description = clone.description;
>> if(clone.hasProgram())
>> this.program = clone.program;
>> }
>>
>> public Department clone (Department clone) {
>> return new Department (clone);
>> }
>>
>>
>> public boolean hasProgram () {
>> return program!=null;
>> }
>>
>> public Integer getId() {
>> return id;
>> }
>>
>> public String getID() {
>> return id.toString();
>> }
>>
>> public String getName() {
>> return name;
>> }
>>
>> public Boolean getActive() {
>> return active;
>> }
>>
>> public String getDescription() {
>> return description;
>> }
>>
>> public StudyProgram getProgram() {
>> return program;
>> }
>>
>> public void setId(Integer id) {
>> this.id = id;
>> }
>>
>> public void setName(String name) {
>> this.name = name;
>> }
>>
>> public void setActive(Boolean active) {
>> this.active = active;
>> }
>>
>> public void setDescription(String description) {
>> this.description = description;
>> }
>>
>> public void setProgram (StudyProgram program) {
>> this.program = program;
>> }
>> }
>>
>> ==================================
>> struts config file
>> ==================================
>> <struts-config>
>> <form-beans>
>> <form-bean name="User" type="beans.user.User"
>>
>> />
>> <form-bean name="StudyProgram"
>> type="beans.studyProgram.StudyProgram"
>> />
>> <form-bean name="Department" type="beans.department.Department"
>>
>> />
>> .......
>> <action input="/view/editDepartment.jsp" name="Department" path="/SaveD"
>> scope="request" type="actions.department.SaveDAction">
>> <forward name="fail" path="/view/editDepartment.jsp"/>
>> </action>
>>
>> =================================
>> jsp page (just one part) no need to copy all
>> =================================
>>
>> <html:form action="/SaveD" method="POST">
>> <html:hidden property="program.id" value="<%=isNew?
>> program.getID() : department.getProgram().getID()%>"/>
>> <html:hidden property="id" value='<%=isNew? "" :
>> department.getID()%>'/>
>> ===============================
>> tomcat trace
>> ===============================
>> SEVERE: Servlet.service() for servlet action threw exception
>> java.lang.IllegalArgumentException: No bean specified
>> at
>> org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)
>> at
>> org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:937)
>> at
>> org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
>> at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
>> at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:473)
>> at
>> org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:818)
>> at
>> utils.controller.RequestProcessHandler.processPopulate(RequestProcessHandler.java:384)
>> at
>> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:194)
>> at
>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>> at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
>> at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>> at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>> at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>> at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>> at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>> at
>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
>> at
>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>> at java.lang.Thread.run(Unknown Source)
>> ===============================================================
>>
>> Laurie Harper wrote:
>>> auz wrote:
>>>> hope some1 can help me out, i have a Struts ActionFormBean who has a
>>>> complex
>>>> type as an attribute (also ActionFormBean), the problem is i dont know
>>>> how
>>>> to populate it, tryed everything. i presume i have to extend
>>>> RequestProcessor's populateProcess method or something like that, can
>>>> any1
>>>> help. NOTE i'm using struts 1.3.9. I have tryed all options for
>>>> property
>>>> name on page using struts tags ie (property="bean1.bean2.id" or
>>>> "bean2".
>>>> "bean2.id" ) and also made various setters for property bean1 but
>>>> nothing
>>>> gave any result every time i get beanUtils populate exception
>>>>
>>>> tnx
>>>>
>>>> i know this can be done, just dunno how, some code would also be
>>>> apritiated
>>> Ditto :-) Post the code you're using, the stack trace for the exception
>>> and any other relevant log output and perhaps someone can see where
>>> you're going wrong. This should work pretty easily.
>>>
>>> - Are both ActionFormBBean classes properly JavaBean compliant?
>>>
>>> - Do you have the appropriate getter/setter pairs on the 'outer' bean
>>> for the 'inner' one? (i.e. getBean2() / setBean2() methods)
>>>
>>> - how are you instantiating the inner bean? (statically? in bean1's
>>> constructor? in bean1's reset() method?)
>>>
>>> You could also try cranking log levels up to debug and see if you can
>>> spot a problem in the additional log messages.
>>>
>>> L.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/populating-ActionFormBean-s-tp15518640p15641637.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]