#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24

    Neither BindingResult nor plain target object for bean name 'command'


    Hi have the this excpetion, seems my object cannot be found/bound to my form

    Stack Trace

    Code:
    SEVERE: Servlet.service() for servlet debugjsp threw exception
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
    	at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:172)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:192)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:158)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:145)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:136)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:120)
    	at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:379)
    	at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:139)
    	at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:90)
    	at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
    	at org.apache.jsp.jsp.PostProfileForm_jsp._jspx_meth_form_005finput_005f0(PostProfileForm_jsp.java:327)
    	at org.apache.jsp.jsp.PostProfileForm_jsp._jspx_meth_form_005fform_005f0(PostProfileForm_jsp.java:125)
    	at org.apache.jsp.jsp.PostProfileForm_jsp._jspService(PostProfileForm_jsp.java:78)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    	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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
    	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:240)
    	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:258)
    	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1174)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:901)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    	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(Thread.java:595)
    2008/11/07 10:27:25 org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet action threw exception
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
    	at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:172)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:192)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:158)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:145)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:136)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:120)
    	at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:379)
    	at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:139)
    	at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:90)
    	at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
    	at org.apache.jsp.jsp.PostProfileForm_jsp._jspx_meth_form_005finput_005f0(PostProfileForm_jsp.java:327)
    	at org.apache.jsp.jsp.PostProfileForm_jsp._jspx_meth_form_005fform_005f0(PostProfileForm_jsp.java:125)
    	at org.apache.jsp.jsp.PostProfileForm_jsp._jspService(PostProfileForm_jsp.java:78)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    	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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
    	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:240)
    	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:258)
    	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1174)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:901)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    	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(Thread.java:595)
    JSP
    Code:
    <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    
    <html>
    <head>
    <title>
    Object Form
    </title>
    </head>
    
    <body bgcolor="#ffffff">	
    <form:form method="post">	
    <table border="1">	      
    <tr>
      <td>ProfileId</td>
      <td>
    	<select name="profileId">
    		<c:forEach var="postProfile" items="${postProfileList}">
    		<option value="<c:out value="${postProfile.profileId}" />">
    			IDNO<c:out value="${postProfile.profileId}" />
    		</option>
    		</c:forEach>
    	</select>
      </td>				
    </tr>			 	
    <tr>
    	<td>PostProfilestatus</td>
    	<td>
    		<form:input path="postProfilestatus" />
    	</td>
    </tr>
    <tr>
    	<td>Musterings</td>
    	<td>
    		<form:input path="musterings" />
    	</td>
    </tr>	      		
    <tr>
    	<td>Ranks</td> 
    	<td>
    		<form:input path="ranks"/>
    	</td>
    </tr>	  	    		
    <tr>
    	<td>UnitCode</td> 
    	<td>
    		<form:input path="unitCode"/>
    	</td>
    </tr>	  	    
    <tr>
    	<td>Statusreason</td>   
    	<td>
    		<form:input path="statusreason"/>
    	</td>
    </tr>		
    <tr>
    	<td>CrtDat</td>
    	<td>
    		<form:input path="rtDat"/>
    	</td>
    </tr>			
    <tr>
    	<td>CrtId</td>
    	<td>
    		<form:input path="crtId"/>
    	</td>
    </tr>			
    <tr>
    	<td>ChgDat</td>
    	<td>
    		<form:input path="chgDat"/>
    	</td>
    </tr>			
    <tr>
    	<td>ChgId</td>
    	<td>
    		<form:input path="chgId"/>
    	</td>
    </tr>			      
    <tr>
    	<td><input type="submit" name="delete" value="Delete"/></td>
    	<td><input type="submit" name="update" value="Update"/></td>
    </tr>				
    <tr>
    	<td colspan="2"><input type="submit" name="add" value="+ Add +"/></td>
    </tr>		      
    </table>    	
    </form:form>
    </body>
    </html>
    Controller class

    Code:
    package com.jobpost.controller;
    
    import java.util.Map;
    import java.util.List;
    import java.util.HashMap;
    
    import com.jobpost.postprofile.*;
    import com.jobpost.service.PostProfileService;
    
    import org.apache.commons.logging.*;
    import org.springframework.web.servlet.*;
    import org.springframework.web.servlet.mvc.*;
    import org.springframework.web.servlet.view.*;
    import javax.servlet.http.*;
    import javax.servlet.ServletException;
    import org.springframework.validation.BindException;
    
    public class PostProfileFormController extends SimpleFormController {
    
        protected final Log logger = LogFactory.getLog(getClass());
        private PostProfileService pps;
    
        public PostProfileService getpps() {
            return pps;
        }
    
        public void setpps(PostProfileService pps) {
            this.pps = pps;
        }
    
        public ModelAndView onSubmit(HttpServletRequest request,
                                     HttpServletResponse response, Object cmd,
                                     BindException errors) throws Exception {
            logger.debug(
                    "Entering PostProfileFormController handleRequest method ....");
            PostProfiles postProfiles = (PostProfiles) cmd;
            if (null != request.getParameter("delete")) {
                System.out.println("[Delete] button pressed ... ");
                pps.removePostProfiles(postProfiles);
            } else if (null != request.getParameter("update")) {
                pps.updatePostProfiles(postProfiles);
                System.out.println("[Update] button pressed ... ");
            } else if (null != request.getParameter("add")) {
                pps.insertPostProfiles(postProfiles);
                System.out.println("[Add] button pressed ... ");
            }
            return new ModelAndView(new RedirectView(getSuccessView()));
        }
        
    	protected Map<String, List<PostProfiles>> referenceData(HttpServletRequest request) throws ServletException {
    		List<PostProfiles> pplist = pps.getAllPostProfiles();
    		Map<String, List<PostProfiles>>  model = new HashMap<String, List<PostProfiles>>();
    		model.put("postProfileList", pplist);
    		
    		/*ModelAndView mav = new ModelAndView();		
    		mav.addObject("postprofiles", pplist);
    		*/
    		
    		return model;
    	}
    
    	protected Object formBackingObject(HttpServletRequest request) throws
                ServletException {
    		
    		String id = request.getParameter("id");
    		
            if (null != id && !id.equals("")) {
                return pps.findPostProfilesById(Long.parseLong(id));
            }
            return new PostProfiles();
        }
    }
    action-servlet.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    
      <!-- Fixed properties -->
      
      <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
        <property name="prefix"><value>/jsp/</value></property>
        <property name="suffix"><value>.jsp</value></property>
      </bean>
       
      <!-- Custom controller objects -->
      
      <bean id="ppController" class="com.jobpost.controller.PostProfileController">
        <property name="postProfileService"><ref bean="postProfileService"/> </property>
      </bean>
    
      <bean id="ppFormController" class="com.jobpost.controller.PostProfileFormController">
        <property name="sessionForm"><value>true</value></property>
    	<property name="commandName"><value>postprofiles</value></property>
        <property name="commandClass"><value>com.jobpost.postprofile.PostProfiles</value></property>
        <property name="formView"><value>PostProfileForm</value></property> <!-- Interesting, you cannot add the suffix here, it will append the .jsp -->
        <property name="successView"><value>index.html</value></property> <!-- you MUST add the suffix here, otherwise it won't append the suffix itself -->
        <property name="pps"><ref bean="postProfileService"/></property>
      </bean>
    
      <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
          <props>
            <prop key="/index.html">ppController</prop>
            <!-- <prop key="/refresh.html">ppFormController</prop> -->        
            <prop key="/PostProfileForm.html">ppFormController</prop>
          </props>
        </property>
      </bean>
    
    </beans>
    Please assist?
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2007
    Location
    in the ether
    Posts
    983
    Rep Power
    154
    A bit rusty with Java but I think you have to set a request scoped attribute 'command' to hold the data object. This should do it I think:
    Code:
    ModelAndView mav = new ModelAndView();	
    mav.addObject("command", commandObjectOrSomethingHere);
    The above is my wild guess just from the error message.

    Comments on this post

    • Yawmark agrees : On target, but it's best practice not to use the default command name.
  4. #3
  5. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5054
    According to your bean factory configuration, your form backing object is named "postprofiles," but you don't specify the correct command name (or any name) in your <form:form> tag (and you should). See appendix section "E.5. The form tag" of the Spring 2.5 reference manual for more information on the spring-form.tld.

    ~
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24
    Originally Posted by Yawmark
    According to your bean factory configuration, your form backing object is named "postprofiles," but you don't specify the correct command name (or any name) in your <form:form> tag (and you should). See appendix section "E.5. The form tag" of the Spring 2.5 reference manual for more information on the spring-form.tld.

    ~
    Did it here ..

    Code:
    <bean id="ppFormController" class="com.jobpost.controller.PostProfileFormController">
        <property name="sessionForm"><value>true</value></property>
    	<property name="commandName"><value>postprofiles</value></property>
        <property name="commandClass"><value>com.jobpost.postprofile.PostProfiles</value></property>
    Actually i removed it from xml file and did this
    Code:
    <form:form commandName="postprofiles">
    Got the same error ... Does method = "post" matter BTW?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24
    Originally Posted by JavaNinja
    A bit rusty with Java but I think you have to set a request scoped attribute 'command' to hold the data object. This should do it I think:
    Code:
    ModelAndView mav = new ModelAndView();	
    mav.addObject("command", commandObjectOrSomethingHere);
    The above is my wild guess just from the error message.
    Hey Ninja i already did that

    Code:
        public ModelAndView onSubmit(HttpServletRequest request,
                                     HttpServletResponse response, Object cmd,
                                     BindException errors) throws Exception {
            logger.debug(
                    "Entering PostProfileFormController handleRequest method ....");
            PostProfiles postProfiles = (PostProfiles) cmd;
    				
            if (null != request.getParameter("delete")) {
                System.out.println("[Delete] button pressed ... ");
                pps.removePostProfiles(postProfiles);
    			return new ModelAndView(new RedirectView(getSuccessView()));			
            } else if (null != request.getParameter("update")) {
                pps.updatePostProfiles(postProfiles);
                System.out.println("[Update] button pressed ... ");
    			return new ModelAndView(new RedirectView(getSuccessView()));
            } else if (null != request.getParameter("add")) {
                pps.insertPostProfiles(postProfiles);
                System.out.println("[Add] button pressed ... ");
    			return new ModelAndView(new RedirectView(getSuccessView()));
            }
    		
    		ModelAndView mav = new ModelAndView();
    		mav.addObject("postprofiles", postProfiles);
    		
    		return mav;
        }
    No luck
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24
    A question, where does formBackingObject return the object to? Is it the sessionForm? does the JSP form fetch data from the session put by formBackingObject... And referenceData() returns Map, where exactly is this returned, directly to the Form or the formSession?
  12. #7
  13. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5054
    Originally Posted by devsonx7
    Did it here ..
    Right, you need that.

    Actually i removed it from xml file
    No! You define the command name in the configuration file AND specify the command name in the form tag. Or don't define the command name in the configuration file AND don't specify the command name in the form tag. Preferably the first option, but either way, it's all or nothing.

    Does method = "post" matter BTW?
    No. It's POST by default.

    Hey Ninja i already did that ... No luck
    Don't guess! Take the time to understand what's actually going on. The P-PAM* method of coding only results in confusion.

    * Projectile-Partition Adhesion Methodology (P-PAM); you know, throwing code up against the wall to see if it sticks.

    ~
    Last edited by Yawmark; November 7th, 2008 at 12:18 PM.
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  14. #8
  15. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5054
    Originally Posted by devsonx7
    A question, where does formBackingObject return the object to?
    It's bound to the request.


    does the JSP form fetch data from the session put by formBackingObject...
    It can, but the formBackingObject wouldn't typically put data in the session.

    And referenceData() returns Map, where exactly is this returned, directly to the Form or the formSession?
    It's added to the model. It will be very useful for you to familiarize yourself with the lifecycle of an AbstractFormController before attempting to go any farther.

    ~
    Last edited by Yawmark; November 7th, 2008 at 12:15 PM.
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24
    Originally Posted by Yawmark
    It's bound to the request.



    It can, but the formBackingObject wouldn't typically put data in the session.


    It's added to the model. It will be very useful for you to familiarize yourself with the lifecycle of an AbstractFormController before attempting to go any farther.

    ~
    Thanx Yawmark, what time is it there? Its almost 9pm here on a Friday .. So am gonna go party and return to this on Monday! You really are very helpfull ...
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24
    Originally Posted by Yawmark
    It's bound to the request.



    It can, but the formBackingObject wouldn't typically put data in the session.


    It's added to the model. It will be very useful for you to familiarize yourself with the lifecycle of an AbstractFormController before attempting to go any farther.

    ~
    Hi, i'm trying to update the form based on the drop down list. If the user select a different ID from the drop-down and and press reload button, the form should reload with object (Model) of that ID

    Here's my function ...

    Code:
    protected Object formBackingObject(HttpServletRequest request) throws
    		ServletException {
    	
    	/**
    	 * Read from the profileID field parameter
    	 */
    	
    	String id = request.getParameter("profileId");		
    	if ( id != null && !id.equals("") && isFormSubmission(request))	
    	{
    		return pps.findPostProfilesById(Long.parseLong(id));			
    		
    	}	
    	
    	/**
    	 * Read from the URL parameter
    	 */
    	
    	String pid = request.getParameter("id");
    	//logger.debug("** PID is :"+pid+" **");
    	if (null != pid && !pid.equals("")) {
    		return pps.findPostProfilesById(Long.parseLong(pid));
    	}
    	
    	return new PostProfiles();
    }
    as you can see there's two IDs one from URL (pid) and the other from the dropdown (id) ... This doesn't seem to work ... i used log4j to check if the first if statement is executed, and yes it does execute but the form doesn't populate. On the log4j logger i noticed there an error (but no exception thrown)
    which states ... binding errors: 2, but no further info ???[EDIT] I think this error is coming from processFormSubmission method[/EDIT]

    Your help is always appreciated
  20. #11
  21. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5054
    This doesn't seem to work ...
    Too much partying, perhaps. Have a closer look at the workflow described in the AbstractFormController API.

    used log4j to check if the first if statement is executed
    Not in the code sample you provided.

    ~
    Last edited by Yawmark; November 10th, 2008 at 09:36 AM.
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24
    Originally Posted by Yawmark
    Too much partying, perhaps. Have a closer look at the workflow described in the AbstractFormController API.


    Not in the code sample you provided.

    ~
    I read through AbstractController but its only usefull if you not expecting form POSTs, most probably just views ... Its rather a simpler way of controlling ModelViews but cant' call referenceData and formBackingObject, neither onSubmit i think ... unless i did party too much
    [edit]
    let me rephrase ... It uses HandleRequestIntenal to manage/return ModelAndView ... well i guess this does referto POST/GET forms, but limited maybe ...
    [/edit]
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24
    Originally Posted by devsonx7
    I read through AbstractController but its only usefull if you not expecting form POSTs, most probably just views ... Its rather a simpler way of controlling ModelViews but cant' call referenceData and formBackingObject, neither onSubmit i think ... unless i did party too much
    [edit]
    let me rephrase ... It uses HandleRequestIntenal to manage/return ModelAndView ... well i guess this does referto POST/GET forms, but limited maybe ...
    [/edit]
    Sorry, i think i should be read AbstractFormController not AbstractController
  26. #14
  27. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5054
    Sorry, i think i should be read AbstractFormController not AbstractController
    Right, AbstractFormController is the class I mentioned in reply #11. Way too much partying...

    ~
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    213
    Rep Power
    24
    Originally Posted by Yawmark
    Right, AbstractFormController is the class I mentioned in reply #11. Way too much partying...

    ~
    Still reading but not getting where i wud like to really .. Wondering though if this property may come in handy
    1.
    Code:
    <property name="bindOnNewForm" value="true" />
    2.
    Secondly, notice the referenceData method is different to the SimpleFormObject that you can receive the command object as a parameter

    If both of these will help, then the next step is to figure how do i override referenceData ... Well, if i'm completely on the wrong direction ... tough!

IMN logo majestic logo threadwatch logo seochat tools logo