Handling multiple events in web application

We are converting a window application to a web application. We are facing an issue while implementing the web application with Java on front end and Oracle DB in back end. Consider a field with a car registration number which needs to be verified if it exists in the DB and fetch the remaining values related to the car and display it. At the same time we also need to save the car registration number in the form (displayed in the browser) so that other operations (such as invoicing) can happen on the car. We have a constraint that we cannot touch any of the server procedures in the DB (which handles all DB calls) but could only play with the functions in the UI.
Now the verification of the reg. no. happens whenever we go 'out of focus' from the text box where the reg.no. is written. However, if the user presses 'save' button to save the reg.no., verification should also occur and data should be saved. Now the problem we are facing is that on pressing the save button, two events are occurring simultaneously - 1. textbox with reg.no. is getting 'out of focus' and 2. save button is getting pressed resulting in verifying the reg.no. again. Due to this two events happening simultaneously, one or other method is failing leading to the car reg.no. not getting verified and saved as it should be.
Could anyone think of any solution to overcome the issue?
/Mayank

Hi,
Your assumptions are all correct. Indeed there is Javascript code executing on focus change and AJAX is doing the validations by inturn calling an oracle procedure through some Java rountine. The two requests are overlapping and hence blocking the complete execution of either, leading to the validation not taking place at all.
The webpage gets refreshed everytime an event occurs and thus the next event can take place only after the page has refreshed once (after completing all the validations linked to that event). The problem is occuring since the page is not getting time to refresh. With simultaneous execution of 2 events, the validations related to 'Out of focus' remains incomplete before the 'save function' starts. I am constrained not to put the validation related to 'Out of Focus' in the beginning of 'save' event since that would alter functionality of the 'save' event. Again, I am not allowed to change any of the server procedures on the DB side and have to pass exactly the same i/o parameters for it to function properly.
What I am trying to find is: Whether it is possible to find out (using some global variables) that when the 2 events are happening simultaneously, their functionalities could be combined and serialized in just one refresh of the webpage. and how?
I am trying to get this project done by Java resources and am myself not very technical with Java. If a solution exists and I get to know it exists, I can guide the programmers to try out the approach that come up.
Thanks so much :)

Similar Messages

  • Is it possible to handle multiple events using Jscript for a button in Apex

    Hi,
    I've application wherein in one of the pages for a button, I need to trigger 2 events as: 1. redirect to a new page upon 'click' of the button
    2. display a set of values on 'mouse over' that button.
    I'm able to handle both separately, but not in one button. I would like to know if there is any limitation in Apex that we cant handle multiple events? Currently I've put a text item near the button, and called the Jscript for mouse over event in that as a temporary workaround. Can someone let me know if this is feasible? If not any other alternative to handle this?
    Thanks in advance,
    gsachidh

    Hi Gsachidh,
    well interesting problem you're facinng. Indeed, it can't be specified using the 'Button Attributes' So we have to come up with an workaround.
    A quick en dirty solution would be to specify it with the 'Optional URL Redirect options'. In a normal button, with processing on same page, this would be 'no target'. but in case of additional things to be done this can be used, using an target URL. I used this many times, in example with popUp windows for refreshing the caller object when changes are made. In your case we have to add next to the href an onmouseover event. this can be done with;
    Target set to => URL
    URL - target => javascript:doSubmit('<button_name>');" onMouseOver="javascript:showTooltip('tooltip');"
    Here the " is the key, letting ApEx know the target (href) is doSubmit('<button_name>'), just like when no target would be specified and adding a new javascript event; onMouseOver.
    Although this is a dirty solution in my opinion, it is the best i could come up with. I have another idea in how to do this, that is by adding this event dynamically with javascript with an addEvent. But i don't have an example at the moment for this scenario.
    Simon
    Message was edited by:
    S1M0N

  • Good exception handling policy for Java web application

    I'm looking for a good exception handling policy for Java web application. First I found this Java exception handling best practices - How To Do In Java which says that you should never catch the Trowable class nor use e.printStackTrace();
    Then I found this Oracle page The Message-Driven Bean Class - The Java EE 6 Tutorial, which does just that. So now I'm confused. Is there a good page online for an exception handling policy for Java EE Web applications? I have a hard time finding one. I've read that you should not catch the Exception class. I've been catching it previously to make sure that some unknown exception doesn't slip through early in the loop and stops all other customers from executing later on in the loop. We have a loop which runs once a minute implemented using the Quartz framework. Is it OK if you just change the implementation to catch the RuntimeException class instead of the Exception class? We're using Java 7 and the Jetty Servlet Container.

    I'm looking for a good exception handling policy for Java web application.
    If you have not done so I suggest you start by reviewing the several trails in The Java Tutorials.
    Those trails cover both HOW to use exceptions and WHEN to use them.
    This trail discusses  the 'controversy' you mention regarding 'Unchecked Exceptions'
    http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html
    Unchecked Exceptions — The Controversy
    Because the Java programming language does not require methods to catch or to specify unchecked exceptions (RuntimeException, Error, and their subclasses), programmers may be tempted to write code that throws only unchecked exceptions or to make all their exception subclasses inherit from RuntimeException. Both of these shortcuts allow programmers to write code without bothering with compiler errors and without bothering to specify or to catch any exceptions. Although this may seem convenient to the programmer, it sidesteps the intent of the catch or specify requirement and can cause problems for others using your classes.
    Why did the designers decide to force a method to specify all uncaught checked exceptions that can be thrown within its scope? Any Exception that can be thrown by a method is part of the method's public programming interface. Those who call a method must know about the exceptions that a method can throw so that they can decide what to do about them. These exceptions are as much a part of that method's programming interface as its parameters and return value.
    The next question might be: "If it's so good to document a method's API, including the exceptions it can throw, why not specify runtime exceptions too?" Runtime exceptions represent problems that are the result of a programming problem, and as such, the API client code cannot reasonably be expected to recover from them or to handle them in any way. Such problems include arithmetic exceptions, such as dividing by zero; pointer exceptions, such as trying to access an object through a null reference; and indexing exceptions, such as attempting to access an array element through an index that is too large or too small.
    Generally don't catch an exception unless you plan to HANDLE the exception. Logging, by itself is NOT handliing.
    First I found this Java exception handling best practices - How To Do In Java which says that you should never catch the Trowable class nor use e.printStackTrace(); 
    That article, like many, has some good advice and some poor or even bad advice. You get what you pay for!
    I've read that you should not catch the Exception class.
    Ok - but all that does is indicate that a problem of some sort happened somewhere. Not very useful info. Java goes to a lot of trouble to provide specific exceptions for specific problems.
    I've been catching it previously to make sure that some unknown exception doesn't slip through early in the loop and stops all other customers from executing later on in the loop.
    If the exception is 'unknown' then maybe it NEEDS to 'stop all other customers from executing later on in the loop'.
    That is EXACTLY why you don't want to do that. You need to identify which exceptions should NOT stop processing and which ones should.
    Some 'unknown' exceptions can NOT be recovered and indicate a serious problem, perhaps with the JVM itself. You can NOT just blindly keep executing and ignore them without risking data corruption and/or the integrity of the entire system Java is running on.
    Is it OK if you just change the implementation to catch the RuntimeException class instead of the Exception class? We're using Java 7 and the Jetty Servlet Container.
    No - not if you want a well-behaved system.
    Don't catch exceptions unless you HANDLE/resolve them. There are times when it makes sense to log the exception (which does NOT handle it) and then raise it again so that it gets handled properly later. Yes - I know that is contrary to the advice given in that article but, IMHO, that article is wrong about that point.
    If you have ever had to maintain/fix/support someone else's Java code you should already understand how difficult it can be to find WHERE a problem occurs and WHAT the exact problem is when exceptions are not handled properly.

  • Multiple Instance of Web Application having static reference

    Hi All,
    I have a Web application "A" and the replicate of the same
    as "B". So it means it has same package and class name,
    for example
    com.test.Util is the java file which gets the DB Properties
    from a File. All the variables in that java file are static
    for example the
    DIRECTORY_NAME = c:/instance1
    FILE_NAME = db.properties
    In application "A"'s web.xml, on load startup i am invoking
    a Servlet on the init method i am grabbing these details
    from my util class.
    In Application "B" i am chaning the com.test.Util
    DIRECTORY_NAME=c:/instance2
    FILE_NAME=db2.properties
    I generate a WAR for Application "A" and "B" and deploy that in Tomcat.
    Now if i start tomcat, i understand that Configuration of
    B overrides A, because they are all static.
    Basic Question is same Static memory blocks are shared by two different deployed web application, i want to have them seperate how can i do that?
    Thanks in Advance
    Arul

    Try deploying them in different domains... not sure of this though

  • How to create an event in web application?

    Hi,
    I am creating online auction application. I need to have an event trigerred when an auction on an item is finished. How can I do that?
    Thank you

    You could use the Observer design pattern...You'll find plenty of litterature on the subject.
    You'd also want to take a look at how they implement the feature you're looking for in existing auction applications, like Sun's :
    http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/code.html
    Sourceforge's Gavel, which is open source, so you can browse the CVS repository to look for source code :
    http://sourceforge.net/projects/gavel/

  • Handling multiple events simultaneously.

    Hi,
    I have a window with a CNiGraph inside. In the graph I have multple traces. I have a toolbar which has the following buttons:
    * Pan
    * Zoom Area
    * ZoomX
    * ZoomY
    * Range mark
    * Add annotation
    When the user clicks a toolbar item I have to change the Tracking mode to the appropriate mode, eg
    if (m_nMode == 0)
    m_Graph2D.SetTrackMode(CNiGraph::TrackAllEvents);
    else if (m_nMode == 1)
    m_Graph2D.SetTrackMode(CNiGraph::TrackPanPlotAreaXY);
    else if(m_nMode == 2)
    m_Graph2D.SetTrackMode(CNiGraph::TrackZoomRectXY );
    else if(m_nMode == 3)
    m_Graph2D.SetTrackMode(CNiGraph::TrackZoomRectX);
    else if(m_nMode == 4)
    m_Graph2D.SetTrackMode(CNiGraph::TrackZoomRectY);
    else if(m_nMode == 5)
    m_Graph2D.SetTrackMode
    (CNiGraph::TrackDragCursor);
    else if (m_nMode == 6)
    m_Graph2D.SetTrackMode(CNiGraph::TrackDragAnnotation)
    My problem is the following. If the user has a cursor displayed and wants to zoom I set the trackmode, however if after the zoom he wants to move the cursor I have to change the trackmode. Is there a way to have multiple trackmodes at the same time. Meaning if the user creates a rectangle for zooming it zooms however if the user starts dragging an annotation or a cursor it will respond to that.
    Since if I change to TrackAllEvents it will not track my cursor or my annotations, since the events are never fired.
    Please help,
    Thanks
    Miklos

    The Measurement Studio C++ graph does not support enabling multiple interaction modes. As you suggest, the way to do this is to have a toolbar, in which the user can select the interaction mode that he or she wants.
    On a side note, the Measurement Studio .NET graph does support enabling multiple interaction modes. However, using the Measurement Studio .NET graph would require that you use a managed language (e.g. C#, VB.NET, Managed C++) for your user interface.

  • Static member problem in multiple instance of  web application

    Problem
    I am working on a product which is java based. I have a war file. I have to deploy this war file in JBoss. Further, I need to run multiple instance of this war file in same JBoss instance.
    Issue
         In that war file there is servlet Start.java. That servlet calls an other class from its init method. Here is code
    public class Start extends HttpServlet
         public void init(ServletConfig config) throws ServletException
              super.init(config);
              DB.loadProperties (�db.properties�);
         } // init
         public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException
                   } // doGet
         public void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException
                   } // doPost
    } // Start
    public final class DB implements Serializable
         public static final String     P_UID = "ApplicationUserID";
         private static final String     DEFAULT_UID = "System";
         public static final String     P_PWD = "ApplicationPassword";
         private static final String     DEFAULT_PWD ="System";
         public static final String     P_STORE_PWD = "StorePassword";
         private static Properties           s_prop = new Properties();
    public static boolean loadProperties (String filename)
         {    // looks for properties file
    s_prop = new Properties();
              FileInputStream fis = null;
              try
                   fis = new FileInputStream(filename);
                   s_prop.load(fis);
                   fis.close();
              catch (FileNotFoundException e)
                   log.warning(filename + " not found");
                   loadOK = false;
         �}
    As you can see if I deployed two instance of this war in JBoss and assume each instance point to its own properties file. The �Static� members are problem.
    Restriction
         I am not allowed change the code or logic of the product. I must be able to get some thing outside or apply a patch to solve this problem.
    Please Help
    Possible option that I have thought
    1 Using multiple JVM - Not an option in this project
    2 Using multiple JBoss � Not the requirement (need to run only on single Instance of JBoss)
    3 Use own class loader for war/ear � don�t know how in JBoss need help.
    I am using JBoss 3.2.3
    Thanks,
    Kumaran

    Static members belong to the class. So, you needto
    think of multiple JVMs for your problem.Thanks for reply.
    don�t know how in JBoss need helpJust guessing... clustered environment MAYBE
    RichThanks Rich,
    I don�t know how Cluster environment solve my problem. I need more information on your thought. Cloud you explain it.
    Kumaran

  • Can we handle multiple forms  in struts application

    In one jsp i will handle a form based on the input ,I must retrieve data and set it in another form class is it possible if so how
    addResource.jsp
    <html:form >
    <html:text name="resourceForm" property="resourceId" />
    </html:form>
    In action class method
    retrive resourceid based on that retrieve employee information
    and need to set in another form for display is it possible

    you can forward the request to a different action before redirecting to the second form, create another action like
      <action path="/secondFormAction"
                      type=""
              name="secondForm">
              </action>
    then in your resource form action
    <action path="" name="resourceForm" >
        <forward name="success" path="/secondFormAction.action"/>
    </action>the secondFormAction will create the form for you and u could put the data in request attribute and access it in the secondFormAction and then pupulate the data in the secondForm and then redirect the request to the second JSP.
    hope you have got the point here, I wouldnt wont to paste anycode until you try it out.

  • Multiple Event Handler

    Hey,
    This is probably a really stupid question but is there a way
    to declare an event handle on an Actions layer that handles
    multiple events?
    For example, both of these are equivalent:
    // on button
    on (rollOut)
    // on action layer
    btnTest.onRollOut = function()
    // on button
    on(rollOut, releaseOutside)
    // on action layer

    btnTest.onRollOut = btnTest.onReleaseOutside = function(){
    }

  • Best way to manage images on jsp web application

    Hi,
    Am developing a jsp web application, in that project, the user will upload the image files, now I created an image directory in the context root and when the image is uploaded by the user it is saved in the /images directory and the image path is saved in the database. I can display this image using the <img src="images/a.jsp" > tag.
    but when I rebuild the project all the images in the /images directory get deleated but the image path is remained in the database, is there any method that I make /image dir outside my project context root so that when I rebuild the project the /images dir can get changed and my project will save images outside the context root that is in the /images dir which is now outside the project context root. and is it possible to display those images using <img src""> tag. because this time my /images dir is at D:/images . what could be the best method or way to handle images with the web application.
    any suggestion will be helpfull

    Well my friend as per your given case there are to two ways of approaching your problem.
    Case 1:
    How to save the relevant data ??
    .Create a backup folder Workstation on which you are hosting your application where you can store all the uploaded files which is outside the scope of webserver(However we can write a dedicated servlet which can access that file) and make sure we pickup from any the folder path from a specfic MessageResource bundle or an context/servlet init parameter in web.xml.
    .Write a Upload servlet/Backing Bean which saves all the files in the discussed folder using utility packages like Commons FileUpload,Oreilly MultipartRequest & etc and then register saved fileName in the database user specfic table specific to user.
    How to display the Image ??
    .Write a dedicated servlet which can pickup user related fileName specfic information from the database and the read the file from backup folder by constructing the path from the entry made as a init param in web.xml or any other custom MessageResource bundle and then stream the Image data using the ServletOutputStream.
    NOTE: do not forget to pickup & setImage file ContentType & Set the content length.
    .Just try to render the JSP view file where we are displaying the displaying the images by calling the dedicated ImageServlet.
    <img src="ImageServlet?userid=2345" align="center"/>Try to refer below posts to get a better understading.
    Dedicated Image Servlet:
    http://forum.java.sun.com/thread.jspa?threadID=5208858&messageID=9840042#9840042
    Uploading Files Using Servlet:
    http://muimi.com/j/jakarta/commons/fileupload/
    Case 2
    The second method would more or less the same but here we would save the uploaded file
    content is saved in the Database as a Blob and we would retrive it back using a dedicated image servlet again.
    However,in terms of performance the second case implementation is very costly.
    Try to refer below posts to get a better understading on the second case.
    http://forum.java.sun.com/thread.jspa?threadID=5193481&tstart=50
    http://forum.java.sun.com/thread.jspa?threadID=5211649&messageID=9853670#9853670
    Hope this might help :)
    REGARDS,
    RaHuL

  • How to handle multiple datasources in a web application?

    I have a J2EE Web application with Servlets and Java ServerPages. Beside this I have a in-house developed API for certain services built using Hibernate and Spring with POJO's and some EJB.
    There are 8 databases which will be used by the web application. I have heard that multiple datasources with Spring is hard to design around. Considering that I have no choice not to use Spring or Hibernate as the API's are using it.
    Anyone have a good design spesification for how to handle multiple datasources. The datasource(database) will be chosen by the user in the web application.

    Let me get this straight. You have a web application that uses spring framework and hibernate to access the database. You want the user to be able to select the database that he wants to access using spring and hibernate.
    Hopefully you are using the Spring Framework Hibernate DAO. I know you can have more that one spring application context. You can then trying to load a seperate spring application context for each database. Each application context would have it's own configuration files with the connection parameters for each datasource. You could still use JNDi entries in the web.xml for each datasource.
    Then you would need a service locater so that when a user selected a datasource he would get the application context for that datasource which he would use for the rest of his session.
    I think it is doable. It means a long load time. And you'll need to keep the application contexts as small as possible to conserve resources.

  • MVC �Best Practice� (handling multiple views per action/event)

    Looking for the best approach for handling multiple views for one action/event class? Background: I have a small application using a basic MVC model, one controller servlet, multiple event classes, and multiple JSP views. For performance reasons, the controller Servlet is loaded once, and each event class is an instance within it. Each event has an �eventProcess()� and an �eventForward()� method called by the controller, standard stuff.
    However, because event classes should not use instance variables, how should I communicate which view to forward to should based upon eventProcess() logic (e.g. if error, error.jsp, if success, success.sjp)? Currently, there is only one view mapped per event, and I'm having to put error handling logic in the JSP, which goes against the JSP being for just view only.
    My though was 1) A session object/variable that the eventProcess() sets, and the eventForward() reads, or 2) Have eventProcess() return a mapping key and have the conroller lookup a view page based upon that key, as opposed to 1-1 event/view mapping.
    Would like your thoughts!
    Thanks
    bRi

    Your solution seems ok to me, but maybe the Struts framework from Apache
    that implements MVC for JSP is a better solution for you:
    http://jakarta.apache.org/struts/index.html
    You should take a look at it. It has in addition some useful taglibs that makes life much easier.
    We have successfully used it in a project with about 50 pages.

  • Handling events in BSP application using WML tag Extensions

    Hello Everyone  ,
                            We are developing a BSP applications for Mobile handheld using WML tag library. I am looking for some code samples to know how we can handle evevents inside the BSP using the WML tag library.
    Can any one of  you plesae help us by placing a code snippet for handling onInputprocessing() methods (BSP Using WML Tag extensions).
    I mean to ask how we can handle events inside the BSP applications that uses the WML tag library.
    I know about how to handle BSP events using HTMLB and XHTMLB tags frameworks.
    Thanks for your help in advance.
    Thanks,
    Greetson

    Is this WML tag library something that is supplied by SAP u2013 as a BSP Extension Element?  Or are you just using WML tags directly in your layout?  I can tell you in general that if you want to generate HTMLB events from regular HTML code you can generate the JavaScript calls using the htmlbEvent tag of the BSP extension library.  However your tags have to be running within an HTMLB Content tag for this to work.
    If you want to work totally without HTMLB then you need to use the simple HTTP Post but format the input name as OnInputProcessing(<function code>) like this:
    <input type="submit" name="OnInputProcessing(ok)" value="OK">
    This will cause the OnInputProcessing event handler to trigger without needing any HTMLB tags (this is how it was done in WebAS 6.10 before we BSP Extensions).

  • Same JVM for multiple Frames in a web application

    Hi guys,
    I have a web application that loads an applet during login. Once the login is completed, the web application will display the available functions accessible with a menu on the left frame and the main display page on the right frame. Whenever any form action is perfomed on the right frame, the jvm with the login session seems to exit (java console closes) and the applet will be loaded to prompt the user to login again. The JRE installed on the Windows client is 1.6.0_14 from SUN.
    I'm guessing that the different frames are using different JVMs?
    Is there a way to use the same jvm for a web application with multiple frames? I want to prevent the case where the user will have to login again.
    Thanks for any advice!
    - Zen -

    I have sort of the same problem
    [Identical applets in the same JVM, next generation plugin issue|http://forums.sun.com/thread.jspa?threadID=5396118]
    I have submitted a Request for enhancement to SUN to allow forced grouping of applets in the same JVM.
    Sort of the opposite of the "separate_jvm" Applet tag parameter.
    It seems there is currently no way to do this.
    [New Plugin command line args|https://jdk6.dev.java.net/plugin2/jnlp/#COMMAND_LINE_ARGS]
    When per-applet JVM command-line arguments are specified, it is likely that the new Java Plug-In will need to launch another JVM instance in order to satisfy them. In other words, it is unlikely that a preexisting JVM instance will have been started with the correct set of command-line arguments to satisfy the current applet's request. The rules for exactly when a new JVM instance is launched to start a given applet are deliberately left unspecified, as this functionality is brand new in the 6u10 release and may need to change in subsequent releases. Here is a rough set of guidelines for the sharing and creation of new JVM instances:
    * If the command-line arguments used to start a preexisting JVM instance are a superset of the requested arguments, the preexisting JVM instance will be used.
    * If a JVM instance is launched for the "default" set of command-line arguments (i.e., those specified in the Java Control Panel, with no per-applet arguments specified), then this JVM instance will never be used to launch any applet that has even one per-applet command-line argument.
    * -Xmx is handled specially: if a preexisting JVM instance was started with for example -Xmx256m, and a new applet requests -Xmx128m, then new applet will very likely be run in the preexisting JVM instance. In other words, -Xmx specifications are matched with a greater-than-or-equal test.
    There is no way to "name" a JVM instance used to launch a particular applet and "force" subsequent applets into that JVM instance.
    See the section on the separate_jvm parameter to isolate a particular applet in its own JVM instance, separate from all other applets.

  • Web Application Multiple screen

    Hi to all
    I'm very very new on Flash builder so my question can be very silly ....
    I'm trying to buil my first web application that is composed by 4 screen
    In the first screen there are 3 button and I want display the rigth screen when user click on the button
    I found on internet this code
      navigator.pushView(SecondScreen);
    and I associated it on click event
    but i get the error
    Can someone help me ?
    thank's in advance
    Multiple markers at this line:
    -1061: Call to a possibly undefined method pushView through a reference with static type spark.components:NavigatorContent.
    -1136: Incorrect number of arguments. Expected 1.
    -1 changed line

    Hi,
    Create radio buttons. OnSelect event of radio button write your code to display interactive form.
    If you want you can create three veiw for e IF forms. so only one view visible at one time
    OR
    Create your interactive section in 3 TC container or in TRAY, for each section one TC or TRAY.
    Crate on 3 atributes of type WDUI_VISIBILITY and bind this to visible property of container or tray.
    In onselect event of radio button based on your selection, use SET_ATTRIBUTE to visible your interactive section bye
    passing '01' or '02' values.
    hope it solves.
    cheers,
    Kris.

Maybe you are looking for