Advertisement

01.26.2007 at 10:47AM PST, ID: 22138399
[x]
Attachment Details

How to call Struts action from onclick event

Asked by brunoguimaraes in Java Programming Language

Tags: action, struts, call, onclick, how

Hi all,

I have a form with 2 buttons. One of them is of <html:submit> kind, and it calls the form action. I also have another button, a <html:button> one that is supposed to call a secondary action. This action will set some attributes in the page that will be needed by the main action.

So, my question is: how do I call the action from the <html:button>'s onclick event? I tried to use onclick="location.href='MyAction.do'". But when I do that, I cannot retrieve any data from the form. For example, in the secondary action I tried:

String key = form.getKey();

It always returns null, even if the field was filled.

If I change the <html:button> to <html:submit> and delete the other <html:submit>, and change the form action to the secondary action, it works. So I think the problem is the way I'm calling the secondary action.

Any tips?

Thanks in advance!Start Free Trial
 
 
[+][-]01.26.2007 at 10:52AM PST, ID: 18406532

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: action, struts, call, onclick, how
Sign Up Now!
Solution Provided By: CEHJ
Participating Experts: 1
Solution Grade: A
 
 
[+][-]01.26.2007 at 11:04AM PST, ID: 18406618

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.26.2007 at 11:06AM PST, ID: 18406633

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32