Announcement Announcement Module
Collapse
No announcement yet.
ModelMap <form:input - WITHOUT ANNOTATIONS - HELP!!! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ModelMap <form:input - WITHOUT ANNOTATIONS - HELP!!!

    I need solution without annotations:

    My controller
    Code:
    public class ProfilesController extends MultiActionController {
    ...
    	@Override
    	protected String getCommandName(Object command) {
    		return "commandName";
    	}
    ...
    	public ModelAndView create(HttpServletRequest request,
    			HttpServletResponse response) throws Exception {
    		List<Permission> permissions = permissionManager.getPermissionList();
    		ModelMap modelMap = new ModelMap();
    		modelMap.addAttribute(new Profile());
    		modelMap.addAttribute(permissions);
    		return new ModelAndView("profile", "commandName", modelMap);
    	}
    my jsp:
    Code:
    <form:form method="POST" action="add.htm" commandName="commandName">
    	<%@ include file="/WEB-INF/jsp/headerDetails.jsp"%>
    	<table width="736" border="0">
    		<tr>
    			<th class="styleHeader" colspan="2" scope="col"><spring:message
    				code="profile" /></th>
    			<th width="10" scope="col">&nbsp;</th>
    			<th class="styleHeader" width="700" scope="col"><spring:message
    				code="permissions" /></th>
    		</tr>
    		<tr>
    			<td><label><spring:message code="name" />*</label></td>
    			<td><form:input path="profile.name" size="32" maxlength="30" />
    			<br>
    			<form:errors path="profile.name" cssClass="styleErrorMessage" /></td>
    			<td>&nbsp;</td>
    
    		</tr>
    
    
    	</table>
    	<p>*) <spring:message code="fields required" /></p>
    </form:form>
    Result:
    Aug 19, 2009 9:45:20 PM org.springframework.web.servlet.tags.RequestContex tAwareTag doStartTag
    SEVERE: Invalid property 'profile' of bean class [org.springframework.ui.ModelMap]: Bean property 'profile' is not readable or has an invali
    d getter method: Does the return type of the getter match the parameter type of the setter?
    org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'profile' of bean class [org.springframework.ui.ModelMap]: Bean pro
    perty 'profile' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:540)
    at org.springframework.beans.BeanWrapperImpl.getNeste dBeanWrapper(BeanWrapperImpl.java:447)
    at org.springframework.beans.BeanWrapperImpl.getBeanW rapperForPropertyPath(BeanWrapperImpl.java:424)
    at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:530)
    at org.springframework.web.servlet.support.BindStatus .<init>(BindStatus.java:147)
    at org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.getBindStatus(AbstractData BoundFormElementTag.java:172)

    at org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.getPropertyPath(AbstractDa taBoundFormElementTag.java:19
    2)
    at org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.getName(AbstractDataBoundF ormElementTag.java:158)
    at org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.autogenerateId(AbstractDat aBoundFormElementTag.java:145
    )
    at org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.resolveId(AbstractDataBoun dFormElementTag.java:136)
    at org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.writeDefaultAttributes(Abs tractDataBoundFormElementTag.
    java:120)
    at org.springframework.web.servlet.tags.form.Abstract HtmlElementTag.writeDefaultAttributes(AbstractHtml ElementTag.java:379)
    at org.springframework.web.servlet.tags.form.InputTag .writeTagContent(InputTag.java:139)
    at org.springframework.web.servlet.tags.form.Abstract FormTag.doStartTagInternal(AbstractFormTag.java:90 )
    at org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag(RequestContextAwareTag.java:7 7)
    at org.apache.jsp.WEB_002dINF.jsp.profile_jsp._jspx_m eth_form_005finput_005f0(profile_jsp.java:500)
    at org.apache.jsp.WEB_002dINF.jsp.profile_jsp._jspSer vice(profile_jsp.java:173)
    at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:374)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.pro cessRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doF orward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.for ward(ApplicationDispatcher.java:302)
    at org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:236)
    at org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:257)
    at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1183)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:902)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:807)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:501)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
    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.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)

  • #2
    How often are you going to create the same thread? Twice a day????

    Next to that use code tags when posting stacktraces. I suggest you read the reference guide and really start to read the stacktrace.

    Basically you cannot use a Collection or Map as a command object directly.

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      How often are you going to create the same thread? Twice a day????

      Next to that use code tags when posting stacktraces. I suggest you read the reference guide and really start to read the stacktrace.

      Basically you cannot use a Collection or Map as a command object directly.
      I found the solution without annotation:
      controller:
      Code:
      public class ProfilesController extends MultiActionController {
      ...
      	@Override
      	protected String getCommandName(Object command) {
      		return "commandName";
      	}
      ...
      	public ModelAndView create(HttpServletRequest request,
      			HttpServletResponse response) throws Exception {
      		ModelAndView mav = new ModelAndView("profile", "commandName",
      				new Profile());
      		mav.addObject(permissionManager.getPermissionList());
      		return mav;
      	}
      my jsp:
      HTML Code:
      <form:form method="POST" action="add.htm" commandName="commandName">
      	<%@ include file="/WEB-INF/jsp/headerDetails.jsp"%>
      	<table width="736" border="0">
      		<tr>
      			<th class="styleHeader" colspan="2" scope="col"><spring:message
      				code="profile" /></th>
      			<th width="10" scope="col">&nbsp;</th>
      			<th class="styleHeader" width="700" scope="col"><spring:message
      				code="permissions" /></th>
      		</tr>
      		<tr>
      			<td><label><spring:message code="name" />*</label></td>
      			<td><form:input path="name" size="32" maxlength="30" /> <br>
      			<form:errors path="name" cssClass="styleErrorMessage" /></td>
      			<td>&nbsp;</td>
      			<td><form:checkbox path="permissions"
      				id="${permissionList[0].id}" label="${permissionList[0].name}"
      				value="${permissionList[0].id}" /></td>
      		</tr>
      		<c:forEach items="${permissionList}" var="permission" begin="1">
      			<tr>
      				<td>&nbsp;</td>
      				<td>&nbsp;</td>
      				<td>&nbsp;</td>
      				<td><form:checkbox path="permissions" id="${permission.id}"
      					label="${permission.name}" value="${permission.id}" /></td>
      			</tr>
      		</c:forEach>
      
      	</table>
      	<p>*) <spring:message code="fields required" /></p>
      </form:form>
      ...

      Comment


      • #4
        If you simply change your @Controller it also works instead of using the (to be) deprecated Controller hierarchy.

        Comment


        • #5
          Originally posted by Marten Deinum View Post
          If you simply change your @Controller it also works instead of using the (to be) deprecated Controller hierarchy.
          Can I use in one spring project at the same time controller via annotation (@Controller) and controller without annotation (e.g. MultiActionController) ?

          Comment

          Working...
          X