Announcement Announcement Module
Collapse
No announcement yet.
Binding controller methods to jsp buttons fails Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding controller methods to jsp buttons fails

    Hi,

    I wrote a table in jsp using <display:table> tag. I added a pagination support That throws an exception saying:

    No request handling method with name 'nextPage' in class [com.liav.adam.admin.spring.controller.AdDetailsCon troller]

    This is the table in the jsp
    HTML Code:
    <tr >    
                    <td colspan="3" align="center">    
                 <div style="height: 140px; width:100%; overflow: auto;">    
                   <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">    
       
                 <c:set var="listPageUrl" scope="page">    
                                    <c:url value="/AdDetails.htm"/>    
                 </c:set>          
                               
                       <display:table name="adSummary.inventoryList"     
                                      defaultsort="1"     
                                      id="inventoryListTable"     
                                      style="height: 45px; border:0px solid red; width:100%;"   
                                      excludedParams="*"     
                                                decorator="com.liav.adam.admin.decorator.AdDetailsDecorator"   
                                      sort="list"   
                                      requestURI="${listPageUrl}"   
                                      pagesize="3"   
                                      >    
                                          
                      <display:setProperty name="paging.banner.first">    
                              <span class="pagelinks">    
                                <input type="image" name="nextPage" src="images/next.jpg">    
                                <input type="hidden" name="nextPageURI" value="{3}"/>    
                              </span>    
                            </display:setProperty>    
       
                            <display:setProperty name="paging.banner.full">    
                              <span class="pagelinks">    
                                <input type="image" name="prevPage" src="images/prev.jpg">    
                                <input type="image" name="nextPage" src="images/next.jpg">     
                                <input type="hidden" name="prevPageURI" value="{2}"/>    
                                <input type="hidden" name="nextPageURI" value="{3}"/>    
                              </span>    
                            </display:setProperty>    
                                
                        <display:setProperty name="paging.banner.last">    
                              <span class="pagelinks">    
                                  <input type="image" name="prevPage" src="images/prev.jpg">    
                                  <input type="hidden" name="prevPageURI" value="{2}"/>    
                              </span>    
                            </display:setProperty>    
                                
                        <display:column property="name" style="width: 25%" title="Inventory Name" maxLength="15" sortable="false"/>    
                        <display:column property="page.site.name" style="width: 25%" maxLength="15" title="Site" sortable="fasle"/>    
                        <display:column property="page.name" style="width: 25%" title="Page" sortable="false"/>    
                    <display:column property="location.value"  style="width: 25%" title="Placement" sortable="false"/>                                    
                        </display:table>    
                        
                </table>    
              </div>    
       
            </td>                                                     
    </tr>
    This is the declared bean acting as the controller for the above jsp:

    HTML Code:
    <bean id="AdDetailsController" class="com.liav.adam.admin.spring.controller.AdDetailsController" scope="request">    
              <property name="methodNameResolver" ref="adDetailsPageActionResolver"/>    
            <property name="adFacade" ref="adFacade"/>    
              <property name="adminFacade" ref="adminFacade"/>    
            <property name="adSummary" ref="adSummary"/>      
            <property name="sessionForm" value="true" />    
            <property name="requireSession" value="true" />    
            <property name="commandName" value="adSummary"/>    
                <property name="commandClass" value="com.liav.adam.admin.spring.uiobj.AdSummary"/>    
            <property name="formView" value="AdDetails"/>    
            <property name="successView" value="AdDetails.htm"/>    
         </bean>    
             
         <bean id="adDetailsPageActionResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">    
           <property name="methodParamNames">    
             <list>    
               <value>prevPage</value>    
               <value>nextPage</value>    
             </list>    
           </property>    
       </bean>  
    And finaly, here is the controller with the problematic methods:

    Code:
    public class AdDetailsController extends AbstractSearchListController {    
    public AdDetailsController() {    
            super.setRequireSession(true);    
        }    
        private AdFacade adFacade;    
        private AdminFacade adminFacade;    
        private AdSummary adSummary;    
       
    @Override   
        protected Object formBackingObject(HttpServletRequest request) throws Exception {    
    ...    
        return (AdSummary) adSummary;    
    }    
       
    public ModelAndView nextPage (HttpServletRequest request,     
                                      HttpServletResponse response,     
                                      InventoryList commandObj,    
                                      BindException errors) {    
                
            return super.nextPage(request, response, commandObj, errors);    
        }     
            
    public ModelAndView prevPage (HttpServletRequest request,     
                                      HttpServletResponse response,     
                                      InventoryList commandObj,    
                                      BindException errors) {    
            return super.prevPage(request, response, commandObj, errors);    
        }
    Can you suggest why does the nextPage & prevPage aren't invoked when i press the paging buttons on the screen?

    Thanks.

  • #2
    First off all WHY is your controller a request scoped object, I would start by removing that, you shouldn't keep state in your controller.

    Next to that I suggest the reference guide as the methods you implemented don't qualify for request handling methods.

    Comment


    • #3
      Hi Marten,

      Regarding the method stamp: In the reference it says:

      public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpServletResponse [, Exception | AnyObject]);

      My method is:
      public ModelAndView nextPage (HttpServletRequest request, HttpServletResponse response,
      InventoryList commandObj,
      BindException errors)


      If i understand the documentation correctly - i need to omit my third parameter but then how would i pass the commandObj?

      Thanks.

      Comment


      • #4
        I suggest checking the reference guide again.

        [quote]
        // 'anyMeaningfulName' can be replaced by any method name
        public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpServletResponse [,HttpSession] [,AnyObject])
        [/code]

        You cannot pass in the BindExceptions, hence the method doesn't match, the 3rd attribute should be the session, the 4th your object.

        Comment


        • #5
          Hi Marten,

          I'm using Spring 2.0, not 2.5.
          My super method has this stamp:

          ModelAndView com.amdocs.adam.admin.spring.controller.AbstractSe archListController.
          nextPage(
          HttpServletRequest request,
          HttpServletResponse response,
          BaseList commandObj,
          BindException errors)

          Comment


          • #6
            Well that is also very clear isn't it.. You are only allowed to have 3 attributes NOT 4... As I already stated you cannot include the BindExceptions.

            Comment


            • #7
              So the following is legal?

              public ModelAndView nextPage (
              HttpServletRequest request,
              HttpServletResponse response,
              InventoryList commandObj) {
              System.out.println("liav");
              return super.nextPage(request, response, commandObj, null);
              }

              Comment


              • #8
                Please use [ code][/code ] tags...

                According to the docs that should be valid...

                Comment


                • #9
                  Hi Marten,

                  Thanks for your quick replies.

                  So my Controller method looks valid but i still can't invoke it, getting:

                  No request handling method with name 'nextPage' in class [com.amdocs.adam.admin.spring.controller.AdDetailsC ontroller]

                  My model is valid also?

                  Comment


                  • #10
                    The next problem is that you have 2 methods with the same name (super class method is same name) that messes things up also...

                    Comment


                    • #11
                      Well i changed my method's name to nextPageBtn & prevPageBtn & i still get:

                      No request handling method with name 'nextPageBtn' in class [com.amdocs.adam.admin.spring.controller.AdDetailsC ontroller]

                      JSP:
                      HTML Code:
                      <display:setProperty name="paging.banner.first">
                      											  <span class="pagelinks">
                      												<input type="image" name="nextPageBtn" src="images/next.jpg">
                      												<input type="hidden" name="nextPageURI" value="{3}"/>
                      											  </span>
                      											</display:setProperty>
                      					
                      											<display:setProperty name="paging.banner.full">
                      											  <span class="pagelinks">
                      											    <input type="image" name="prevPageBtn" src="images/prev.jpg">
                      											    <input type="image" name="nextPageBtn" src="images/next.jpg">
                      											    
                      											    <input type="hidden" name="prevPageURI" value="{2}"/>
                      											    <input type="hidden" name="nextPageURI" value="{3}"/>
                      											  </span>
                      											</display:setProperty>
                      											
                      						   					<display:setProperty name="paging.banner.last">
                      											  <span class="pagelinks">
                      												<input type="image" name="prevPageBtn" src="images/prev.jpg">
                      												<input type="hidden" name="prevPageURI" value="{2}"/>
                      											  </span>
                      											</display:setProperty>
                      Context File:
                      HTML Code:
                      	 <bean id="AdDetailsController" class="com.amdocs.adam.admin.spring.controller.AdDetailsController" scope="request">
                      	    <property name="methodNameResolver" ref="adDetailsPageActionResolver"/>
                         	   	<property name="adFacade" ref="adFacade"/>
                      	   	<property name="adminFacade" ref="adminFacade"/>
                        	   	<property name="adSummary" ref="adSummary"/>	
                         	   	<property name="sessionForm" value="true" />
                         	   	<property name="requireSession" value="true" />
                              <property name="commandName" value="adSummary"/>
                      		<property name="commandClass" value="com.amdocs.adam.admin.spring.uiobj.AdSummary"/>
                              <property name="formView" value="AdDetails"/>
                              <property name="successView" value="AdDetails.htm"/>
                      	 </bean>
                      	 
                      	 <bean id="adDetailsPageActionResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
                             <property name="methodParamNames">
                               <list>
                                 <value>prevPageBtn</value>
                                 <value>nextPageBtn</value>
                               </list>
                             </property>
                          </bean>
                      Controller:
                      Code:
                      public ModelAndView nextPageBtn (HttpServletRequest request,		  HttpServletResponse response,InventoryList commandObj ) {
                      	System.out.println("liav");
                      	return super.nextPage(request, response, commandObj, null);
                      }
                      Thanks.

                      Comment


                      • #12
                        Well the last thing I can think of is that your commandObject is of a different class then what you have specified in the method. You are using an InventoryList in your method where as your commandClass is specified as a AdSummary now that doesn't really match.

                        Next to that I also questioned WHY is it a request scoped bean, that shouldn't be the case because now you have a proxy which also screws up the detection logic.

                        Comment


                        • #13
                          But i send an InventoryList in the table which uses the paging:

                          HTML Code:
                          <display:table name="[B]adSummary.inventoryList[/B]" 
                            defaultsort="1" 
                            id="inventoryListTable" 
                            style="height: 45px; border:0px solid red; width:100%;"
                            excludedParams="*" 
                            decorator="com.amdocs.adam.admin.decorator.AdDetailsDecorator"
                            sort="list"
                            requestURI="${listPageUrl}"
                            pagesize="3"
                          >

                          Comment


                          • #14
                            But that doesn't mean it is your commandObject your command object is still your adSummary... You are only telling displaytag to use the inventoryList property of the adSummary object, no more - no less it doesn't suddenly change your command object.

                            Comment

                            Working...
                            X