This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes need regarding DispatchAction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "need regarding DispatchAction" Watch "need regarding DispatchAction" New topic
Author

need regarding DispatchAction

lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
hi there... m using multiple submit buttons...
now here to recognize method i use a hidden variable named "function"

now i m giving here the code i used in JSP

"<"html:hidden property="function"/>
"<"html:submit styleClass="BUTTON" property="editsubmit" onklick="http://localhost:8080/user/user.do?function=edit">
"<"bean:message key="button.edit"/>
"<"/html:submit>"<"/td>


and i have used
parameter="function" in action tag of struts-config.


other then this i m extendign DispatchAction in my Action class
and through its execute() method i m calling super.execute();
now at his point i m getting following error
java.lang.NoSuchMethodException: Action[/user] does not contain specified method (check logs)


other then this when i debug i get function=""
in my variable window of debug perspective...
so it means that value of function doesnt pass...
hopeing to get a solution
thanx in advance...
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
HI Lubna

First clear with concept then start proceeding

Whenever you are extending DispatchAction in your Action class, then u should have a function in your Action class with value of the property your are setting as a parameter in the action tag in struts-config.In this case, property name is function and value for that property is edit,so u must have a method by name edit in your Action class

Hope this Helps
[ May 11, 2006: Message edited by: vidya sagar ]
sushil bharwani
Greenhorn

Joined: Mar 02, 2006
Posts: 26
Ur concept of using Dispatch Action is not clear
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
Hi sushil

If you are new to Dispatch Action,Then my explanation 100% doesnot make sense, i just added points to lubna to make him/her little bit clear with concept of Dispatch Action
sushil bharwani
Greenhorn

Joined: Mar 02, 2006
Posts: 26
well vidya sagar i am not here to tell u how much experience i have in handling struts development but i have send a personal mail to him/her with examples and all, explaining everything. As i am not interested in typing to much on Blogs I would just say

Well Keep Breathing Java and just dont fight on Blogs

Sushil
lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
hello guys....
m not having any problem in using DispatchAction its working fine
i just have problem that my hidden variable
function doesnt get assigned dynamically... so please look at the code that i have written in first message n do let me know if u guys have any solution...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You need to remove the onclick attribute from your <html:submit> button. It's useless, and isn't executing. An onklick event must contain JavaScript code, not a URL. If this is the only button on the page, change your <html:hidden tag to:

<html:hidden property="function" value="edit" />

and submit the form normally. Your dispatch action will pick up the value of the function as being "edit" and forward to the appropriate method.

If you have more than one button on the form, leave the <html:hidden property="function" />. Then change the <html:submit> tag to a <html:button> tag. In this tag, specify: onklick="this.form.function.value='edit';this.form.submit();" For another button you'd set the function value to 'add' or whatever else.
[ May 11, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
hi merrill thanx for ur help but the problem is it is yet not taking the value...
i thought as i m using "function" as variable name that might b the cause of problem so i changed it to methodToCall now this.form is not working here it doesnt generate any process on using "this" so i tried with onklick="document.form.methodToCall.value='edit';"
but for this i m getting error that
document.form.methodToCall is null or not an object...
do u have any idea wat can be the problem or is there any other way to do it...
ya let me tell u that i tried to call a function also in which i can assing value to this variable but that is also not working...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The above should work if you haven't made any mistakes in your JavaScript syntax. Since this is giving you problems, though, you might try an entirely different approach.

Instead of having a hidden field, make the property that controls the dispatch the button property, and instead of using DispatchAction, use LookupDispatchAction. This link explains how to do it.
lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
hi merrill using lookupdispatchaction gives me following error...
not getting solved... n ya really thanx... all this things let me know more about struts...


java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:329)
at org.apache.jasper.runtime.PageContextImpl.findAttribute(PageContextImpl.java:308)
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:889)
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:931)
at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:232)
at org.apache.jsp.UserInfo_jsp._jspService(UserInfo_jsp.java:353)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
at java.lang.Thread.run(Thread.java:536)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Did you add a getKeyMethodMap() method to your class? If not, this may be the problem. Carefully read the link I gave you, and you will understand how it works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need regarding DispatchAction