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
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