Call a JSP procedure through 'onClick' with a js variable...

  • Thread starter Sébastien de Mapias
  • Start date
S

Sébastien de Mapias

Hi,
I'm using Struts 1.1. I'm displaying in a list in a JSP, with 4
columns
(an ID, a date, a type1 and a type2). A click on the 4rth element
in one row of this list triggers the appearance of a small pop-up
(just a div that I make visible), with 3 fields To, Cc, Bcc and a
hidden 'id' field, and 2 buttons: 'Send' or 'Cancel'.

I'd like to call the 'sendMail' defined in my struts-config.xml, with
one argument: the ID of the row clicked. I can't seem to be able
to have it working.

1/ in the 1rst case I do the following in the definition of my 'Send'
button:
~ <a href="#" onClick="sendMail.do?docId=document.getElementById
('id').value;">
~ <bean:message key="button.send" />
~ </a>

I get error "missing: in conditional expression" with
"sendMail.do?docId=document.getElementById('id').value;"

=> the 'document.getElementById('id').value' is not evaluated
(I should get "sendMail.do?docId=6489")

2/ in the 2nd case I've created a javascript function, and tried with
~ <a href="#" onClick="sendMail();">
~ <bean:message key="button.send" />
~ </a>

my sendMail() function being:
~ function sendMail() {
~ var docId = document.getElementById('id').value;
~ window.location.href='sendMail.do?docId='+docId;
~ }

I do get the correct URL in my address bar then:
~ http://localhost:9080/app-web/sendMail.do?docId=1618

but with the following error:
~ Error 500: Cannot find bean org.apache.struts.taglib.html.BEAN
~ in any scope

My question: is there a way to call my JSP-defined 'sendMail'
procedure with this 'docId' parameter ? (I only need to call this
procedure/action, don't need to open another window)

In advance, thanks...
Seb
 
S

Sébastien de Mapias

Forgot to add that the following can't work:
~ <a href="#" onClick="sendMail.do?docId=<bean:write name="xxx"
property="id"/>;">
~ <bean:message key="button.send" />
~ </a>
neither as I have no bean defined within this sub-div
displaying these To/Cc/Bcc fields and Send/Cancel buttons.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top