Struts + DynaValidatorForm + ValueObject as form property ---JSP Access?

J

javaguy44

Was wondering if someone could help me out...

I have a DynaValidatorForm, and I'd like to use a custom ValueObject
as a form property.

In my struts-config.xml I have:
<form-bean name="testValObjDynaValidateForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="valobject" type="vo.ValueObjectProject"/>

where ValueObjectProject is a bean(shorthand)

package vo;
public ValueObjectProject {
private String projectId;
public getter + setter projectId

private String projectName;
public getter + setter projectName

public ValueObjectProject getValueObjectProject() {
return new ValueObjectProject();
}
public void setValueObjectProject(ValueObjectProject vob) {
this.projectId = vob.projectId;
this.projectName = vob.projectName;
}
}

In my Action class, I have the following:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
DynaValidatorForm f = (DynaValidatorForm) form; // *1*
ValueObjectProject vop = new ValueObjectProject("1", "Project
One");

f.set("valobject", vop); //same as form-property name=""
return mapping.findForward("success");
}

Now my question is how do I access the ValueObject in the JSP?

I've tried to access the bean like this so far in my jsp:
<html:text name="valobject" property="projectId"/>
<html:text name="valobject" property="projectName"/>

but this does not work, and I keep getting the error "cannot find bean
in any scope."

Can someone please help?
Thanks,
Javaguy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top