PDA

View Full Version : Can any one help me?-"Neither Errors instance nor plain target object..."


wallance
Apr 6th, 2006, 06:00 AM
I haved serached the solutions for this problem all through this forums, and also tried them, but it didn't work. Any one give me a help?
When I try to use "spring:bind" I got this error:
javax.servlet.jsp.JspTagException: Neither Errors instance nor plain target object for bean name 'role' available as request attribute

my JSP:

<form name="roleForm" method="post" action="">
<table width="33%" border="0">
<tr>
<td width="29%">Role Name</td>
<td colspan="3">
<spring:bind path="roleForm.role.roleName">
<input name="TBox_Name" type="text" id="TBox_Name">
</spring:bind>
</td>
</tr>

<tr>
<td width="29%">Role Auth</td>
<td colspan="3">
<spring:bind path="roleForm.role.roleAuth">
<input name="TBox_Name" type="text" id="TBox_Name">
</spring:bind>
</td>
</tr>
<!--
<tr>
<td>
Description
</td>
<td colspan="5">
<spring:bind path="role.RoleDesc">
<textarea name="textfield">
</textarea>
</spring:bind>
</td>
</tr>
-->
<tr>
<td colspan="3"><input name="Btn_Submit" type="submit" id="Btn_Submit2" value="submit">
<input name="Btn_Cancel" type="reset" id="Btn_Cancel3" value="cancel"></td>
<td width="42%" colspan="1">&nbsp;</td>
</tr>
</table>
</form>

my controller:
public class RoleFormController extends SimpleFormController {
private RoleManagerImpl roleManager;

public RoleManagerImpl getRoleManager() {
return roleManager;
}

public void setRoleManager(RoleManagerImpl roleManager) {
this.roleManager = roleManager;
}

public RoleFormController() {

System.out.println("*********In RoleFormController***************");
// need a session to hold the formBackingObject
//setSessionForm(true);
// initialize the form from the formBackingObject
//setBindOnNewForm(true);
setCommandClass(RoleForm.class);
setCommandName("roleForm");
}
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
Role role=new Role();
role.setRoleAuth("aaa");
role.setRoleName("admin");

RoleForm roleForm=new RoleForm();
roleForm.setRole(role);

return roleForm;
}
protected ModelAndView onSubmit(Object command,BindException errors)
throws ServletException {
RoleForm roleForm = (RoleForm) command;
// delegate the insert to the Business layer
getRoleManager().insertRole(roleForm.getRole());
return new ModelAndView(getSuccessView(),"roleForm",roleForm).addAllObjects(errors.getModel());
}
}
my config file:
<bean id="roleFormController"
class="org.hxmt.hcmp.control.RoleFormController">
<property name="roleManager" ref="roleManager"/>
<property name="formView" value="EditRole"/>
<property name="successView" value="success"/>
</bean>
And the class RoleFom is defined like this:
public class RoleForm {
private Role role;
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
}
Can any one help me? It is exigent..

Christian Dupuis
Apr 6th, 2006, 06:45 AM
Hi wallace,

I think the following snippet of your jsp is causing the problem:


<td>
Description
</td>
<td colspan="5">
<spring:bind path="role.RoleDesc">
<textarea name="textfield">
</textarea>
</spring:bind>
</td>
</tr>


In particular the line '<spring:bind path="role.RoleDesc">'. Did you try to put in
'<spring:bind path="roleForm.role.RoleDesc">'.

Cheers
Christian

P.S. I think you should have posted that question to the Web forum. But anyways...

wallance
Apr 6th, 2006, 08:27 AM
Hi wallace,

I think the following snippet of your jsp is causing the problem:


<td>
Description
</td>
<td colspan="5">
<spring:bind path="role.RoleDesc">
<textarea name="textfield">
</textarea>
</spring:bind>
</td>
</tr>


In particular the line '<spring:bind path="role.RoleDesc">'. Did you try to put in
'<spring:bind path="roleForm.role.RoleDesc">'.

Cheers
Christian

P.S. I think you should have posted that question to the Web forum. But anyways...


Hi Christian

You got the root casue! Thank you very much~