aspose file tools*
The moose likes Struts and the fly likes How to go to particular method in Action class when i click the submit button in Jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to go to particular method in Action class when i click the submit button in Jsp?" Watch "How to go to particular method in Action class when i click the submit button in Jsp?" New topic
Author

How to go to particular method in Action class when i click the submit button in Jsp?

Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98
Hi,

In my jsp am having 3 submit buttons, If i click one submit button it should go to the particular method in the Action class and display the data that is hard coded data in the Action class. If i click second submit button it should go to that particular method in the Action class and display the data that is hard coded data in the Action class etc. How can i go to the particular method in Action class from the jsp when i click submit button? Please give me some suggestions..

Thanks,
Vidya
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Here JavaScript helps you using js identify which action has selected and call the respective action.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Sandy Chatterjee
Ranch Hand

Joined: Jun 27, 2012
Posts: 55

To deal with the above scenario struts1 provides two classes DispatchAction and LookupDispatchAction.
Refer to the below mentioned link for details(For DispatchAction):
Click Here
If you need any further explanation reply back.

Regards,
Sandy


Take up one idea. Make that one idea your life; dream of it; think of it; live on that idea. Let the brain, the body, muscles, nerves, every part of your body be full of that idea, and just leave every other idea alone. This is the way to success.
Sandy Chatterjee
Ranch Hand

Joined: Jun 27, 2012
Posts: 55

Its not a good practice to use javascript.
As javascript can be disabled in clients web browser.
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98

Actually am having a small doubt, we normally write <form action="someaction"> tag in the jsp..
That means after submitting the form it will go to the particular action which is specified in the "action" attribute.
Am i right? If so, in my newly created jsp am having 3 submit buttons. When creating each submit button ill write "onclick="some javascript function to go to particular action class".
Now on clicking each submit button it will go to particular action method that is specified in the onclick attribute..
Now my doubt is what should i write in the action attribute of form which containing 3 submit buttons?
Sandip Ram
Greenhorn

Joined: Jun 13, 2012
Posts: 4
Hi vidya,
Yes, your right and this is a not a small doubt also.
If you go through the documentation then may be you get your answer so easily.
So please once go to struts documentation and search struts predefined classes.
There are two classes that is DispatchAction and LookUpdispatchAction class which is help you to clear your doubt.

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to go to particular method in Action class when i click the submit button in Jsp?