Multiple submit buttons in a jsp form?

I've been doing some research and found out that multiple buttons in a JSP form are possible by two ways:
- We can obtain the value of the submit button to know which one was clicked in the parameters of the request using the name of the buttons (which should be the same for all the submit buttons).
- We can change the submit destination using Javascript (Horrible solution since I want my web site to be safe to be used even if Javascript isn't active in clients browsers. I will use it of course since we can do amazing things with it but I want my website to be able to work without it also)
WHAT annoys me is the fact that the value of a submit button is also his text, so if I change the text of the submit button, I will always have to check the servlet to do the corresponding change.
Is there a third choice to be able to use multiple buttons?
Olivier Voutat

It seem rather convoluted at first but it's really good. I've not worked with JSF so I've no idea how that compares but from what I know, Craig McClanahan, who came up with Struts, worked on JSF also, so I guess it could only improve on Struts.
EDIT: Here's a search result on Google'ing his name: http://www.theserverside.com/news/thread.tss?thread_id=29068
But like I said, you don't have to use Struts ( which only uses standard JSP/ Servlets stuff anyway ), you simply use one of the ideas from it.
For example; you have a properties file, say "/WEB-INF/properties/myProps.properties" with these entries:
#USERS MODULE
users.button.save=Save User
users.button.search=Search User By Name
users.button.delete=Delete UserThis would be a key: users.button.save to the value Save User
Now, in your JSP, you use JSTL <fmt> tags:
<fmt:setBundle basename="properties.myProps"/>
//set the resource bundle you want to use
//and create buttons with the proper values
<input name="myButton" type="submit"><fmt:message key="users.button.save"/></input>
<input name="myButton" type="submit"><fmt:message key="users.button.search"/></input>This would create buttons with text "Save User" and "Search User By Name" respectively
Now, finally, in your servlet:
//create a map of the properties,
//possibly on app startup using a ServletContextListener
//and put it in the servlet context for access everywhere
HashMap myProps = (HashMap)getServletContext.getAttribute("myPropertiesMap");
String buttonClicked = request.getParameter("myButton");
if ( buttonClicked.equals((String)myProps.get("users.button.save")) )
//perform save action
else if ( buttonClicked.equals((String)myProps.get("users.button.search")) )
//perform search action
//etcYou'll obviously want to optimize this. Perhaps make a method that handles the comparison so you can have neater if conditions. But you get the idea, right?
Edited by: nogoodatcoding on Oct 4, 2007 8:12 PM

Similar Messages

  • Can I have multiple submit buttons on the same form?

    Hi!
    I'm creating a web page that allows the user to build a mail filter, and I would like to have to submit buttons, one to add more fields to the filter and another one to save the filter... I could insert the two buttons on the, but I don't know how to distinguish them while doing the process of the form on a jsp page. Any ideas?

    You can create additional submit buttons using Javascript buttons:
    <input type='button' value='Add Fields'
    onClick='this.form.action="/servlet/AddFields";this.form.submit()' />
    <input type='button' value='Save Filter'
    onClick='this.form.action="/servlet/SaveFilter";this.form.submit()' />
    The value of "onClick" is a block of Javascript, so you can all a function to validate the form before submitting, etc.
    Mike W.

  • Multiple submit button on a single form

    hi all,
    My current system have 1 submit button with single form. This submit button will call file_content.upload.
    htp.p('function on_submit() {');
    htp.p('     ...the rest of my code here..');
    htp.p('     document.forms[0].submit();');
    htp.p('     return true;');
    htp.p('}');
    htp.p('<form enctype="multipart/form-data" method="post" action="file_content.upload">');
    htp.p('     ...the rest of my code here..');
    htp.p('<input type="button" id="btn_Submit" value="Submit" onclick="on_submit()"></form>');
    My question is, i want to enhance this by adding additional 1 submit button with value "Save". But this new "Save" button will call/trigger different file. This new button will call file_content.update. How to accomplish this and how to differentiate these 2 button?
    htp.p('<input type="button" id="btn_Submit" value="Submit" onclick="on_submit()"> 
    <input type="button" id="btn_Save" value="Save"></form>');
    Appreciate any help from you guys. Thanks
    Edited by: morezack on Jul 20, 2011 8:21 PM
    Edited by: morezack on Jul 20, 2011 8:29 PM

    PLEASE IGNORE THIS THREAD. ACCIDENTLY SUBMIT IT. I WANT TO DELETE THIS BUT CANNOT

  • Multiple submit button on the same form

    Hi,
    I have created a PL/SQL procedure which generates a HTML form using htp and below is part of the code.
    Create or Replace PROCEDURE OBM_PROCEDURE
    htp.formOpen(OWA_UTIL.GET_OWA_SERVICE_PATH || 'insert_obm');
    htp.formSubmit(cvalue=> 'Insert');
    This creates the form and clicking Insert button calls the other procedure (insert_obm).. works fine.
    I could create other buttons like "Query" "Update" "Delete" on the same form using following.
    htp.print ('<INPUT TYPE=submit VALUE="Query"> ');
    But all the buttons call the same form (insert_obm) since they are in the same form. How do I make the buttons call different procedure?
    Thanks,
    Jee

    Hi,
    The best way to do is call a single procedure as you are doing on form submit and check which form submit was clicked ,say based on the submit value and then do the processing accordingly i.e whether it is INSERT or DELETE.
    Hope this helps,
    Thanks,
    Anu

  • Multiple submit button on jsp

    Hello,
    Can I have multiple submit button on single JSP page?
    if its possible then tell me how?
    And how to call multiple functions in JSP?
    reply me urgent

    I think this code will help you
    <html>
         <head></head>
         <script>
              function submitForm(clickedButton){
                   if(clickedButton.name =="button1"){
                        alert("button1");
                        document.multipleSubmitDemoForm.action="linkToJSPWhenFirstButtonClicked.jsp";
                   }else if(clickedButton.name =="button2"){
                        alert("button2");
                        document.multipleSubmitDemoForm.action="linkToJSPWhenSecondButtonClicked.jsp";
                   }else if(clickedButton.name =="button3"){
                        alert("button3");
                        document.multipleSubmitDemoForm.action="linkToJSPWhenThirdButtonClicked.jsp";
                   document.multipleSubmitDemoForm.submit();
         </script>
         <body>
              <form name="multipleSubmitDemoForm" method="POST" action="" >
                   <input type="button" name="button1" onClick=submitForm(this) />
                   <input type="button" name="button2" onClick=submitForm(this) />
                   <input type="button" name="button3" onClick=submitForm(this) />
              </form>
         </body>
    </html>

  • Multiple Submit buttons in Adobe form !

    Hello Experts,
    Scenario :
    Form has Material number as input field and Material description should get automatically populated( maybe as a script or button , dont know yet ). Then the form is to be submitted at the backend.
    I have created an Adobe interactive form with Multiple Submit buttons( one is Submit toSAP) button , other is a normal pushbutton( for Material desc to be populated ) . I have been able to Submit data at backend.
    But problem is there is only one event on the Interactive form UI element properties.
    Please suggest how to achieve the above ? via script or sm code in web dynpro ?
    System Config :  WAS 6.4 /  SP12 .
    Need a quick resolution. Generous points for help.
    Regards,
    Sonika

    Hi Sonika,
    control_param structure is used in case of ISR forms, but I dont think your form is related to the ISR.
    Use a context attribute, and set its value to get the Material description from backend.
    Like you can define an attribute in context, "GETDESCRIPTION", and set its value at the exit event of Inputfield to "GET".
    $.parent.GETDESCRIPTION.rawvalue = "GET"
    app.eval("event.target.SAPSubmit();");
    And at the click event of the button you can write:
    $.parent.GETDESCRIPTION.rawvalue = "SET"
    app.eval("event.target.SAPSubmit();");
    And in the backend, read the value of this attribute and perform the desired action.
    Hope this helps,
    Amit

  • How to distribute a form with multiple submit buttons?

    I have a form that has multiple submit buttons depending on the information that is being entered and then who the information should go to.  When I try to disbribute the form, I get an error message stating the following, "Acrobat is unable to distribute this form because it contains multiple submit buttons with different formats or return URLs."  Is anyone able to let me know how I can distribute the form?

    Sounds as if you need your own web script to process submissions - written by an experienced web programmer (I very strongly recommend someone familiar with all the latest security weaknesses, and not a project for anyone else). Your needs are (it seems to me) too complex for Adobe's automatic system.

  • How can I add more than one submit button in a jsp without use of javascrip

    I want to add more than one submit button in a jsp without use of javascript

    you can do add multiple submit button with this way
    <input type="submit" value="Previous" />
    <input type="submit" value="Next" />
    <input type="submit" value="Finish" />

  • Regarding multiple submit buttons in a page!!

    hi all,
    If i have two submit buttons in a html page then i can put them in two separate forms ,one form with get method and another with post method and pass the information to the servlet and then retrieve the values using doGet and doPost methods. How can i retrieve the information in the servlet if i have multiple submit buttons in my html page?
    pls help me.......

    is your question how do i know what button was pressed?
    in html
    <INPUT name="type" value="a" type="submit">
    <INPUT name="type" value="b" type="submit">
    <INPUT name="type" value="c" type="submit">
    <INPUT name="type" value="d" type="submit">in servlet
    String type = request.getParameter("type");
    // type = a | b | c | d

  • How do I add a submit button to a pdf form?

    hello
    I am trying to add a submit button to a pdf form... is this possible though forms central or Acrobat Pro?

    If it is a PDF you created with FormsCentral, then yes, it should have a Submit button. See this for more info: http://helpx.adobe.com/acrobat-com/formscentral/help/create-fillable-pdf-form.html  and http://helpx.adobe.com/acrobat-com/formscentral/help/create-forms-locally-save-them.html
    If it's a fillable form created with Acrobat Pro, and you want to collect data with FormsCentral, then you import that existing PDF file into FormsCentral and add a Submit button to the form: http://helpx.adobe.com/acrobat-com/formscentral/help/navigate-formscentral.html#import_exi sting_fillable_pdf_forms
    I hope that helps,
    Brian

  • How do I add a functional "submit button" to a pdf form in Adobe Acrobat Pro XI ? I created the pdf form in Adobe Forms Central.

    How do I add a functional "submit button" to a pdf form in Adobe Acrobat Pro XI ? I created the pdf form in Adobe Forms Central. It's for an online Diet Questionnaire. After people complete the form I'd like them to click "SUBMIT" and the completed form will be emailed to me.

    This can be a bit confusing because Acrobat 11 comes with the desktop app that allows you to create simple PDF forms without having a FormsCentral account. Some people find this helpful, but you need to understand that when you generate the PDF form, it is Reader-enabled by Acrobat. In order to edit the form further in Acrobat, you have to create a non-enabled copy of the form. You do this in Acrobat by opening the form and selecting: File > Save a Copy
    and opening the copy. It is not opened automatically.
    You can now add a button and set it up to submit by email, either using a "Submit a form" action or the submitForm JavaScript method. You can set it up to include just the form data or the entire PDF, and will want to use a mailto type URL. Submitting the form to the FormsCentral server has a number of important advantages over email (much more reliable, more secure, etc.), so you might want to consider it.
    If the form needs to be saved with Reader versions prior to 11, then you will need to Reader-enable the document. In Acrobat 11 you do this by selecting: File > Save As Other > Reader Extended PDF > Enable More Tools

  • Submit button  from Interactive adobe form in Web Dynpro ABAP

    Hi all,
    We seem to be having a problem with the 'submit' button on the Interactive Form for the Web Dynpro ABAP.  The submit button is from the Web Dynpro active X or web Dynpro Native in the form designer. The submit button doesn't trigger the action in Web Dynpro. we are currently running on support pack 9 for the ABAP stack. We have Internet Explorer browser version 6.  Could someone tell me if there are requirements for the IE version that will work in conjunction with a particular ABAP stack version.  And, are there specific IE security settings or administrative privilages required with this version of the ABAP stack.  Or, any other ideas as to why this does not seem to work. 
    Thanks in advance,
    Michelle Hong

    Hi Michelle,
    Could you tell me how you resolved the problem - as I'm facing exactly the same issue!
    Many Thanks
    Christine

  • Submit button in interactive adobe form in abap web dynpro

    Hi can anyone help me out to know hoe to use the submit button in adobe interactive form in abap web dynpro .
    Iam creating a adobe form abap web dynpro . There i need to use the submit button to trigger some action in the adobe interactive form .
    So i need to know how to use the submit button and coding for that in the abap web dynpro .
    Vighnesh

    Hi Michelle,
    Could you tell me how you resolved the problem - as I'm facing exactly the same issue!
    Many Thanks
    Christine

  • PRocessing Multiple "Submit" buttons

    I want my JPS to have multiple submit buttons, one for Contineu and one for Cancel. It appears to me that the only way to detect which was clicked in the servlet is pretty inelegantly, something like this:
    if(request.getParameter("continue") != null)
    // do continue stuff
    else
        if(request.getParameter("cancel") != null)
    // do cancel stuffIs this correct? Is there a less cumbersome way? Thanks.

    I will suggest that you write two servlets one to do cancel action and the other to do continue action and through JS call the servlet of cancel or continue.
    that makes your work easier.
    Like this
    <Script language="JavaScript">
    function fn_Perform_Action(chr_User_Action)
                   //-- 2.1) -- ADD a record to database
                   if (chr_User_Action == "Save")
                             var bln_Ret_Val = fn_Check_Mandatory_Fields();                                                       if (bln_Ret_Val)
                                       document.frm_name.action = "/path";
                                       document.frm_name.submit();
                                       return true;                              
                   //--2.3) -- Back to the Menu
                   if (chr_User_Action == "Back")
                                       document.frm_name.action = "/path";
                                       document.frm_name.submit();
                                       return true;                              
                        return false;
    </script>
    <Input Type="Button" Value=" Update " id="id_btn_Save" Name="btn_Save"  OnClick="return fn_Perform_Action('Save');">   
    <Input Type="Button" Value="Back" id="id_btn_Back" Name="btn_Back"  OnClick="return fn_Perform_Action('Back');">
    </Td>          
    </Tr>
    [/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 2 Submit Buttons --- doesn't process form

    I previously was utilizing one button and the cancelAction command. However, this was causing the form to be submitted when used in the preSubmit event.
    I have recently implemented a 2 submit button solution to a form, which works beautifly for validation. All my edits are executed when they are suppose to be. However, now the form does not submit. When I click the complete button, noting happens.
    I have regular button name Validate, where I do all of my edit checks, and it calls the click event of a submit button, Button1, if all edits pass. I use the command Button1.execEvent("click");
    The click event of Button1 is greyed out, not sure if that is an issue.
    Has anyone ever encountered this before?

    Hi,
    I am guessing that you have used a submit by email button, which automates the submit process. As a result it does not have a click event. I would recommend using a regular button with script in its click event that will do the submit. There are examples of single button submit here, which you should be able to adapt for your hidden submit/regular button: http://assure.ly/eUR4wJ.
    Hope that helps,
    Niall

Maybe you are looking for