• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

two actions

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some links in my jsp page and each link should submit to different action. My actions inhert from DispatchAction.




When I click the link, it should execute the viewEditRequest method in
CreateRequestAction. My RequestForm.java also has the variables dispatchID and methodName ...abd corresponding get/set.

Its working when I directly submit the form by clicking a submit button with hidden fields but wont work when I have a link with different action.
May be because its cofused with the ActionForm...i dont know...
Help!!!
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you given the hidden submit buttons an id each and tried document.getElementById('button_id').click() to ensure you're submitting the correct button?
 
James Workmen
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I click the submit the button, it submits to the 'createSearchAction'
action and I am sending two hidden values along with it.

And in the Search Action it is executing the viewEditSearch method.

The problem is when I submit those values along the link, like,


it is not executing the method in Request action.
I do not the reason...
 
James Workmen
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I need is submit to a different action with different form bean in JSP.
 
John Smith
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you're trying to acheive and why you're doing that. If you put the values on the request you're not actually submitting the form and don't need an ActionForm class at all, you can put those values there dynamicaly with javascript from any normal text input field. So unless i've mis-understood what you're saying here you either don't need a form at all or you should have 2 hidden submit buttons (not links) that don't have request parameters which will submit to your dispatch action path. The whole idea of a dispatch action is to not have 2 action paths so having that setup the way you do with seperate forms isn't the right way to go about it.

I would make an action mapping to submit your form to which will internally select whichever method and redirect from there to whichever action you want to invoke. The idea of a dispath action is not to call two different actions but to call one action which will internally execute the approriate method as you have set up in the java class
 
James Workmen
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right. I am doing exactly like you mentioned. I have action mapping to submit the form which will internally select whichever method.

But what do you mean when you said 'redirect from there to whichever action you want to invoke.'


The scerario is I have a JSP...and I have couple of actions in the JSP like 'edit', 'save' and 'delete' buttons which I when I click, invoke the appropriate method in my action.

But I have at the top of the page have menus, (href links) which should take to another page, so I have given a value of another action with some required data,
like
<a href="/anotherAction?disoatchID=3...">Request</a>

So the whole page is like this...


The above submit button, submits to searchAction and is executing the viewSearch method in the action. But when I click on the above link it is submit to 'anotherAction' and execute the 'viewEditRequest' method in it.
It is throwing the following error

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic