Results 1 to 5 of 5

Thread: Multi Action controller problem

  1. #1

    Default Multi Action controller problem

    HI ,

    I have a page it supports multiple actions,so i am choosing MultiActionController to done this.I configured spring-servlet.xml with ParameterNameMethodResolver.In my JSP from javascript i am passing different actions and based on it i am invoking different methods of MultiActionController.In my application i am using Tuckey "UrlRewriteFilter."

    to process the any url to process the request,When i perform any action it does nothing.

    If any one already worked on this kind of issue,PLease help me.

    Thanks in Advance.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    Without seeing some configuration and logging (you might want to enable debug logging) it is quite hard to give pointers. I assume either a mapping issue or some problem after url rewriting.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Hi Marten,

    Thanks for your quick reply.

    Below is the code i am using,PLease look into this:

    Spring-servlet.xml
    ******************

    In handlemapping:

    <property name="mappings">
    <props>

    <prop key="/account/listGroups">accountController</prop>
    </props>
    </property>




    <bean id="accountController" class="com.esha.edt.web.AccountController">
    <property name="customerFacade" ref="customerFacade"/>
    <property name="personDao" ref="personDao"/>
    <property name="groupDao" ref="groupDao"/>
    <property name="methodNameResolver" ref="methodResolver"/>


    </bean>


    <bean id="methodResolver" class="org.springframework.web.servlet.mvc.multiac tion.ParameterMethodNameResolver">
    <property name="defaultMethodName" value="listGroups"/>
    <property name="paramName" value="methodToCall"/>
    </bean>

    ******Controller************

    public class AccountController extends MultiActionController {

    private CustomerFacade customerFacade;
    private PersonDao personDao;
    private GroupDao groupDao;
    private ParameterMethodNameResolver methodResolver;

    public GroupDao getGroupDao() {
    return groupDao;
    }

    public void setGroupDao(GroupDao groupDao) {
    this.groupDao = groupDao;
    }

    public PersonDao getPersonDao() {
    return personDao;
    }

    public void setPersonDao(PersonDao personDao) {
    this.personDao = personDao;
    }
    /**
    * Creates a new instance.
    */
    public AccountController() {
    System.out.println("in account controller");
    // Do nothing
    }

    /**
    * Sets the customer facade.
    *
    * @param customerFacade the customer facade
    */
    @Required
    public final void setCustomerFacade(final CustomerFacade customerFacade) {
    this.customerFacade = customerFacade;
    }



    public Map listGroups(

    HttpServletRequest request, HttpServletResponse response) {
    System.out.println("in listgroups");

    return model;
    }

    public void activate(HttpServletRequest request, HttpServletResponse response)
    {

    System.out.println("activate");


    }

    public void deactivate(HttpServletRequest request, HttpServletResponse response)
    {

    System.out.println("deactivate");


    }

    public ParameterMethodNameResolver getMethodResolver() {
    return methodResolver;
    }

    public void setMethodResolver(ParameterMethodNameResolver methodResolver) {
    this.methodResolver = methodResolver;
    }

    *************urlrewrite mappings*******

    <rule>
    <from>^/account/$</from>
    <to type="temporary-redirect">%{context-path}/account/listGroups</to>
    </rule>

  4. #4

    Default

    <form:form commandName="account" action="" >
    <input type="button" name="Disable" value="Disable" width="20px" onclick="javascript:setAction('deactivate');"/>


    <input type="button" name="Enable" value="Enable" width="20px" onclick='javascript:setAction("activate");'/>


    <input type="hidden" id="methodToCall" value=""/>

    </form:form>

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    Please use [ code][/code ] tags when posting code that way it remains readable what you post.

    What is your javascript function doing?

    Another question, I'm not that into url rewriting, is isn't a redirect destroying the original request and thus removing all parameters from the original request (as it is like issueing a new request).
    Last edited by Marten Deinum; Apr 11th, 2010 at 06:33 AM. Reason: Removed commont on methodNameResolver
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •