You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Mandar Velankar <ms...@cooltoad.com> on 2007/01/10 08:31:42 UTC

Problem in using DispatchAction

Hi,
I am using DispatchAction to call my own public method in class which
extends DispatchAction, but problem is my required method is not called ,
instead execute() method is called. Where is problem?
Here is my code 

JSP Page 
....
....
<html:form action="/addshade">
<html:hidden property="method" value="mymethod" />
<table width="100%" border="0" cellpadding=3 cellspacing=1 bgcolor="#FFFFFF"
class="TextContenttext" >
<tr bgcolor="#f0f0f0">
<td colspan="2"><html:errors/></td>
</tr>
....
....
</table>
</html:form>
....
....

Action mapping entry in struts-config.xml
....
....
<action-mappings>
<action path="/addshade" 
type="coreservlets.production.ShadeAction"
name="shadeFormBean"
scope="session" 
input="/pages/production/add_shade.jsp"
parameter="method"
>
<forward name="missing-value" 
path="/pages/production/add_shade.jsp"
redirect="true"/>
<forward name="success" 
path="/pages/production/saveshade.jsp"/>
</action>
</action-mappings>
....
....

Action Class

....
....
public class ShadeAction extends DispatchAction{

/** Creates a new instance of ShadeAction */
public ShadeAction() {
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
request.getSession().getServletContext().log("ShadeAction::Inside execute of
ShadeAction");
....
....
}
....
....
public ActionForward mymethod(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
request.getSession().getServletContext().log("ShadeAction::Inside mymethod
of ShadeAction");
return(mapping.findForward("success"));
}

}

But from logs , it shows execute() method is called.
Where is mistake? Thanks a lot.
wait for your replies.

Regards
Mandar Velankar 
-- 
View this message in context: http://www.nabble.com/Problem-in-using-DispatchAction-tf2951023.html#a8253237
Sent from the Struts - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Problem in using DispatchAction

Posted by Martin Cooper <ma...@apache.org>.
Please ask questions about using Struts on the Struts User mailing list.
This list is for discussion of the development of Struts itself.

--
Martin Cooper


On 1/9/07, Mandar Velankar <ms...@cooltoad.com> wrote:
>
>
> Hi,
> I am using DispatchAction to call my own public method in class which
> extends DispatchAction, but problem is my required method is not called ,
> instead execute() method is called. Where is problem?
> Here is my code
>
> JSP Page
> ....
> ....
> <html:form action="/addshade">
> <html:hidden property="method" value="mymethod" />
> <table width="100%" border="0" cellpadding=3 cellspacing=1
> bgcolor="#FFFFFF"
> class="TextContenttext" >
> <tr bgcolor="#f0f0f0">
> <td colspan="2"><html:errors/></td>
> </tr>
> ....
> ....
> </table>
> </html:form>
> ....
> ....
>
> Action mapping entry in struts-config.xml
> ....
> ....
> <action-mappings>
> <action path="/addshade"
> type="coreservlets.production.ShadeAction"
> name="shadeFormBean"
> scope="session"
> input="/pages/production/add_shade.jsp"
> parameter="method"
> >
> <forward name="missing-value"
> path="/pages/production/add_shade.jsp"
> redirect="true"/>
> <forward name="success"
> path="/pages/production/saveshade.jsp"/>
> </action>
> </action-mappings>
> ....
> ....
>
> Action Class
>
> ....
> ....
> public class ShadeAction extends DispatchAction{
>
> /** Creates a new instance of ShadeAction */
> public ShadeAction() {
> }
> public ActionForward execute(ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response)
> throws Exception {
> request.getSession().getServletContext().log("ShadeAction::Inside execute
> of
> ShadeAction");
> ....
> ....
> }
> ....
> ....
> public ActionForward mymethod(ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response)
> throws Exception {
> request.getSession().getServletContext().log("ShadeAction::Inside mymethod
> of ShadeAction");
> return(mapping.findForward("success"));
> }
>
> }
>
> But from logs , it shows execute() method is called.
> Where is mistake? Thanks a lot.
> wait for your replies.
>
> Regards
> Mandar Velankar
> --
> View this message in context:
> http://www.nabble.com/Problem-in-using-DispatchAction-tf2951023.html#a8253237
> Sent from the Struts - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>