-
Apr 10th, 2010, 11:11 AM
#1
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.
-
Apr 11th, 2010, 03:44 AM
#2
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.
-
Apr 11th, 2010, 06:02 AM
#3
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>
-
Apr 11th, 2010, 06:07 AM
#4
<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>
-
Apr 11th, 2010, 06:24 AM
#5
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules