Simple problem with an alert

I want to show an alert, then when it times out, display a menu of choices (the "main menu").
Problem is, the alert never displays; the menu immediately pops up so they never get a chance to see the alert message.
How do I get the alert to wait it's timeout period before continuing on to the next block of code?
Here's a fragment:
Alert altOk = new Alert("Save","New settings saved.",null,AlertType.INFO);
altOk.setTimeout(3500);
display.setCurrent(altOk);
showMainMenu();
Thanks in advance for any help!

Yap...that's because you encapsulate the display.setCurrent(menu) in the showMain() function.
In fact, I encapsulate both setCurrent(new Alert(the correct parameters)) in the showAlert function. In doesn't make sense in the way you should show the alert after main but that's the way it is. IF someone out there know the reason, I would like to know as well...But my guess is because the Alert is subclass of Screen which is more lighter that Displayable object....so you have to put the Displayable initially. Tha analogy is the same as when you use the Swing libraries. IF you want to add menubar, you have to put the menubar on the frame then show the frame at the end(hence, Frame is heavier than menubar)....
Hope you'd tested the code.....
cheers....

Similar Messages

  • A simple problem with sateful Session beans

    Hi,
    I have a really novice problem with stateful session bean in Java EE 5.
    I have written a simple session bean which has a counter inside it and every time a client call this bean it must increment the count value and return it back.
    I have also created a simple servlet to call this session bean.
    Everything seemed fine I opened a firefox window and tried to load the page, the counter incremented from 1 to 3 for the 3 times that I reloaded the page then I opened an IE window (which I think is actually a new client) but the page counter started from 4 not 1 for the new client and it means that the new client has access to the old client session bean.
    Am I missing anything here???
    Isn�t it the way that a stateful session bean must react?
    This is my stateful session bean source.
    package test;
    import javax.ejb.Stateful;
    @Stateful
    public class SecondSessionBean implements SecondSessionRemote
    private int cnt;
    /** Creates a new instance of SecondSessionBean */
    public SecondSessionBean ()
    cnt=1;
    public int getCnt()
    return cnt++;
    And this is my simple client site servlet
    package rezaServlets;
    import java.io.*;
    import java.net.*;
    import javax.ejb.EJB;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import test.SecondSessionRemote;
    public class main extends HttpServlet
    @EJB
    private SecondSessionRemote secondSessionBean;
    protected void processRequest (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    response.setContentType ("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter ();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet main</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Our count is " + Integer.toString (secondSessionBean.getCnt ()) + "</h1>");
    out.println("</body>");
    out.println("</html>");
    out.close ();
    protected void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest (request, response);
    protected void doPost (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest (request, response);
    }

    You are injecting a reference to a stateful session bean to an instance variable in the servlet. This bean instance is shared by all servlet request, and that's why you are seeing this odd behavior.
    You can use type-leve injection for the stateful bean, and then lookup the bean inside your request-processing method. You may also save this bean ref in HttpSession.
    @EJB(name="ejb/foo", beanName="SecondBean", beanInterface="com.foo.foo.SecondBeanRemote")
    public MyServlet extends HttpServlet {
    ic.lookup("java:comp/env/ejb/foo");
    }

  • Problems with email alerts in OEM ( 10g )

    Gurus,
    I have setup the notification for the listener availability and I am having problems with getting the emails when the listener is down. I manually tested the setup by stopping the listener from the command prompt on the server and I don't see any email alerts, but the email alerts come after the listener is started back again from the prompt. I am interested in seeing the alerts when the listener goes down, any info on this is appreciated.
    Thanks.

    Thanks for your response. I have selected "yes" for both Up and down in your alert setup and still no luck. I did check the field where it says about sending email. Again when I stopped the listener alert didn't fired up, but it fired up after starting the listener.

  • Why my N900 has a problem with beeps/alert sounds!...

    I have a weird problem with my N900 and the alert sounds.
    They seem to stutter or not sound smoothly as if something is slowing them.
    It happens on message alerts, email, sms and camera shutter etc.
    Difficult to describe. I am not technical but it almost seems like it can't keep up maybe the CPU or memory???
    Had the problem before and after PR1.2..
    Also noticed stutter/pausing on media player as per this clip below from another user.
    http://www.youtube.com/watch?v=IKd7Gko2dak
    Searched discussion and can't see a topic but have read someone else mentioning something similar once.

    You may have to see about exchanging that MacBook/Pro for another before time runs out, and hope the replacement does not have this issue; and if you have access to an Apple Store with Genius, you may be able to get an appointment to discuss this issue and the exchange prospect, if it comes to that before 14 days from purchase date go by.
    I've looked a little and seen a few different problems with some of the hardware you have, but not the same issue with the green color, etc. Do you have a different external display device to see if the color is due to the internal graphics hardware in the MacBookPro retina?
    Hopefully you can get an answer in this matter.
    Good luck & happy computing!

  • Simple problem with transitions

    Hi everyone
    I am having a small bit of a problem with transitions....
    When I drag a clip from the viewer over the canvas to get the menu bar pop up, and select insert with transition ( cross dissolve ) it puts in a transition but its very short and too fast and when i select it and try to make adjustments it doesn't seem to let me make any changes to the cross dissolve.
    I wander what i am doing wrong?
    Many thanks Tim

    Hi
    Just as David Harbsmeier indicates. Handles
    Transitions are handled differently in iMovie resp FinalCut.
    • iMovie - material that builds the transition is taken from the videoclips = the total length remains same
    • FinalCut (as pro- works) . You have to set of a piece of material in each end of the video clips.
    This is called In- resp. Out-points. The remaining parts are called Handles
    Transitions here are using material from these = Total lenght of movie increase
    per transition.
    I find books/DVDs by Tom Wolsky - Very valubale - Enjoyed them very much.
    • Final Cut Express 4
    • Final Cut Pro 6 - DVD course (now probably version 7)
    Yours Bengt W

  • Simple problem with input

    hi!
    i've a problem with user input in my application:
    Code:
    BufferedReader F_reader = new BufferedReader (new InputStreamReader(System.in));
    Fs_line = F_reader.readLine();
    My problem is that i've to press the return key for two times, before the JDK returns the line! Does anybody know a better solution with JDK 1.4.2?
    thanks for help
    mike

    it was a mistake of our own implementation! code ist correct! any circumstances are our eval!
    thanks mike

  • Simple problem with a list initialization.

    hello ! i have a class Contact and i would like to make a list of lists of Contact variables .. but when i try to run my code , it says "IndexOutOfBoundsException: Index: 0, Size: 0" . I know that every list of the list must be initialized .. but i don't know how .
    here is the declaration of the List
    static  List<List<Contact>> lolContact=new ArrayList<List<Contact>>();and i know that i should do something like :
    lolContact.get(0)=new ArrayList<Contact>();to initialize every list of the list but i don't know how . please help

    badescuga wrote:
    and i know that i should do something like :
    lolContact.get(0)=new ArrayList<Contact>();
    Couple of problems with that.
    1. You can never do methodCall() = something in Java. The result of a method call is not an L-value.
    2. You're trying to assign a ContactList to a Contact variable. Basically, you're trying to do
    Contact c = new ArrayList<Contact>();3. Even if you changed it to
    Contact c = lolContact.get(0);
    c = new Contact();it would not put anything into the list. That would just copy the first reference in the list and stick it into variable c, so that both c and the first list item point to the same object (remember, the list contains references, not objects--no object or data structure ever contains an object in Java), and then assigns a completely different reference to c, forgetting about the one to the object pointed to by the list. It would not affect the list in any way.
    4. You can't do get(0) until you've first put something into the list.

  • Probably simple problem with while loops

    I was programming something for a CS class and came across a problem I can't explain with while loops. The condition for the loop is true, but the loop doesn't continue; it terminates after executing once. The actual program was bigger than this, but I isolated my problem to a short loop:
    import java.util.Scanner;
    public class ok {
    public static void main(String[] args){
         Scanner scan = new Scanner(System.in);
         String antlol = "p";
         while(antlol == "p" || antlol == "P"){
              System.out.println("write a P so we can get this over with");
              antlol = scan.nextLine(); 
    //it terminates after this, even if I type "P", which should make the while condition true.
    }

    Thanks, that worked.
    I think my real problem with this program was my CS
    teacher, who never covered how to compare strings,Here's something important.
    This isn't just about comparing Strings. This applies to comparing ANY objects. When you use == that compares to see if two references refer to the same instance. equals compares objects for equality in the sense that equality means they have equal "content" as it were.

  • Problems with the alerts

    Hi to all.
    I have this problem:
    I need to know If exists any way, for don't close the alert with the "X", locate in the upper rigth corner.
    If I close the alert with this th application runs wrong.
    The application runs in a web.
    I anybody have any solution, say me that.
    Thanx in advance

    Oscar,
    There is no property to disable the "X" window close button. But you can write a piece of code to force the user to select one of the buttons in the alert. The example
    below assumes that the alert has two buttons.
    Declare
    alert_rtn number;
    Begin
    loop
    alert_rtn := Show_alert('ALERT_XXX');
    if (alert_rtn = ALERT_BUTTON1 or
    alert_rtn = ALERT_BUTTON2) then
    exit;
    end if;
    end loop;
    End;
    This piece of code will show the alert always until one of the buttons is chosen. This is kind of a workaround. Hope this helps.
    null

  • Problem with PIN alerts in holster

    After upgrading to OS 5.0 on US Cellular (same as Sprint OS 5.0), my profiles seemed to be "Fixed" from OS 4.7 problems.  However I have come to realize I don't get alerts in holster for PIN messages now.  Every other alert works great.  Vibrate or sound so work out of holster.  I phoned tech support who said the in holster alert issues are "known" for the Tour.  If so, when may there be a RIM fix? 

    Do you have an endpoint for the service. To enable endpoint monitoring, go to the
    dashboard page for the associated resource and edit the
    Endpoints setting in the
    monitoring section, see figure 1. If you have an endpoint, try disabling and enabling the alert in the management tab.
    figure 1.
    Johnny Coleman [MSFT] Any code posted to this Forum is [As-Is] With No Warranties

  • Problem with PC Alert

    I have MSI BX Master motherboard and under
    Win 98 PA Alert worked just fine but now under WIN XP professional this program is not working I got massage
    that there is not hardware monitoring chipset present
    on my board.I downloaded the last version of program and he is stil not working.

    I don't run any of 'those' monitoring programs. I find that they use resources and by the time you are alerted to a problem it generally is too late.
    If I remember correctly (from the 'old' forum) PC Alert does not work with XP, not the 'new' version, not the 'old' version.
    Hopefully someone will pass by with a bit more info.......

  • Strange problem with AAM, Alerts, and custom app

    Hello
    We have a custom app written by an outside vendor. There is a function of the app called merge that basically takes a template in a document library and is supposed to make a copy for editing. The function only works if the Default AAM is the internal server
    name http://server1. However the alerts email links show the same thing so they do not work from outside of the network. If the default AAM is changed to the Internet URL http://sharepoint.domain.com the merge fails with error "error is The remote server
    returned an error: (401) Unauthorized., url is http://sharepoint.domain.com/prm/Document Library/Templates/Test co.docx." And the alerts are correct. 
    Of course the vendor says it is not their issue. Anyone able to give me some ideas? Can the Alert Template be changed to come from other than the default AAM value?
    Thanks

    the error ("401 unauthorized") is likely due to a LoopbackCheck.
    You cannot change the email message, alerts always use default AAM.
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • A problem with email alerts in management services of Azure portal

    Hi,
    I have created an alert with email notification on a custom performance counter using the management services of Azure portal.
    Currently the alert is in active state (and has been so for several hours), but i haven't received any email.
    Can someone please advise on this issue?
    Thanks,
    Roi

    Do you have an endpoint for the service. To enable endpoint monitoring, go to the
    dashboard page for the associated resource and edit the
    Endpoints setting in the
    monitoring section, see figure 1. If you have an endpoint, try disabling and enabling the alert in the management tab.
    figure 1.
    Johnny Coleman [MSFT] Any code posted to this Forum is [As-Is] With No Warranties

  • Simple problem with triggers

    Hi all,
    Initially I have written a trigger for testing .But im not able to write it as per the requirement.Actually I have written the trigger for a table "test" when a row is inserted into it then my trigger will insert a row in another table.In the same way if an row is UPDATED then that same field of the same row is to be updated in another table.how can I do this by modifying this trigger code.Im in a confusion of doing this.
    Table: test.
    Name Null? Type
    ID NOT NULL NUMBER(38)
    UNAME VARCHAR2(15)
    PWD VARCHAR2(10)
    Table : test123.
    Name Null? Type
    ID NUMBER
    UNAME VARCHAR2(30)
    PWD VARCHAR2(30)
    the trigger is as follows:
    CREATE OR REPLACE TRIGGER inst_trigger
    AFTER INSERT OR UPDATE
    ON test
    FOR EACH ROW
    DECLARE
         id number;
         uname varchar2(20);
         pwd varchar2(20);
    BEGIN
         id := 1245;
         uname :='abc';
         pwd := 'xyz';
         IF INSERTING THEN
    INSERT INTO test123 VALUES (id,uname,pwd);
         END IF;
    END test_trigger;
    how can i modify this for the above mentioned use.
    Thanks in advance,
    Trinath Somanchi,
    Hyderabad.

    Hallo,
    naturally , you have not assign values directly in trigger. They come automatically
    in trigger with :new - variables.
    CREATE OR REPLACE TRIGGER scott.inst_trigger
    AFTER INSERT OR UPDATE
    ON scott.test
    FOR EACH ROW
    BEGIN
    IF INSERTING THEN
    INSERT INTO scott.test123 VALUES (:new.id,:new.uname,:new.pwd);
    ELSE
    UPDATE scott.test123
    set uname = :new.uname, pwd = :new.pwd
    where id = :new.id;
    END IF;
    END inst_trigger;Nicolas, yes, merge here is very effective, but i think, that OP can starts with simpler version von "upsert".
    Regards
    Dmytro

  • Simple problem with popup message before adding document on system form

    Hi all,
    We have an AddOn that validates price lines on system Sales Order form matrix, so that if prices fall below a certain value, a popup is show to ask to continue or not, when user presses ADD button.
    The problem is that if he chooses yes (to continue), the Sales Order is not added since the button ADD keeps being selected ....
    Here is my code:
            [B1Listener(BoEventTypes.et_CLICK, true)]
            public virtual bool OnBeforeClick(ItemEvent pVal)
                int iResult = B1Connections.theAppl.MessageBox("Price lines fall bellow minimum! Continue?", 1, "NO", "YES", "");
                if (iResult == 1) // NO
                    // Show error
                    B1Connections.theAppl.StatusBar.SetText("OK", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                    return false;
                // YES: Continue to add Sales Order
                return true;
    The problem is somehow related with the popup message being shown: if user says YES to continue, the system form does not continue with the standard process of adding the Sales Order (when I move the cursor above the ADD button is shows it already pressed...).
    Do I have to do anything more to force the process to continue, when the user says YES?
    Regards,
    Manuel Dias

    Thtas known problem. The solution for this is declare global variable as boolean, when user selects Yes, then set this variable to true and emulate click to add button again where before the message box check if its varaible sets to true - in this case dont show message box, only set variable to false.
    The concept of code will be
    dim continue as boolean = false
    in item event
    if continue = false then
        x = messagebox...
      if x = 1 then
        continue = true
         items.item("1").click
    end if
    else
    continue = false
    end if

Maybe you are looking for