Using javascript with struts

hi ,
i have a jsp page which has a function to be called in javascript,
if all the values entered are correct, then the details need to be submitted to the action form in struts.
the coding is like below:-
<%@ page language="java"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld"      prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld"     prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld"     prefix="logic"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Title</title>
<link href="css/cherrysoft.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="javascripts/function_client.js" type="text/javascript"></script>
<script src="javascripts/chgoto.js" language="JavaScript" type="text/javascript"></script>
<script language="JavaScript">
function fixSize() {
     buttondiv.style.top =  document.body.offsetTop +(document.body.offsetHeight - buttondiv.offsetHeight );
     contentDiv.style.height = document.body.offsetHeight -  buttonbar.offsetHeight - buttondiv.offsetHeight-14;
     function cancel(obj){
obj.action="FinanceView.do?do=listBook";
          obj.submit();
     function check_details(obj)
          var frmyear=document.forms[0].fin_fromyear.value;
          var frmmonth=document.forms[0].fin_frommonth.value;
          var toyear=document.forms[0].fin_toyear.value;
          var tomonth=document.forms[0].fin_tomonth.value;
          var yearabbr=document.forms[0].fin_year_abbr.value;
          //alert("From Year : "+frmyear+" frmmonth : "+frmmonth + " : toyear "+toyear+" : to month "+tomonth);
          if(yearabbr.length < 1)
               alert("The abbreviation field is mandatory");
               document.forms[0].fin_year_abbr.focus();
          else if(frmyear.length < 1)
               alert("The from year field is mandatory");
               document.forms[0].fin_fromyear.focus();               
          else if(frmmonth.length < 1)
               alert("The from month field is mandatory");
               document.forms[0].fin_frommonth.focus();
          else if(toyear.length < 1)
               alert("The to year field is mandatory");
               document.forms[0].fin_toyear.focus();               
          else if(tomonth.length < 1)
               alert("The to month field is mandatory");
               document.forms[0].fin_tomonth.focus();               
          else if(frmyear == toyear)
               alert("The from and to year cannot be same");
               document.forms[0].fin_fromyear.focus();
          else if(frmmonth>4)
               alert("The from month cannot start from "+frmmonth);
          else if(tomonth<3)
               alert("The to month cannot be less than "+tomonth);
          else if(frmmonth==tomonth)
               alert("The from month and to month cannot be same");
          else
               obj.action="FinanceView.do?do=listBook";
               obj.submit();
</script>
</head>
<body onLoad="fixSize();" >
<html:form action="/FinanceBeanAdd">
<div style="height:5%;width:100%" >
     <div id="buttonbar" style="border:0px ;margin-top:0px">
     <table width="100%" cellspacing="0" class="main" >
      <tr>
               <td class="heading" >Add Financial Year Details</td>
                 <td width="24" background="<%=request.getContextPath()%>/images/bg-titlemid.jpg"></td>
                  <td width="100"  valign="bottom" background="<%=request.getContextPath()%>/images/bgline.gif"></td>
      </tr>
     </table>
     </div>
</div>
<DIV id="contentDiv" class="workareadiv"  style="height:85%;width:100%">
<table width="600px" height="380px" align="center" border"0" cellpadding="0" cellspacing="0">
     <tr>
          <td valign="top">
               <table border="0"align="center" cellpadding="0" cellspacing="0" >
                    <tr>
                         <td  colspan="2">
                         <table width="600px" height="380px" border="0" align="center" cellpadding="0" cellspacing="0" >
                              <tr>
                                   <td colspan="3" bgcolor="#FFFFFF">
                                        <tr>
                                                  <td colspan="3" valign="top">
                                   <div  id="enter_details" style=display:block>
                                   <table border="0" bgcolor="#FFFFFF" width="730px" >
<tr bgcolor="#FFFFFF" class="firstrow">
<td width='30%' align='left'style="padding-left: 40px" >
<b>Abbreviation</b><font color='red'>*</font>
</td>
<td width='70%'>
<html:text property="fin_year_abbr" maxlength="7"/></td>
</tr>
<tr bgcolor="#FFFFFF" class="secondrow">
<td width='30%' align='left'style="padding-left: 40px" >
<b>From Year</b><font color='red'>*</font>
</td>
<td width='70%'>
<html:text property="fin_fromyear" maxlength="4" /></td>
</tr>
<tr bgcolor="#FFFFFF" class="firstrow">
<td width='30%' align='left'style="padding-left: 40px" >
<b>From Month</b><font color='red'>*</font>
</td>
<td width='70%'>
<html:text property="fin_frommonth" maxlength="2" /></td>
</tr>
<tr bgcolor="#FFFFFF" class="secondrow">
<td width='30%' align='left'style="padding-left: 40px" >
<b>To Year</b><font color='red'>*</font>
</td>
<td width='70%'>
<html:text property="fin_toyear" maxlength="4" /></td>
</tr>
<tr bgcolor="#FFFFFF" class="firstrow">
<td width='30%' align='left'style="padding-left: 40px" >
<b>To Month</b><font color='red'>*</font>
</td>
<td width='70%'>
<html:text property="fin_tomonth" maxlength="2" /></td>
</tr>
                         <tr>
                                                       <td>
                                                       <logic:messagesPresent>
                                                            <ul><font color='red' >
                                                                 <html:messages id="error1">
                                                                      <li><%= error1 %></li>                         </html:messages>
                                                                 </font>
                                                            </ul>
                                                       </logic:messagesPresent>
                                                       </td>
                                                       </tr>
                                                       </table>
                                                       </td>
                                                       </tr>
                                        </td>
                                   </tr>
                              </table>
                              </div>
                              </td>
                         </tr>
                         </table>
                    </td>
               </tr>
          </table>
</td>
</tr>
</table>
</div>
           <div id="buttondiv" style="height:10%">
                                                                   <table width="100%" align="left" border="0" cellpadding="3" cellspacing="0"  class="main" >
                                                                 <tr>
                                                                      <td colspan="4" bgcolor="#FFFFFF">
                                                                           <table border="0" cellpadding="2" cellspacing="2" align="left">
                                                                           <tr>
                                                                           <td>
                                                                                <div align="left" id="save_btn">
                                                                                <!-- <html:button property="do" value="Save" onclick="check_details(this.form);"/>-->
                                                                                     <!--<html:submit property="do" value="Save"/> -->
                                                                                 <input type="button" value="Save" onclick="check_details(this.form);"%>
                                                                                </div>
                                                                           </td>
                                                                           <td><div align="left">
                                                                           <html:button property="Cancel" value="Cancel" onclick="cancel(this.form);"/>
                                                                           </div></td>
                                                                           </tr>
                                                                           </table>
          </div>
</html:form>
</body>
</html>
[/b]the problem right now is when the values are entered the details are not getting stored and it returns to the view.
pls require someone's help.
thanks
sreejith

I don't see anything at all in that code that has anything to do with JDBC.
So certainly that code by itself can't store anything in a database.

Similar Messages

  • Help me!! How to use JavaScript with JSP ??

    I am using JDeveloper and I created a screen in JSP which uses a bean for database connectivity and retriving info onto the page.
    The page has a ListBox where list items are populated from the database.My requirement is
    whenever the list is changed the page shuold be refreshed with the selected item info.
    I tried to use 'JavaScript' for triggering the event with 'onChange' event of the ListBox.But the event is not getting invoked. I think JavaScript is not working with JSP.
    Please help me with how to Use javaScript with JSP or any other alternative where I can meet my requirement.
    I have one more question...I have gone through the JSP samples in OTN and I am trying do download the sample 'Travel servlet' which show list of countries...etc
    I have also gone through the 'readme' but I don't know how to extract .jar file.
    I would be great if you could help me in this.
    Thanks!!
    Geeta
    null

    We have a similar need. We have used Cold Fusion to display data from Our Oracle Database. We have a simple SElect Box in HTML populated with the oracle data. When someone selects say the State of Pennsylvania. then we have an On change event that runs a Javascript to go get all the cities in Pennsylvania.
    Proble we are having is that inorder for the Javascript to work , we currently have to send all the valid data.
    Do you know of any way to dynamically query the the Oracle database in Javascript

  • Use Javascript with InDesign buttons?

    I haven't been able to find ANY info about this anywhere, but I'm wondering if it's possible to call a Javascript function from an InDesign button, instead of link to a web address. This can obviously be done in Flash, but the same syntax that works in Flash does not work in InDesign. I'm not referring to the Scripts panel here - I'm talking about using Javascript with a button created in InDesign. I tried calling a JS function with the GetURL action, to no avail.
    If anybody has ever done this, please post a sample of the correct syntax for a JS function call, as well as which action I should use. Many thanks in advance!

    (Edit: I'm talking about ID CS4/CS5 SWF export, naturally)
    I don't know why, but the following URL (using a global javascript function) seems to work, somehow;
    javascript:alert('testing');
    Arbitrary function names do not work - browser just says "function not defined" - although the same stuff works in Flash. For example;
    javascript:myFunction();
    Also, there seems to be very little info on which (button) properties are included in the SWF export.
    Additional information on the subject would be much appreciated here, too.

  • Using Javascript With Acrobat Forms

    Hello,
    I have been attempting to use Javascript with forms made using Acrobat X Pro. Particularly, I am attempting to use the Font palette with Text fields as described in http://partners.adobe.com/public/developer/en/tips/CalcScripts.pdf .
    One example of this is the Strikethrough property.  TextField1.caption.font.lineThrough = "linethrough" and TextField1.font.lineThrough = "linethrough". I see that "linethrough" is an enumeration (Having values of 0,1, and 2). But I have tried this numerous times, in various ways, and it does not work. I also tried other Font properties and could not get them to work. Is there more setup to this? I am still very much new to developing Forms, and it was frustrating for me to not find a resource that outlined all of the stuff you could do with Forms. My only prior experience with Javascript is for web pages. The pdf I mentioned above seemed promising, but I'm having trouble implementing it.
    I appreciate any help for this!

    For questions about LiveCycle Designer use the forum LiveCycle Designer.

  • Using JavaScript with Acrobat XI Standard

    I am part of a transition team setting up a new correctional facility. I am working with our IT dept to purchase licenses for Acrobat XI. I need to get a definitive answer on using JavaScript with XI standard. The forms I am working with have a variety of scripts mostly button activated. Actions include saving and renaming files to a networked drive. Money is always an issue so if I can use XI standard that would be the better financial choice. The documents will not be created using XI standard just processed.

    This is the Reader forum; the Acrobat one is here:
    http://forums.adobe.com/community/acrobat

  • Using jsf with struts

    hi;
    i am trying to understand the proper architecture when using jsf and struts together.
    i think i understand the differences between the technologies . it seems to me that instead of justifying jsf there should be a focus on how the two technologies actually collaborate.
    specifically, i would like to know or see examples of things like replacing the view portion of struts and plugging in the jsf framework instead or how to i replace the struts actions with jsf commands or maybe they are totally different things.
    where can i get information like this?
    thanks.

    At present, i think the best thing to do is to look at the example provided with the struts-faces integration taglib. I don't know any documentation about it.
    http://cvs.apache.org/builds/jakarta-struts/nightly/struts-faces/

  • How to use displaytags with struts

    How to use display tags with struts to generate report from database

    I think it would only consist in including the tag library of displaytags in the header and use the prefix of desplay tags.
    Exporting the report from a database would only need to retrieve this information from the database as a List, Map or Collection of objects (beans) and display tem with the corresponding tag (table)
    You have some more information here:
    http://displaytag.sourceforge.net/11/tut_basic.html
    Regards and good luck,
    Fran Serrano.

  • How can i use JavaScript in Struts

    Any one can please tell me how can i use simple java script in Struts framework
    like
    <script language="javascript">
    function call()
    alert("You Are In call()")
    </script>
    </head>
    <body>
    <form ..... >
    <input type="button" value="CHECK" onclick="return call()" >
    </form >........
    ok this i can use in normal jsp
    but how can i use same in Struts framework
    Thanks in advance

    This forum is for JSF, not Struts. Your best bet to get your question answered, is to post to the struts user mailing list.

  • How does one use JavaScript with the Windows Media Player Plugin?

    Hi there.
    According to this old [http://msdn.microsoft.com/en-us/library/dd564570%28v=VS.85%29.aspx MSDN Article] it is possible to control the windows media player plugin using javascript.
    It provides a series of objects off the object that should perform certain funtions, such as play stop and seek.
    It states very clearly in the article that some are not supported; however, none of them seem to be working with the latest version(s?) of Firefox.
    I have Firefox 5 installed currently and have not tested in any other version, so I'm not sure when it stopped working.
    The video does load and will display properly -- the ability to control it through javascript however, does not work.
    i.e.:
    var mplay = document.getElementById('myplayer');
    mplay.controls.play(); // mplay.controls is undefined
    This same code works in Internet Explorer.

    You need to place the URL in a data attribute for Firefox.
    <pre><nowiki>document.write(' <OBJECT id="Player" data="http://87.117.197.189:16229" width="320" height="45" type="application/x-ms-wmp">');
    document.write(' <param name="AudioStream" value="true">');
    document.write(' <param name="Enabled" value="True">');
    document.write(' <param name="ClickToPlay" value="false">');
    document.write(' <param name="BufferingTime" value="5">');
    document.write(' <param name="ShowDisplay" value="False">');
    document.write(' <param name="Volume" value="70">');
    document.write(' <param name="autoStart" value="true">');
    document.write(' </OBJECT>');</nowiki></pre>

  • Using Javascript with SOFIAFramework

    Hi everyone,
    I'm trying to set one login page designed in JSP, making use of the SOFIA framework. In order to make some validations, i have to use Javascript at the client side itself.
    I tried by calling a function(Javascript) on the click of a button. My making use of alert(), i realized that i reached the function. But i got errorwhen i tried to retrieve the value of one text field.
    CODE : (Javascript)
    function check(){
    alert("Inside function");
    var name=newForm.username.value;
    alert(name);
    I got error at the second line of code inside the function and it states that, "newForm.username.value is null or not an object"
    Could anyone help ,me to get out of this.

    It might even be possible to use Reader XI for filling in the forms and saving the forms. Since this is a free product, then cost would not be an issue. The issues will be the custom files that would need to be installed on each user's system.

  • Using ajax with struts 1.2.9

    Hello Experts ,
    First of all I am sorry if I have posted question in a wrong forum but I have tried posting my problem in struts forum also but didn't get reply & I am pretty new to struts.
    I am trying to use ajax in struts 1.2.9.I have used 1 dependent combo.When I am changing value in 1 combo it will call an action class which will fetch data for 2nd combo .My problem is ,action class "success" has to be forwarded to some particular jsp.But I want to refresh only a part of page not the whole page.How to refresh just a part of page?? Any idea or any link which can help me.Any help in this will be highly appreciated.Many many Thanx in advance.

    Hello Shasi,
    Lets take the sample code for one combo box (College) , one change of which I want to display the information of that college in the textboxes below it.So on change of college combo I am calling the action class which is retrieving info of college.My problem is now how to send this data to jsp & what should be the success & failure forward for my action class.
    In my JSP I have written something like this....
                           createXMLHttpRequest();
                            queryString2 ="retrieve_college_info.do?";
                            queryString2 = queryString2 + "selcollege="+document.forms[0].college_name.options[document.forms[0].college_name.selectedIndex].value;
                            xmlHttp.open("GET", queryString2, true);
                            xmlHttp.onreadystatechange = handleCollegeRetrieve;
                            xmlHttp.send(null);My action class code goes like this
    package ibm.tgmc_nextyear.actionclass;
    import ibm.tgmc_nextyear.businesslogic.*;
    import ibm.tgmc_nextyear.formbean.*;
    import java.io.PrintWriter;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionForward;
    import java.sql.*;
    import java.util.ArrayList;
    import org.apache.struts.util.LabelValueBean;
    public class CollegeRetrieveInfoAjaxAction extends org.apache.struts.action.Action {
        public ActionForward execute(ActionMapping mapping, ActionForm  form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
                   String optionSelected = request.getParameter("selcollege");    
                   String responseText="";
                   Connection conn = null;
                   Statement stmt = null;
                   ResultSet rs = null;
                   TeamDetailsForm team_frm = null;
                   try {
                        conn = getDataSource(request).getConnection();
                        stmt = conn.createStatement();
                rs = stmt.executeQuery("select name , address  , city , pincode , ph_no , hod_name , principal_name , alt_no , website from user.college_table where college_id=" + optionSelected);
    *//what after this ???*
            } finally {
                if (rs != null) {
                    rs.close();
                if (stmt != null) {
                    stmt.close();
                if (conn != null) {
                    conn.close();
             *//what should be the value os success forward*
           return(mapping.findForward("success"));
    }

  • ALBPM5.7: Using ALUI with struts application??

    I have a fully functional struts application that uses PAPI to interact with ALBPM5.7. Now I want to Expose all UI screens on the portal server. This need not be portlets, rather using ALUI framework/ EDK to wrap the UI JSPs and expose them in our portal
    Can I reuse my Struts Application with ALUI in some way.
    Thanks.
    Edited by [email protected] at 12/11/2007 9:49 PM

    Ravinder,
    Yes, of course you can bring your struts web application on ALUI portal as a portlet.In general, any web application running either on remote server or ALUI server can be brought up to the ALUI portal.
    If your Struts application is running on the remote server ,here is the steps to view this application on ALUI Portal :
    Login to your ALUI admin ( http://<hostname>:<portnumber >/portal/server.pt(like http://yh759.yashind.com:7001/portal/server.pt) with Administrator as userid(no password required by default)
    Create a Remote server in ALUI where you need to have the info of your Struts application server info
    Create a remote webservice for portlet
    Create a portlet out of that remote webservice
    Put this portlet on any page.
    Alo you can find the online help on ALUI admin conosle for doing all the above steps.
    Thanks
    Bishnu
    Regards
    Bishnu

  • How to plot bar chart using iReport with Struts 2

    Hi All
    Im working on iReport 3.5.1 to generate jasper report for our java enterprise application. Here, I have no problem, when im generating simple report[without any chart]. When i try to add a bar chart to jasper report, i coudnt get the exact chart what i wanted, im just getting some ridiculous chart which is exactly wrong, i guess the problem is with the data given to plot the chart. Do, anybody know how to transport data to plot the bar chart in iReport. For Simple chart im using javabeans to generate report, but for chart, how it should be?
    Thanks in advance
    Thanks and Regards
    Baskaran
    Edited by: Baskaran on May 22, 2009 12:36 PM

    jxl does not support create chart from scratch.
    Maybe you can do it by using excel template:
    define a chart in the sheet,using definedName or fixed range as chart data source.

  • How to validate the phone using Javascript with regularexpression

    Hi ,
    I wanted to validate the phone no with java script regular expression in Sun IDM Xpress code.
    I have written the code like
    <script>
    var bolean = testStr.match(\d{3}-\d{3}-\d{4});
    </script>
    But it not validating and giving the "undefined: illegal character (; line 1)"
    Can any body help me how to validate phone no in the java script regular expression in Sun IDM.
    Thanks in advance.
    Regards,
    Ranjan

    create a javascript rule that include the regular expression validation and call that rule from the filed validation section passing the field value.
    S.

  • Acrobat Reader X : Error using javascript with ProtectedMode on

    Stumped with an issue.
    I have a PDF with a mouseup event to trigger the PDF to SAVE to a network location and it works fine in v9 but with Reader X and enable Protected Mode turned on it throws the following error:
    NotAllowedError: Security settings prevent access to this property or method.
    Doc.saveAs
    I get the above error even though the NETWORK PATH has been added in Reader preferences as a trusted PATH and the web site is listed as a trusted site.
    What am I missing here?

    According to the documentation, I am supposed to be able to setup a POLICY file "ProtectedModeWhitelistConfig.txt" and add parameters to it such as
    FILES_ALLOW_DIR_ANY = c:\tempfiles\*
    FILES_ALLOW_ANY = c:\tempfiles\*
    I want the ability to save to a UNC network path...it worked fine in Acrobat 9 and now with sandbox security and protectedMode in "X" nothing works.
    In Acrobat X, if "enable protected mode" is on, NOTHING works and an error is thrown.  If it is unchecked, the saveAs works fine.

Maybe you are looking for

  • Can you write an excel file on client machine instead of on the server

    I am trying to user cfSpreadSheet functon. The first question I have is, can you write the file on a client machine? I tried but they all end up on the server drive. Scecond question, is there a way to do row and column range formating in CF9.0? Spre

  • S10e (4187XB5) wireless fails after a few seconds

    The wireless thinks it is connected. It connects to the home (or office) wireless without trouble, acquires valid IP address, etc., but behaves as if unconnected after a few seconds. I have tried: Uninstalling and reinstalling the network adapter via

  • Removecontexts

    I have the following mapping structure.. IDOC   ORDERS05     E1EDK01       belnr     E1EDK03       IDDAT - 011       DATUM - date      E1EDK03       IDDAT - 011       DATUM - date      E1EDP01       posex I need to map that to Header (as many times a

  • Dialog Prog to Display fields of Table or Structure in screen dynamically.

    Hello Experts ,        I am working on a dialog programming I wish to display any given table/structure on the screen - to be very clear. 1st screen -     One input box which can take any SAP standard or custom tableor structure as input <-- Press en

  • How to link to a computational program? (a "C" or "BASIC"}

    I am writing an engineering book that has a lot of equations and would like to link to a program that does the computations for the reader so that he does not to perform the complex calculations manualy. Any suggestions?