Wait for a return code in a Macro

Hello,
I have a macro in 7.5 that submits data and then waits for a return code before moving to the new step in the macro.   I have changed the sumit code to the new EPM standard, but the macro fails at the Get Events step which is where the macro waits for the return code.  The Fail message is  "Error 1004-cannot run "Get Events". Macro may not be available in this workbook or all macros are diabled."
My current code is:
           Dim submitrefresh As New EPMAddInAutomation
           submitrefresh.SaveWorksheetData 
          ' Application.Run "MNU_ESUBMIT_REFRESH"
'wait for the return code from the server to know the first send completed
           Dim oExcel As Object
        Set oExcel = Application.Run("GetEvents")
            Do
            DoEvents
                    Loop While oExcel.SendResult_Status = False And oExcel.SendResult_Submitted <> -1
                    'MsgBox "Send completed on server"
Does anyone know or have the code to fix or replace this code?   I need to get a return code from the send.
Thanks

Hi Debra,
SaveWorksheetData  - is synchronous method. You don't need to wait ... the next line after  SaveWorksheetData  will be executed only after save is finished.
Vadim

Similar Messages

  • Silent install for patch release 3 waiting for carriage return

    I'm trying to get Patch Release 3 (to take my 10.2.0.1.0 installtion to 10.2.0.4.0 on Linux RHEL 5/x64) to install using a ResponseFile so it can be scriptable.
    The actual silent install works fine - the problem lies with the patch install - it waits for the carriage return to be pressed oce it has been installed. And since its waiting for the Return key to be pressed, the script hangs.
    The command I'm running is
    +/oracle/staging/10g/patch/Disk1/runInstaller -ignoreSysPrereqs -silent -responseFile /oracle/staging/10g/patch.rsp << EOF+
    EOF
    I'm not even sure where to start looking to solve this issue.
    Can anyone point me in the right direction please...

    Hi;
    Did you follow patch 8.2 Installing the Oracle Database 10g Patch Set Noninteractively part?
    Also see:
    ERROR:Oracle 10.2.0.4 Patch Set Return Exit Code -1073741819 [ID 779582.1]
    OUI reports a successful silent install when errors are present [ID 793510.1]
    Regard
    Helios

  • Wait for InvokeProcess return values

    Hi,
    I am executing powershell script using InvokeProcess activity. This script has some MSBuild activity like compiling visual studio solution and creating installer. This will take some time. I am invoking  like below from PowerShell script.
    $msbuild ="${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild.exe"
    $Args = " installer.targets " + "/target:Installer " + "/p:Version=$Version"
    Start-Process $msbuild -ArgumentList @($Args)
    How do I wait for InvokeProcess to complete shell script execution and how do I know if that shell script has some errors while executing?

    Hi,
    Thanks for your reply. I have executed InvokeProcess in TFS build. There is a XCOPY activity after InvokeProcess activity. XCOPY copies the file which is generated in InvokeProcess activity. XCOPY returned status code 4. But after build process completed,
    I can see that file exists in the source location.I have executed scripts as well on build agent which executes without error.
    Here is the log:
    Run Post-build script00:00:03
    Inputs
    EnvironmentVariables:
    OutputEncoding: System.Text.SBCSCodePageEncoding
    Arguments: "& 'd:\Builds\8\IR_Addin\test\src\Main\Scripts\PostBuildScript.ps1' -Version "1.0.10.0""
    FileName: PowerShell
    WorkingDirectory:
    Outputs
    Result: 0
    PowerShell "& 'd:\Builds\8\IR_Addin\test\src\Main\Scripts\PostBuildScript.ps1' -Version "1.0.10.0""
    Copy MSI file00:00:00
    Inputs
    EnvironmentVariables:
    OutputEncoding: System.Text.SBCSCodePageEncoding
    Arguments: "d:\Builds\8\IR_Addin\test\src\Main\Build\test.msi" "d:\Builds\8\IR_Addin\test\bin"
    FileName: xcopy
    WorkingDirectory:
    Outputs
    Result: 4
    xcopy "d:\Builds\8\IR_Addin\test\src\Main\Build\test.msi" "d:\Builds\8\IR_Addin\test\bin"

  • Table name for Transports return code

    Hi Floks,
    I have 400 transports list and they have recently to traget system.
    I need to know how many are ended with returncode 8.
    Is there any table where i can know the return codes of the transports?
    Regards
    Srini

    Goto STMS -- click on Import Overview (truck symbol) -- double click on your system --- it displays all the transport requests -- select heading of the status column -- click on filter button on the tool bar -- select the required status -- execute.
    Hope it satisfies your requirement.
    Veerendra.

  • We are waiting for liberate iphone code

    HELLO I HAVE PROBLEMS TO SYNC MY IPHONE WITH MY ID , MY CELL COMPANY IN SPAIN TOLD ME THAT THEY ASK TO APPLE TO SET FREE THIS IMEI ******, SO I AM CONNECTING A FEW TIMES A DAY TO ITUNES, TRYING TO UNLOCK MY IPHONE TO USE IT WITH A DIFFERENT SIM FROM A DIFFERENT CELL COMPANY, BUT I VE BEEN A WEEK DOING IT FORM MONDAY AND STILL THE SAME WONT WORK, SO I DO NOT KNOW WHAT TO DO, I RESET ITUNES FROM MY LAPTOP AND REINSTALLED AGAIN THIS MORNING BUT NOW IS EVEN WORST I CONNECT MY IPHONE AND I DOES NOT APPEAR ON ITUNES, SO I CHECK CONECTIONS AND IT SAYS THERE IS A PROBLEM....SO I REALLY DO NOT KNOW WHAT TO DO...
    <Edited By Host>

    First off, please turn off the caps lock. It makes it very difficult to read the post, and on the internet, it is considered shouting and rude.
    The carrier is the only one that can authorize an unlock, and once the send that information to Apple, it is generally processed quickly. For many carriers, the final step to unlock a device is to restore the device as new, not from a backup. At that point, you should receive a message in iTunes, Congratulations, your iPhone is unlocked.
    When you attempt to insert the SIM from a different company, what is the error you get, besides you saying it won't work? If you have removed and reinstalled iTunes, did you do it by following the steps in this support document? If not, then you could cause additional problems. Remove and reinstall iTunes and related software components for Windows Vista, Windows 7, or Windows 8 - Apple Support
    If this does not help, then contact the carrier again to have them check on the status of the unlock.

  • Still waiting for unlock code since 29th May

    I am still waiting for an unlocking code from EE.I first contacted them on 29th May, then 31st May then 16th June, then 26th June, then 13th July, then 15th July.Each time I have spoken to customer services they have appologised profusely and assured me that the unlock code would be fast tracked. The last 2 calls promised me the money would be deducted from my credit on my orange PAYG account within 72 hours and the unlock code would be sent via email in 24 hours afterwards.My phone is xperia ST261.It is second hand, given to me by a friend who upgraded his phone with EE.I have an Orange PAYG simcard which I've had for over 15 years. I still wish to use this but also use a Lebara simcard, which is why I want the phone unlocked.I topped up with £10 so that there is sufficient money to pay the fee.I have filled in 2 or 3 requests online as I had 2texts from EE saying they couldn't continue with the request and that I needed to visit page...blah blah, fill in online unlock request form (again)I have spoken to 6 customer service reps who have also submitted the request....I should know my IMEI number by heart now!I took reference numbers of a couple of the reps but the last one insisted I just had his name and if I didn't get the code within 72 hours to call back and ask for him.......yeah right.call centre ''can I speak to ****'' that's going to happen!I'm really fed up now. I have a lovely phone that I cant use with my Lebara simcard.I am currently in Spain so going into an EE shop is not possible.My account is UK registered as is my simcardI top up by debit card (UK)So I've now been waiting 36 working days.I feel like I'm just being wound up by the call centre people with them keep fobbing me off.Mary    

    Hi 
    Really sorry to hear you are having problems.
    Just to let you know I am looking into this for you.
    If possible could you please send me a Private Message with your IMEI and Mobile number.
    Thanks. 

  • Completion return code

    I am working on an integration piece where I have a vendor writen C program that uses a korn shell script to invoke different processes, one of which is java. Currently I call my java program within the shellscript. The shell script then waits for a completion code from the java program. Is there any way I can "fake out" the shell script, that is, execute my java program, but tell the shell script it is done before it really is. Sample of what I am doing is below, where I don't get a completion code back from java, until the thread finishes.
    Am new to java so any suggestions would be appreciated.
    class Page {
         public static void main(String [] args) {
              String strTo = args[0];
              String strFrom = args[1];
              String strMessage = args[2];
              PagingProcess3 pp1 = new PagingProcess3(strTo, strFrom, strMessage);
              pp1.start();
    }

    Is there any way I can "fake out" the shell script, that is, execute my
    java program, but tell the shell script it is done before it really is.I don't think so...
    But you could try spawning a new process with Runtime.exec for the Java - that is, start the program right from the beginning with a new instance of the JVM - and then calling System.exit to end the current process. This is not faking: the process really ends and returns the code you define.
    the code could go like
    public class StartRealAppInANewJVM {
      public static void main(String[] args) {
        int exitCode=0;
        try {
            Runtime.getRuntime().exec("java RealApp");
        } catch (Exception e) {
            e.printStackTrace();
            exitCode=-1;
        System.exit(exitCode);
    }

  • CSM HTTP return code checking

    Hey again.
    I have been looking into the CSM return code checking feature as suggested by this forum. This is a little closer to what I am looking for but I have question about what happens when there is a failure.
    If a 500 code for HTTP is seen three times, for example, and the server is removed from the farm, is the original request from the client tried on the next server? Or is a reset sent back to the client, or the original code, and the client must try again.
    I am trying to understand if the client will notice if the CSM noticed X number of a particular error and removed the server from the farm.
    Thanks for any help!
    /ahuffer/

    I think you are mixing two things up(Inband health monitoring & HTTP return code checking).
    The "Inband health monitoring" feature checks for both RSTs from a server and the failure of the server to respond to a SYN. If a SYN ACK response to a SYN is not received,the TCP portion of the code will perform several retries of a SYN before timing it out.
    It is configured as follows
    CSM(config-module-csm)# serverfarm xyz
    CSM(config-slb-sfarm)# health retries 10 failed 50
    (Retries are the number of abnormal end sessions that the CSM will tolerate before removing a real server from service. The failed time is the number of seconds that the CSM waits before reattempting a connection to a real server that was removed from service by inband health checking.)
    "HTTP Return Code checking" is the CSM feature that can be configured to take a server out of use in response to receiving specific return codes.
    When HTTP return code checking is configured, the CSM monitors HTTP responses from all balanced HTTP connections and logs the occurrence of the return code for each real server. The CSM stores return code counts. When a threshold for a return code is reached, the CSM may send syslog messages or remove the server from service.
    Unlike "Inband Health monitoring", "Http Return code checking" feature has a small (estimated in 10-15%) impact on CPS setup rate, since it requires parsing L5 information in the server-to-client direction.
    If the server is taken out of service, Client's request will be loadbalanced among available servers.
    Syed
    Syed

  • Waiting for approval email during sign up procedure

    We are waiting for the return mail before we can download Publisher. We have waited 48 hours now. Is the only option to wait? is it possible to contact any? /Jesper

    Hi Frustrated4ever,
    If you had accessed Adobe related services previously with the old email it may be pulling the information for that account from browser cookie info stored on your system. An easy way to clear this out is to use the Cleaner Tool, within the tool is an option to remove Adobe ID info.
    Here is a link to the tool:
    http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html
    Here is a screen shot of the option:
    - Dave

  • How to generate the return code automatically through EP

    Hello all,
               I have created a transaction Iview and i am calling transaction SE16 to which i am passing application parameter as the table name which i want to see.Now i am getting the SE16 screen with the table name successfully passed on to the input field. But i want the Iview to process this screen also so that i dont have to press enter to see the next screen. i want this iview to process the SE16 screen directly and show me the next screen. I dont know how can i pass the return code parameter which will directly execute the table name entered in SE16 screen.suppose my table name is "ABC" and i have set the application parameter as DATABROWSE-TABLENAME=ABC&~okcode=ANZE where ANZE is the sy-ucomm value.Plz reply at the earliest.
    Thanks and regards,
    Alpa Desai.

    Madden wrote:
    I do think OOP can only complement procedural programming,Wrong. They don't have to have anything to do with each other.
    but I just wish for my app to exit the same way whether I return or not an exit code.
    I mean we are talking about the implementation, or the system, here.
    Simply let it end and the "return code" will be 0.
    But ... is there a way for a Java application to execute another Java application ? The analog for CreateProcess, but in the Java world ?Start a thread and call the main method of the class that kicks it off with the necessary arguements is one way.
    When an Java app executes another Java app will a new VM be created ?Runtime.getRuntime().exec() and call java ...... Which will, obviously, start a new VM.
    Is ther an internal way, for this that will work inside the same VM ?See the thread situation above.
    How will the parent get the exit code from the child ?If called with Runtime simply call System.exit and then (from the original program) evaluate the return code (see the Runtime and Process classes).
    If called in a thread, without using Runtime.exec any where, then you use a return at the end of the main method, but, if you are looking for a "return code" from an entire application, you're probably looking at Runtime.exec anyway. Otherwise, you are better of writing it so that it can be used in a real OOP manner (i.e. you don't have to call the main method of another application at all, you simply start instantiating and using the classes involved), in which case, a "return code" from the "application" is meaningless.
    >
    Timothy Madden,
    RomaniaEdited by: masijade. on Nov 19, 2007 10:18 AM

  • Return code in trace file from ST01

    Hello All,
    Does anybody know what are the values for the return code (0,4,8,12,16) in an trace file from ST01 ?
    Thanks you All !

    seems that you are very bored during the day ....
    The ST01 displays the raw data for the ST05, that is something which you will never in normal life. Return codes are also displayed in ST05, but even there you don't really need them.
    If you ask this question here in the performance forum then I would definitely advise you to switch to the condensed form of the ST05
    (SQL statement summary) see here:
    SQL trace:
    /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
    This condensed forum shows you all the information whioch you need for about 90% of your work.
    kind regads       Siegfried

  • C Function - SSF_ABAP_SERVICE - Problem in return code.

    Hi all,
    We are actually executing a custom program with standard FM - CCARD_DEVELOPE which does a decryption of credit card number. This FM inturn calls another FM SSF_KRN_DEVELOPE which inturn calls C function SSF_ABAP_SERVICE.
    It is working fine in Development server. But it is not working in quality.
    Please find the C function below.
    In Dev, for CRC(return code) we are getting '0'. So it is working fine. But in Quality, we are getting CRC ='9'. Because of this, decryption is not happening. Please let me know, what could be the problem, if it could be because of SAP authorization or any third party software to be installed for validation or anything else.
    call C function 'SSFDEVELOPE'
    CALL 'SSF_ABAP_SERVICE'
    ID 'OPCODE' FIELD SSF_OPCODES-DEVELOPE
    ID 'SECTOOLKIT' FIELD SSFTOOLKIT
    ID 'STRFORMAT' FIELD STR_FORMAT
    ID 'STRFORMATL' FIELD STR_FORMAT_L
    ID 'BOUTDEC' FIELD B_OUTDEC
    ID 'IOSPEC' FIELD IO_SPEC
    ID 'OSTRENVELOPEDDATAL' FIELD OSTR_ENVELOPED_DATA_L
    ID 'OSTROUTPUTDATAL' FIELD OSTR_OUTPUT_DATA_L
    ID 'CRC' FIELD CRC
    ID 'OSTRENVELOPEDDATA' FIELD OSTR_ENVELOPED_DATA-SYS
    ID 'RECIPIENT' FIELD RCPTAB-SYS
    ID 'OSTROUTPUTDATA' FIELD OSTR_OUTPUT_DATA-SYS

    Hi Balaji!
    It can't be something in the source code - that is the part which is identical in both systems (but please check your program version).
    What's different is the surrounding. In theory it could be wrong master data ('credit card not found'), but this is unlikely for this function.
    But you need also some connection settings - here something wasn't defined for quality system. Have a look in SM59 (and according, don't ask me for details), if connections settings are alright.
    Regards,
    Christian

  • Getting a JFrame to display  from a JSP, remaining JSP code waits for frame

    Hello,
    I'm new to Java and just started using JSPs. My objective is to call a display window (from a JSP) that shows the user a list of project selections. Once the user has made their selections and clicked a Submit button, the display class captures the selected projects to the request object as an attribute and then closes the window. The next command in the jsp then forwards the request attribute to a controller. I'm having trouble getting the display window to show-the JSP seems to hang and then timeout. Is there code I'm missing to get the JSP to stop processing while it waits for the choices to be made in the JFrame?
    Below is the JSP code and the class I'm calling. I'm seeing all my debug System.out statements but no JFrame pops up. In the JFrame class, the line f.addWindowListener(... does the capture of user selections to the request attribute.
    Any help will be greatly appreciated!!
    JSP:
    <%@ page language="java" contentType="text/html;charset=UTF-8" import="com.plumtree.remote.portlet.*,edu.app.projects.*" %>
    <%
        request.setAttribute("action", "prefDisplay");
        request.setAttribute("orderby", "title");
        ServletContext jc = getServletContext();
        DualListBox dual = new DualListBox(request,(String)jc.getAttribute("db.driver"), (String)jc.getAttribute("db.connectionstring"),"title");
         JFrame f = dual.getFrame();
         f.setVisible(true);//expect code to stop here and display frame, waiting for the user to finish.
            //Debug code that tests if frame is visible at this point -came true though did not see Jframe displayed
         if(f.isShowing()){
         System.out.println("Jframe visible");}
           //Send to ProjectsController
          request.getRequestDispatcher("pc").forward(request, response);%>               ---------------------------------------------------------------------------------------------
    JFrame Class (below)
    -Sets up Frame and corresponding Dialog box
    -Populates Dialog box with options from a database call (for user selection)
    -Should wait for user input - Window close or Submit! to capture selection and dispose of Jframe
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.EventQueue;
    import java.awt.Frame;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.lang.reflect.InvocationTargetException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.SortedSet;
    import java.util.TreeSet;
    import javax.servlet.http.HttpServletRequest;
    import javax.swing.AbstractListModel;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.ListCellRenderer;
    import javax.swing.ListModel;
    public class DualListBox extends JPanel {
      private static final long serialVersionUID = 1L;
      private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
      private static final String ADD_BUTTON_LABEL = "Add >>";
      private static final String REMOVE_BUTTON_LABEL = "<< Remove";
      private static final String DONE_BUTTON_LABEL = "Submit!";
      private static final String DEFAULT_SOURCE_CHOICE_LABEL = "Available Projects";
      private static final String DEFAULT_DEST_CHOICE_LABEL = "Your Selections";
      private String orderby, mydriver, connectionString;
      private JLabel sourceLabel;
      private JList sourceList;
      private SortedListModel sourceListModel;
      private JList destList;
      private String chosenprojects;
      private SortedListModel destListModel;
      private JLabel destLabel;
      private JButton addButton;
      private JButton removeButton;
      private JButton doneButton;
      private DatabaseHelper dh;
      protected HttpServletRequest request;
      protected JFrame f;
      protected JDialog jd;
      public DualListBox(HttpServletRequest req, String driver, String connection, String ordering) {
         System.out.println("In DualList Setup");
        request =req;
         orderby =ordering;
         connectionString = connection;
         mydriver = driver;
         f = new JFrame("Projects List Selector");     
         jd =new JDialog(f,true);
         jd.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         System.out.println("B4 initscreen");
        initScreen();
        System.out.println("After initscreen");
        String[] DBprojects = this.dbCall();
        System.out.println("After DB Call");
        this.addSourceElements( DBprojects );   
        System.out.println("Filled screen");
        jd.getContentPane().add(this, BorderLayout.CENTER);
        //f.getContentPane().add(jd, BorderLayout.CENTER);
        jd.setSize(800, 600);
        System.out.println("OK2");
        jd.setVisible(true);
        System.out.println("OK3");
        Runnable runner = new FrameShower(jd);
        EventQueue.invokeLater(runner);
      public String getSourceChoicesTitle() {
        return sourceLabel.getText();
      public String chosenprojects() {
             return chosenprojects;
      public JFrame getFrame() {
             return f;
      public void setSourceChoicesTitle(String newValue) {
        sourceLabel.setText(newValue);
      public String getDestinationChoicesTitle() {
        return destLabel.getText();
      public void setDestinationChoicesTitle(String newValue) {
        destLabel.setText(newValue);
      public void clearSourceListModel() {
        sourceListModel.clear();
      public void clearDestinationListModel() {
        destListModel.clear();
      public void addSourceElements(ListModel newValue) {
        fillListModel(sourceListModel, newValue);
      public void setSourceElements(ListModel newValue) {
        clearSourceListModel();
        addSourceElements(newValue);
      public void addDestinationElements(ListModel newValue) {
        fillListModel(destListModel, newValue);
      private String[] dbCall(){
             if(dh==null)
                  dh = new DatabaseHelper(mydriver, connectionString);
              PreparedStatement ps = null;
              ResultSet rs = null;
              ArrayList<String>children = new ArrayList<String>();
              ArrayList<String[]>tree =new ArrayList<String[]>();
              if(orderby==null || orderby.equals("")){
                   orderby ="region";
              String query = "select title,id from projects";// order by " + orderby;
              System.out.println(query);
              try {
                   Connection conn =dh.getConnection();
                   ps = conn.prepareStatement(query);
                   rs = ps.executeQuery();
                   while (rs.next()) {
                        children.add(new String(rs.getString(1)));
                        System.out.println(rs.getString(1));
                        tree.add(new String[]{rs.getString(1),rs.getString(2)});
                   request.setAttribute("ResultTree",tree);
                   return (String[])children.toArray(new String[children.size()]);
              } catch (SQLException e) {
                   throw new RuntimeException(e);
              } finally {
                   try {
                        if (null != rs) rs.close();
                   } catch (SQLException e) {
                   try {
                        if (null != ps) ps.close();
                   } catch (SQLException e) {
      private void fillListModel(SortedListModel model, ListModel newValues) {
        int size = newValues.getSize();
        for (int i = 0; i < size; i++) {
          model.add(newValues.getElementAt(i));
      public void addSourceElements(Object newValue[]) {
        fillListModel(sourceListModel, newValue);
      public void setSourceElements(Object newValue[]) {
        clearSourceListModel();
        addSourceElements(newValue);
      public void addDestinationElements(Object newValue[]) {
        fillListModel(destListModel, newValue);
      private void fillListModel(SortedListModel model, Object newValues[]) {
        model.addAll(newValues);
      public Iterator sourceIterator() {
        return sourceListModel.iterator();
      public Iterator destinationIterator() {
        return destListModel.iterator();
      public void setSourceCellRenderer(ListCellRenderer newValue) {
        sourceList.setCellRenderer(newValue);
      public ListCellRenderer getSourceCellRenderer() {
        return sourceList.getCellRenderer();
      public void setDestinationCellRenderer(ListCellRenderer newValue) {
        destList.setCellRenderer(newValue);
      public ListCellRenderer getDestinationCellRenderer() {
        return destList.getCellRenderer();
      public void setVisibleRowCount(int newValue) {
        sourceList.setVisibleRowCount(newValue);
        destList.setVisibleRowCount(newValue);
      public int getVisibleRowCount() {
        return sourceList.getVisibleRowCount();
      public void setSelectionBackground(Color newValue) {
        sourceList.setSelectionBackground(newValue);
        destList.setSelectionBackground(newValue);
      public Color getSelectionBackground() {
        return sourceList.getSelectionBackground();
      public void setSelectionForeground(Color newValue) {
        sourceList.setSelectionForeground(newValue);
        destList.setSelectionForeground(newValue);
      public Color getSelectionForeground() {
        return sourceList.getSelectionForeground();
      public String getProjects(){
           return chosenprojects;
      private void clearSourceSelected() {
        Object selected[] = sourceList.getSelectedValues();
        for (int i = selected.length - 1; i >= 0; --i) {
          sourceListModel.removeElement(selected);
    sourceList.getSelectionModel().clearSelection();
    private void clearDestinationSelected() {
    Object selected[] = destList.getSelectedValues();
    for (int i = selected.length - 1; i >= 0; --i) {
    destListModel.removeElement(selected[i]);
    destList.getSelectionModel().clearSelection();
    private void initScreen() {
    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new GridBagLayout());
    sourceLabel = new JLabel(DEFAULT_SOURCE_CHOICE_LABEL);
    sourceListModel = new SortedListModel();
    sourceList = new JList(sourceListModel);
    add(sourceLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
    GridBagConstraints.CENTER, GridBagConstraints.NONE,
    EMPTY_INSETS, 0, 0));
    add(new JScrollPane(sourceList), new GridBagConstraints(0, 1, 1, 5, .5,
    1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    EMPTY_INSETS, 0, 0));
    addButton = new JButton(ADD_BUTTON_LABEL);
    add(addButton, new GridBagConstraints(1, 2, 1, 2, 0, .25,
    GridBagConstraints.CENTER, GridBagConstraints.NONE,
    EMPTY_INSETS, 0, 0));
    addButton.addActionListener(new AddListener());
    removeButton = new JButton(REMOVE_BUTTON_LABEL);
    add(removeButton, new GridBagConstraints(1, 4, 1, 2, 0, .25,
    GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
    0, 5, 0, 5), 0, 0));
    removeButton.addActionListener(new RemoveListener());
    doneButton = new JButton(DONE_BUTTON_LABEL);
    add(doneButton, new GridBagConstraints(1, 6, 1, 2, 0, .25,
    GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
    0, 10, 0, 10), 0, 0));
    doneButton.addActionListener(new DoneListener());
    f.addWindowListener(new java.awt.event.WindowAdapter() {
         public void windowClosing(WindowEvent winEvt) {
              //could set to null here to force use of Done button only
         chosenprojects = destList.getSelectedValues().toString();
              request.setAttribute("ProjectIDs", destList.getSelectedValues().toString());
              System.exit(0);
    destLabel = new JLabel(DEFAULT_DEST_CHOICE_LABEL);
    destListModel = new SortedListModel();
    destList = new JList(destListModel);
    add(destLabel, new GridBagConstraints(2, 0, 1, 1, 0, 0,
    GridBagConstraints.CENTER, GridBagConstraints.NONE,
    EMPTY_INSETS, 0, 0));
    add(new JScrollPane(destList), new GridBagConstraints(2, 1, 1, 5, .5,
    1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    EMPTY_INSETS, 0, 0));
    private class AddListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    Object selected[] = sourceList.getSelectedValues();
    addDestinationElements(selected);
    clearSourceSelected();
    private class RemoveListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    Object selected[] = destList.getSelectedValues();
    addSourceElements(selected);
    clearDestinationSelected();
    private class DoneListener implements ActionListener {
         public void actionPerformed(ActionEvent e) {
         chosenprojects = destList.getSelectedValues().toString();
         request.setAttribute("ProjectIDs", destList.getSelectedValues().toString());
         System.exit(0);      
    class FrameShower implements Runnable {
         final JDialog frame;
         public FrameShower(JDialog frame) {
              this.frame = frame;
         public void run() {
              System.out.println("B4 make visible");
              frame.setVisible(true);          
         System.out.println("Made screen visible");
    class SortedListModel extends AbstractListModel {
    private static final long serialVersionUID = 8777627817685130496L;
    SortedSet model;
    public SortedListModel() {
    model = new TreeSet();
    public int getSize() {
    return model.size();
    public Object getElementAt(int index) {
    return model.toArray()[index];
    public void add(Object element) {
    if (model.add(element)) {
    fireContentsChanged(this, 0, getSize());
    public void addAll(Object elements[]) {
    Collection c = Arrays.asList(elements);
    model.addAll(c);
    fireContentsChanged(this, 0, getSize());
    public void clear() {
    model.clear();
    fireContentsChanged(this, 0, getSize());
    public boolean contains(Object element) {
    return model.contains(element);
    public Object firstElement() {
    return model.first();
    public Iterator iterator() {
    return model.iterator();
    public Object lastElement() {
    return model.last();
    public boolean removeElement(Object element) {
    boolean removed = model.remove(element);
    if (removed) {
    fireContentsChanged(this, 0, getSize());
    return removed;
    }{code}
    Edited by: redm14A on Oct 10, 2007 11:34 AM
    Edited by: redm14A on Oct 10, 2007 11:37 AM
    Edited by: redm14A on Oct 10, 2007 11:40 AM
    Edited by: redm14A on Oct 10, 2007 11:45 AM
    Edited by: redm14A on Oct 10, 2007 11:47 AM

    redm14A wrote:
    Hmm, I was trying to avoid writing an applet. Seems my only other option then is to write a JSP that returns a javascript menu populated by options from a database call. Then I'd have the user click submit to send the options to another JSP that simply sets the request attribute and forwards to the controller. Will this be a sound alternative?
    Edited by: redm14A on Oct 10, 2007 12:29 PMSounds good to me.

  • Pause program code and wait for window deactivation

    I have the following code. I need the frame to show then the code to pause until the frame is deactivated.
    The problem is that the frame is shown but only the backgound and its contents are not shown and since the while loop waits for a deactivation it goes into an endless loop. If I press the X on the frame it still does not close. I am guessing for some reason the compiler goes into the while loop before it completes the above task of showing the frame. Can you help me out with my problem?
    final viewMemRecordsFrame memframe = new viewMemRecordsFrame(ff);
    memframe.show();
    memframe.setLocation(80, 80);
    memframe.addWindowListener(new WindowAdapter()
    public void windowDeactivated(WindowEvent e)
    acctnumber = -1;
    memframe.dispose();
    public void windowActivated(WindowEvent e)
    Object waitObject = new Object();
    Thread waitThread = new Thread();
    waitThread.start();
    while(memframe.isVisible())
    try
    waitThread.sleep(200);
    catch(InterruptedException ie)
    waitThread.stop();
    ried the Thread.sleep(200) I had the same problem as above. The frame above the while loop shows but does not show the contents of the frame so an input can not be entered and the frame cannot be deactivated and it runs into an endless loop.

    You appear to have some confusion about threads. Your waitThread doesn't have any code to run, which means it will terminate as soon as you start it.
    "stop" is now depracated and there's really no need for it.
    I'm guessing that this piece of code is activated by some kind of GUI control, which would accont for your program hanging, since no other GUI control (e.g. the close box) can be serviced until an ActionPerfomed method or similar has finished.
    If you want a thread to wait for a window to close the appropriate syncrhonization methods are wait and notify, not sleep.
    For example override "dispose" in "viewMemrecords with:
    public void dispose() {
        synchronized(this) {   // grab the window as a monitor
              super.dispose();  // call the underlying dispose to close the window
              notifyAll();      // wake any waiting threads
       }Then the thread which is to wait does something like:
    syncrhonized(memframe) {
         while(memframe.isVisible())
              memframe.wait();
          }This should make the WindowListener unecessary.
    But [b[don't[/b] make code executed from an GUI action handler wait. GUI action handlers should always return promptly, creating a new Thread if any continuing action is required.

  • Execution flow doesn't wait for return values

    I have created JNI wrappers for existing dlls. However I'm getting weird behavior. My Java function calls a c function which communicates with an old mainframe. If I retrieve one row at a time its fine but if I do a loop the virtual machine crashes. Sometimes, if I add an empty loop for (30000 iterations) then its fine. Its like java is already trying to retrieve the next row while the first row is still being printed on my screen. I've tried adding synchronized in case the dlls where multi-threaded but it has not made a difference. Is there any way to control the execution flow so that it can't go to the next line until the values are truly returned from the c dll.
    thanks
    MA

    There are many function being called on the native side. Since I didn't want to modify the native side
    (because the old dlls are used by another application), I added my own dll as an intermediary between the old c dlls and the java side.
    To fix the problem I am having, I've heard of another project where the native side would write the returned values to a file and only once the file is written can the Java side continue. Is this the only way to control the execution flow?
    Right now I have about 5 empty loops which run to 100000 and things work most of the time. But I would prefer to find a way to say wait until the values are returned correctly.
    Essentially, what I'm doing is
    for (int i=1;i<10; i++){
       test.init(Integer.toString(i),Integer.toString(i),"english desc"+  Integer.toString(i),"french desc"+ Integer.toString(i));
       test.execute(test.ActionAdd);
    }This is supposed to add one row with four fields. I'm just putting junk for the test. If I call the two main lines
    test.init(Integer.toString(i),Integer.toString(i),"english desc"+  Integer.toString(i),"french desc"+ Integer.toString(i));
    test.execute(test.ActionAdd);just once it works fine but if I loop them then it crashes after a few loops. If I put a loop as shown below then it works fine. This is part of the code when I'm adding. Is it being looped 10 times from the code above.
    jsession.scanTable(table,errorlist);
                rtc = table.getRecordCount(errorlist);
                if (rtc > 0)
                publish(rtc+" records found.");
                    for(int i = 1; i <= rtc; ++i)
                        for (int j = 0; j < ElementName.size();j++)
                            publish((String)ElementName.get(j)+ ": " + table.getFieldByName((String)ElementName.get(j),i,errorlist));
                            for (int k = 0; k<100000;k++);
                else
                    publish("No records found.");
                }In the code, when the rows are added, I print them out just to make sure they were added correctly. This is where I got the idea that the Java code was not in synch with the native side because it would crash while writting out a line but it didn't happen every time at the same place.
    This is the function getFieldByName
    public String getFieldByName (String p_FieldName, int p_LineNum, ErrorList p_Errors)
              String retval = "";
              int ret;
              try
                   p_FieldName = prepareFieldName(p_FieldName);
                   retval = new String();
                   ret    = 0;
                   if (this.ptrTableView == NOT_SET)
                        p_Errors.addMessage(p_Errors.SEV_SYSTEM_ERROR(), "Table View Pointer not set");
                        throw (new Exception());
                   // allocating string buffer for value returned
                   StringBuffer m_FieldValue = new StringBuffer();
                   // determining length of value
                   int m_length[] = {0};
                   ret = gti.GetFieldLen(this.ptrTableView, p_FieldName, m_length, eb.getErrorBlockPtr());
                   if (m_length[0] == 0) m_length[0] = 100;
                   m_FieldValue = new StringBuffer(m_length[0]);
                   // get line field          
                   ret = gti.GetLineField(this.ptrTableView, p_FieldName, p_LineNum, m_FieldValue, eb.getErrorBlockPtr());           
                   if (ret != 0)
                          p_Errors.addMessage(p_Errors.SEV_ERROR(), "Error retrieving field value ("+p_FieldName+")");
                   else
                          retval = m_FieldValue.toString();
              catch (Throwable t)
                   p_Errors.addMessage(p_Errors.SEV_ERROR(), "Error retrieving field value ("+p_FieldName+")");
              return retval;
        }The main functions are
    GetFieldLen
    GetLineField
    They go to the native side through my dll which wraps the old dlls.
    Here are is one of the main functions in my dll. I also have the source for the functions they are calling but they are calling other functions which are calling other functions. There is a lot of code . Yes, they use arrays.
    JNIEXPORT jint JNICALL Java_advantagewrapperspk_GtiNative_GtiGetLineField
      (JNIEnv *env, jclass cls, jint p_tableViewPtr, jstring VIEWFIELDNAME, jint VIEWFIELDNUM, jobject VIEWFIELDVALUE, jint iErrBlockPtr)
           //printf("\n\nGtiGetLineField in C:\n");
           jint iResult = 0;
           char *temp1 = (*env)->GetStringUTFChars(env,VIEWFIELDNAME,0);
           char *temp2 = (*env)->GetStringUTFChars(env,VIEWFIELDVALUE,0);
         iResult = GtiGetLineField(p_tableViewPtr,temp1,VIEWFIELDNUM,temp2,iErrBlockPtr);
           //printf("VIEWFIELDNUM %d ",VIEWFIELDNUM);
           //printf("\ntemp1 %s ",temp1);
           //printf("\ntemp2 %s ",temp2);
         (*env)->ReleaseStringUTFChars(env,VIEWFIELDNAME,temp1);
         if (temp2 == 0)      return iResult;
        if (temp2 != NULL)
                cls = (*env)->GetObjectClass(env,VIEWFIELDVALUE);
                jmethodID mid = (*env)->GetMethodID (env,cls,"append","(Ljava/lang/String;)Ljava/lang/StringBuffer;");
                 if (mid == 0) return iResult;
                 jstring sfinal = (*env)->NewStringUTF (env, temp2);
                (*env)->CallObjectMethod(env,VIEWFIELDVALUE,mid,sfinal);
              if (VIEWFIELDVALUE != NULL) (*env)->ReleaseStringUTFChars(env,VIEWFIELDVALUE,temp2);
         //(*env)->ReleaseStringUTFChars(env,VIEWFIELDVALUE,temp2);
         return iResult;
      }This calls
    * Function Name : GtiGetLineField()
    * Description   : Retrieves the value of a line field in a table view
    * Parameters    : pTableViewPtr pTableView--the table view from which to
    *                                           retrieve the value of a line
    *                                           field
    *                 VIEWFIELDNAME szFieldName--the name of the line field
    *                                            whose value is returned
    *                 VIEWLINENUM iLineNum--number of line from which to retrieve
    *                                       field value.  Lines are numbered
    *                                       beginning with 1.
    *                 VIEWFIELDVALUE szFieldValue--returns the value of the
    *                                              line field
    *                 ErrBlockPtr sourceeb--error context info from calling
    *                                       function
    * Return values : int--returns RCT_RETURNOK, RCT_WARNCORECONNECT, or
    *                      RCT_FAILCORECONNECT
    * Modifications : REH - 05/25/93
    int GtiGetLineField ( TableViewPtr pTableView,
                          VIEWFIELDNAME szFieldName,
                          VIEWLINENUM iLineNum,
                          VIEWFIELDVALUE szFieldValue,
                          ErrBlockPtr sourceeb )
       int iRc ;      /* return code */
       ELOG_INIT( sourceeb,
                  "GtiGetLineField",
                  "retrieving the value of a line field in a table view" ) ;
       /* in Gti, we start numbering lines from 1, because that is the way a user
          sees them on the screen.  In Ldm, following C conventions, we start
          numbering lines at 0.  So in LdmSetField, we subtract 1 from iLineNum */
       iRc = LdmGetField( pTableView->pTran,
                          szFieldName,
                          szFieldValue,
                          iLineNum - 1,
                          0,                  /* map occurrence = 1 */
                          ELOG_ERRBLOCK ) ;
       /* in case Ldm returned a warning, indicate so to the calling function */
       iRc = ( iRc == LDM_RETURNOK ) ? RCT_RETURNOK : RCT_WARNCORECONNECT ;
       return( iRc ) ;
       /* if exception was raised, it was due to COREConnect */
       ELOG_END( RCT_FAILCORECONNECT ) ;
    }which calls
    /****************************** API Header *********************************\
    * API Name: LdmGetField
    * This function copies the string value of a specified FIELDNAME into a
    * buffer specified by FIELDVALUE.  The string is NULL terminated.
    * The first OCCUR determines which occurrence of the field in the map.
    * The second OCCUR determines which occurence of the map in the transaction
    * area.  Remember that occurrences are numbered like C arrays: a transaction
    * with ten occurrences of a field will have fields numbered zero through
    * nine.
    * It is assumed that FIELDVALUE has enough space to accommodate the field's
    * value.
    int LdmGetField( HTRAN       htran,
                     FIELDNAME   fieldname,
                     FIELDVALUE  fieldvalue,
                     FIELDOCCUR  fieldoccur,
                     MAPOCCUR    mapoccur,
                     ErrBlockPtr seb )
       ELOG_INIT ( seb, "LdmGetField", "getting transaction field value" ) ;
       if ( htran->Occurrence <= mapoccur ) {
          ElogFail1( LDM_FAILOCCNOTFOUND, htran->TranName ) ;
       }  /* END if. */
       /* Since 'blank' values for field or map occurrences are zero, there
          is no need to set a default. */
       LdmsGetField( htran->Map->CCMap,
                     htran->TranData,
                     fieldname,
                     fieldvalue,
                     fieldoccur,
                     mapoccur,
                     ELOG_ERRBLOCK ) ;
       return( LDM_RETURNOK ) ;
       ELOG_END ( ELOG_ERRBLOCK->Rc ) ;
    }  /* END LdmGetField. */which calls
    /****************************** API Header *********************************\
    * API Name: LdmsGetField
    * Put the value of FIELDNAME into FIELDVALUE.  The field must be an element
    * of the specified map.  The new value will be set in the specified data
    * buffer.  The occurrences refer to the occurrence of the field in the map
    * and the occurrence of the map in the data buffer.
    int LdmsGetField ( CCMapPtr    rcmap,
                       char        *dataarea,
                       FIELDNAME   fieldname,
                       FIELDVALUE  fieldvalue,
                       FIELDOCCUR  fieldoccur,
                       MAPOCCUR    mapoccur,
                       ErrBlockPtr seb )
       ElementPtr element ;
       char       *fieldoffset ;
       ELOG_INIT ( seb, "LdmsGetField", "getting a field of a map" ) ;
       /* Search the transaction definition area (map) for matching
          FIELDNAME. If found, copy FIELDVALUE to defined offset in
          transaction buffer. */
       element = LdmsFindField( rcmap, fieldname, fieldoccur, &localeb ) ;
       /* Copy the value from the transaction data area into FIELDVALUE. */
       fieldoffset = dataarea +
                     ( ( rcmap->BufferLength * mapoccur ) + element->Offset ) ;
       strncpy( fieldvalue, fieldoffset, element->Length ) ;
       fieldvalue[ element->Length ] = '\0' ;
       return( LDM_RETURNOK ) ;
       ELOG_END ( ELOG_ERRBLOCK->Rc ) ;
    }  /* END LdmsGetField. */and on it goes
    I gather from your question about arrays that they might be the source of the problem. Could it be that the pointer to the array is returned while the array is not completed? Any information would help. Thanks.

Maybe you are looking for