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

Discussion in 'Java' started by Sébastien de Mapias, Nov 21, 2008.

  1. 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ébastien de Mapias, Nov 21, 2008
    #1
    1. Advertising

  2. 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.
     
    Sébastien de Mapias, Nov 21, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    4,439
  2. Mike P
    Replies:
    0
    Views:
    3,328
    Mike P
    Jun 19, 2006
  3. AlexWare
    Replies:
    2
    Views:
    774
    Paul Uiterlinden
    Oct 23, 2009
  4. Vikas Gholap
    Replies:
    2
    Views:
    288
    Brian Candler
    Jan 22, 2009
  5. Alexandre Jaquet

    question about variable procedure call

    Alexandre Jaquet, Feb 14, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    97
    Brian McCauley
    Feb 14, 2005
Loading...

Share This Page