Announcement Announcement Module
Collapse
No announcement yet.
<spring:bind > again Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <spring:bind > again

    My error:

    javax.servlet.ServletException: Neither Errors instance nor plain target object for bean name 'releaseSearchList' available as request attribute

    I tried some of the posted questions in the forums. Everyone was saying that I should use a SimpleFormController with bind but I had much problems trying to get that to work.
    Thank you all who attempt to help me resolve my problem. My code is due in a week LMAO.

    config:
    Code:
       <bean id="releaseSearchController" class="com.att.ivr.drm.ui.release.ReleaseSearchController">
        <property name="commandName" value="releaseSearchList" />
        <property name="commandClass" value="com.xxx.xxx.drm.to.ReleaseTO" />
        <property name="commandView"><value>release/release-search</value></property>  
        <property name="userFindService" ref="userFindService" />
        <property name="releaseFindService" ref="releaseFindService" />
      </bean>

    jsp:
    Code:
     
      <dt><label for="releaseName">Release Name:</label></dt>
      <dd><spring:bind path="releaseSearchList.releaseName">
               <input name="releaseName" type="text" maxlength="10" value="<c:out value="${status.value}"/>" />
          </spring:bind>
      </dd>
    controller:
    Code:
    public class ReleaseSearchController extends AbstractCommandController { 
    ...
    	protected ModelAndView handle(HttpServletRequest request,
    			HttpServletResponse response, Object command, BindException errors)
    			throws Exception {
    
    Map model = new HashMap();
    		
    if (request.getMethod().equalsIgnoreCase("POST")) {
    			ReleaseTO myTO = (ReleaseTO) command;
    			Calendar from = Calendar.getInstance();
    			Calendar to = Calendar.getInstance();
    			
    			if (myTO.getFromDate() != null) {			
    				from.setTime(myTO.getFromDate());
    			} else
    				from = null;
    			if (myTO.getToDate() != null) {			
    				to.setTime(myTO.getToDate());
    			} else
    				to = null;
    	
    			model.put(ModelConstants.RELEASE, reader.findByReleaseAndComponentAttributes(myTO.getReleaseName(),
    							from, to, myTO.getSelectedReleaseStatus(), 
    							myTO.getComponentID(), 
    							myTO.getSelectedComponentOwner()));
    		}
    		 
    		
            ArrayList status= new ArrayList();
    
            model.put(ModelConstants.USERS, status); 
            Collection users = userFind.findByRole(User.DATA_COORDINATOR);
            
            model.put("users",users);
            model.put("releaseStatus",Release.listStatuses());
        
           ModelAndView mav = new ModelAndView(commandView, ModelConstants.MODEL, model);
           
           mav.addObject("errors", errors.getModel());
           
           return mav;
    Thank you very much

  • #2
    You need to have the object named "releaseSearchList" in your page context BEFORE you call the handle( ... ) method of your controller.

    As you pointed out, the other people in the forum were correct in stating that you should use an SimpleFormController (there are alternatives, but thats the best option).

    Instead of populating your model in your handle( ... ) method (this model will be used in the page AFTER a POST has been submitted to your controller) use either the referenceData( ... ) or the formBackingObject( ... ) method to populate the page context with your model BEFORE displaying the form page. Example:
    Code:
    protected Object formBackingObject(HttpServletRequest request) 
    throws Exception {
      return new Release();
    }
    cheers, toby

    Comment

    Working...
    X