Event Handling - New Approach

Hi,
I have developed a BSP and implemented the way Brian described in the Apprach 3 of the weblog mentioned below. In the method of new class that handles the server event(method name is same as server event), How do I access the model instance that I used in my BSP?
BSP Programming: Handling HTMLB Events
/people/brian.mckellar/blog/2004/07/28/bsp-programming-handling-htmlb-events
Thanks,
Suresh

Brian it's Good Idea to create in Controller Class or creating event handling methods within the model class. But I would like to create s separate class just for Even handling alone, so that I can use wherever I want(in different BSP Applications).
1.I have created ZCL_EVENT_HANDLER_FORME.
2.Created Method HANDLE_MYBUTTONCLICK and passed
  event_object as a parameter.
3. I have ZCL_MY_CONTROLLER and ZCL_MODEL for BSP.
4. Created instance of ZCL_MODEL and assigned it to the Controller Attribute.
5. Successfully dispatced the event from DO_HANDLE_EVENT to HANDLE_MYBUTTONCLICK method of CL_EVENT_HANDLER_FORME.
6. I don't know how to get the reference to the model in
HANDLE_MYBUTTONCLICK method of CL_EVENT_HANDLER_FORME.
Am I missing some thing....
-Suresh

Similar Messages

  • Event handler if new File added in current folder

    Hi folks,
    I'm just trying to write a little jsx script for Bridge CS6.
    How can I implement an event handler that will react if the user adds a new thumbnail (new file) to the current folder in bridge.
    I've tested it with this code, but it doesn't work:
    app.document.thumbnail.watch ("children", function(id, oldVal, newVal) {
         $.writeln (oldVal + " to " + newVal);
         // some code here
    Thanks. Greetings

    Beautiful. Works as advertised. Thank you for pointing it out to me. Unfortunate that a basic subset of this extension's behaviour doesn't ship with Thunderbird out of the box, though.

  • New window in event handling

    hi to all
    i m beginner in java programming and i want to do event handling on mouse click. i have a button and i want if i click that button a new window open
    can anyone help me

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ActionEvents implements ActionListener
        JDialog dialog;
        public ActionEvents(JFrame f)
            dialog = new JDialog(f, "dialog");
            dialog.getContentPane().add(new JLabel("hello world", JLabel.CENTER));
            dialog.setSize(200,100);
            dialog.setLocation(425,200);
        public void actionPerformed(ActionEvent e)
            if(!dialog.isVisible())
                dialog.setVisible(true);
            else
                dialog.toFront();
        private JPanel getPanel()
            JButton button = new JButton("open dialog");
            button.addActionListener(this);
            JPanel panel = new JPanel();
            panel.add(button);
            return panel;
        public static void main(String[] args)
            JFrame f = new JFrame();
            ActionEvents ae = new ActionEvents(f);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(ae.getPanel(), "North");
            f.setSize(200,100);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • Opening a new window from an event handler in IC WebUI

    Hello ,
    I want to open a new browser window on the click of a button (through the event handler) .This can be done using javascript ,but I ideally want it to be triggered from the event handler .The URL is dynamically
    generated . Please do let me know if there are ways to achieve this .

    Hi,
    In the place where you declare your button write this code.
        ls_button-id = xx.
        lv_string1 = 'javascript:window.open( "'.
        lv_string2 = '" );'.
        ls_button-on_client_click = 'javascript:window.open( "lv_url");'
        CONCATENATE lv_string1
                    lv_url
                    lv_string2
                    INTO lv_string3.
        ls_button-on_client_click = lv_string3.
        ls_button-enabled = abap_true.
        APPEND ls_button TO gt_editbutton.
    pass your dynamic URL here to lv_url. Dont Pass anything to ls_button-on_click.
    You can do this coding in DO_PREPARE_OUTPUT or IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS wherever your button is present.
    Regards,
    Masood Imrani S.

  • Handling new story event

    Hi everybody,
    I'm trying to handle an event for new created stores, I'm using the kNewStorySignalResponderService
    void GTTxtEdtResponder::Respond(ISignalMgr* signalMgr)
              do {
      // Get the service ID from the signal manager
                        ServiceID serviceTrigger = signalMgr->GetServiceID();
      // Take action based on the service ID
                        switch (serviceTrigger.Get())
    case kNewStorySignalResponderService:
    InterfacePtr<INewStorySignalData> data(signalMgr,UseDefaultIID());
        if(data == nil)
           break;
        UIDRef mod = data->GetTextModel();
        if(mod == nil)
            break;
        InterfacePtr<ITextModel> txt(mod,UseDefaultIID());
        if(txt == nil)
            break;
        int len = txt->TotalLength();
    break;
    default:
      break;
              } while (kFalse);
    I keep getting 0 for the length of the text event that when I drag the text it already contains some text.
    what am doing wrong
    Thanks.

    Works as intended.
    The signal is sent as soon as the story is created, before the new/placed text is inserted in a separate step.
    Dirk

  • How can I add new event handler in BC4J event flow in UIX?

    How can I declarativly add extension to existing event handleres in BC4J+UIX page?
    I generate through wizards UIX+BC4J pages and I want extend some actions in eventhandlers section. Can I do it in some way like <event name=".." method=".." class=".."> like in any regular event handlers?

    you can use the <method ..> event handler inside the BC4J event handlers, like:
    <bc4j:findRootAppModule name="EmpAppModule" >
    <bc4j:findViewObject name="CurrentDeptEmpsVO" >
    <method class="myPackage.myClass" method="doOperation"/>
    </bc4j:findViewObject>
    </bc4j:findRootAppModule>

  • Error in post process event handler

    We should write a post process event handler that updates the manager field. So, I used the following code to update the manager field when a user gets created:
    Code:
    public EventResult execute(long processId, long eventId,
    Orchestration orchestration) {
    System.out.println("Test for Event Handler");
    try
    String userKey = getUserKey(processId, orchestration);
    System.out.println("USERKEY1"+userKey);
    UserManager userMgmt = Platform.getService(UserManager.class);
    System.out.println("USERMANAGEMENT"+userMgmt);
    System.out.println(userMgmt.modify(new User(userKey)));
    userMgmt.modify("usr_mgr_key","28",new User(userKey));
    System.out.println("USERKEY2"+userKey);
    } catch (ValidationFailedException e) {
    System.out.println("Exception1");
    } catch (AccessDeniedException e) {
    System.out.println("Exception2");} catch (UserModifyException e) {
    System.out.println("Exception3");} catch (NoSuchUserException e) {
    System.out.println("Exception4");} catch (SearchKeyNotUniqueException e) {
    return new EventResult();
    private String getUserKey (long processID, Orchestration orchestration) {
    String userKey;
    String entityType = orchestration.getTarget().getType();
    EventResult result;
    result = new EventResult();
    System.out.println("Entity Type"+entityType);
    System.out.println("Process ID"+processID);
    if (!orchestration.getOperation().equals("CREATE")) {
    userKey = orchestration.getTarget().getEntityId();
    System.out.println("UserKEY0"+userKey);
    } else {
    OrchestrationEngine orchEngine = Platform.getService(OrchestrationEngine.class);
    userKey = (String) orchEngine.getActionResult(processID);
    System.out.println("UserKEY-1"+userKey);
    return userKey;
    It compiles fine and when we try to create a user, the user gets created successfully. But, the expected behaviour of upadting the manager field with the user key '28' is not happening. My approach above - is it right or is there any other method that will make it work?
    The output message I see is:
    Test for Event Handler
    Entity TypeUser
    Process ID140343
    UserKEY-1613
    USERKEY1613
    USERMANAGEMENToracle.iam.identity.usermgmt.api.UserManagerDelegate@75ecf9ed
    <27-Feb-2012 10:56:41 o'clock GMT> <Warning> <oracle.iam.callbacks.common> <IAM-2030146> <[CALLBACKMSG] Are applicable policies present for this async eventhandler ? : false>
    oracle.iam.identity.usermgmt.vo.UserManagerResult@14da2ada
    <27-Feb-2012 10:56:44 o'clock GMT> <Error> <oracle.iam.identity.usermgmt.impl> <IAM-3051212> <An error occurred while searching for users - : [usr_mgr_key].>
    Exception4
    Thanks
    Krish

    i hope wrong coding.
    Use this code.
    UserManager userMgmt = oimClient.getService(UserManager.class);
    //Attribute you want to modify
    HashMap<String, Object> atrrMap= new HashMap<String, Object>();
    atrrMap.put("usr_manager_key", Long.valueOf("1")); //user will upadated with manager key 1 (xelsysadm) make sure usr_key 1 (manager) exist in OIM.
    //get the user to whom you want to modify
    User user = userMgmt.getDetails("usr_key", "41", null);
    user = new User(String.valueOf(user.getId()), atrrMap);
    UserManagerResult result = userMgmt.modify("usr_key", String.valueOf("41"), user);
    //UserManagerResult str = userMgmt.modify("usr_mgr_key","111",new User("41"));
    System.out.println("UserUpdate.process() "+result.getStatus());
    Also don't use UserManager class, As it will go for looping.
    Use
    EntityManager entityManager = Platform.getService(EntityManager.class);
    entityManager.modifyEntity(orchestrationTarget.getType(), userKey, mapAttrs);
    Also I am assuming you want to use Associate manager With user use case.
    Thanks,
    Kuldeep

  • How to update 1 Event Handler from different SAP systems?

    Hi experts.
    I created an Event Handler via SAP 4.7 Purchase Order.
    I now need to update this same Event Handler with a control parameter from SAP 6.0.
    I was surprised to see that when I updated the Purchase Order in 6.0, EM created a new Event Handler!
    Guess I'm missing something obvious...
    Thanks.
    Zenon.

    Hello Berthold, Steffen,
    Yes it's the same PO in 4.7 and 6.0.  We implemented (upgraded) the ERP system to 6.0.  The Event Handler was orginally created from 4.7, but now we need to update it from 6.0.
    So the Event Handler (tracking id, control parms, EE etc)  can only be updated from the logical system the Eh was created in (4.7), and I can only send Event Messages (Events) from 6.0.  Correct?
    Any thought about how to approach this situation and any future upgrades?  Maybe I need to write a conversion program...
    Thanks.
    Zenon.

  • Event Handling Techniques

    Hi All,
         I have encountered some code which takes a somewhat different approach to event handling that I have used previously.
    This is a basic example of the principles:
    private final static String = "CMD_ONE";
    private final static String = "CMD_TWO";
    private final static String = "CMD_THREE";
    EventHandler eventHanlder = new EventHandler();
    JButton one = new JButton();
    one.addActionCommand(CMD_ONE);
    one.addActionListener(eventHandler);
    JButton two = new JButton();
    two.addActionCommand(CMD_TWO);
    two.addActionListener(eventHandler);
    JButton three = new JButton();
    three.addActionCommand(CMD_THREE);
    three.addActionListener(eventHandler);
    class EventHandler implements ActionListener
         public void actionPerformed(ActionEvent ev)
              if(ev.getActionCommand().compareTo(CMD_ONE) = 0)
                   System.out.println("User hit the ONE button");
              if(ev.getActionCommand().compareTo(CMD_TWO) = 0)
                   System.out.println("User hit the TWO button");
              if(ev.getActionCommand().compareTo(CMD_THREE) = 0)
                   System.out.println("User hit the TWO button");
    My question is what could the motivation for this approach be? Is it to save on memory by having fewer EventListener objects instantiated (presumably).
    Is this necessarily a better approach than having a dedicated EventListener for each separate component.
    I always thought that the idea was to minimise the amount of processing for any event so that the UI was very reactive to user input (by having dedicated EventListeners). I can see that this approach could suffer
    in a situation with the EventHandler being responsible for many components i.e. Having to evaluate a big list of expressions because of the number of delegated commands.
    I would very much like to know if anyone has any strong views on this or if anyone knows the Sun guidance on this matter.
    Thanks for any replies,
    Jonathan.

    I would recommend creating a single listener and add it to every label added to the graph. If you're interested in events that occur outside of the labels (in the background), add a listener to the container of the labels as well.
    Unfortunately, you cannot simply add a listener to the container and get all the mouse events from the container's children because Swing's event dispatching system will only dispatch mouse events to a container if the click location was not within any of the container's children. This means that mouse listeners registered to a container will only receive mouse events within the container's background.

  • The reflection answer to event handling?

    I have been playing with reflection answers to the question of how to handle ActionEvent events in Swing... like using a single instance of one member class as a reflection switch:
    private class Listener implements ActionListener {
         public void actionPerformed (ActionEvent action) {
              try {this.getClass().getMethod(action.getActionCommand(), new Class[0]).invoke(this, new Object[0]);}
              catch(Exception exception) {/* error handling code */}
         public void one() {/* do something */}
         public void two() {/* do something */}
    }No more hideous if/then structures and only one inner class. Just match the method names to the action commands and the two line switch handles everything. Much cleaner code and directories.
    I wrote a small example program that you can get the source for here:
    http://www.immortalcoil.org/drake/SmartFrameExample.java
    I can think of only two reasons not to do this right now:
    1) Event / listener mismatches you would have caught at compile time before (if using inner classes) become runtime errors, or if you improve upon the above with Class.getMethods() then dead actions (as with a classic switch).
    2) Inability to look yourself in the mirror or partake of Jesus's love.
    Still, the result is much prettier code and as long as you code it right it will work flawlessly. I am honestly considering using this.
    Thoughts?

    For simple GUIs with very few actions, your approach is obviously overkill. You want to preserve simplicity whenever possible without affecting performance.
    For mildly complex GUIs, I think your approach is good, but still doesn't solve the bigger problem of managing multiple components that use the same action. If you've got so many actions that you need reflection to reduce code, you probably have a GUI with menubars, toolbars, popup menus, and buttons that all perform the same set of actions. Now you have to register an ActionListener with each component, not to mention disabling an action, which involves finding every menu item and button corresponding to this action and disabling/enabling it. I realize this is a different problem than you were trying to solve, but it's worth considering.
    Well, Swing provides javax.swing.Action to handle just this problem, which more or less alleviates the need for your approach because you have an Action subclass for each action. But maybe the best solution for very complex GUIs is a combination of your approach with the Action approach by providing an ActionSet class, which centralizes event handling for all components. The ActionSet class would define for each action:
    1) a static String for the action command
    2) a static String for the tooltip
    3) a static Icon for the icon
    Now, when a new ActionSet is created, it uses reflection to read each of it's fields, creating a new Action subclass for that action and storing it in a HashMap using the action command for the key. The Action subclass just handles the event by forwarding it to a registered ActionListener on the ActionSet class. The ActionListener would implement your approach for reflection event-handling, thereby eliminating if/else/switch clauses.
    The GUI code can call a method "getAction(String actionCommand)" on the ActionSet to retrieve the Action subclass when creating the JMenuBar, JButton, JToolBar, JPopupMenu, etc. Then at any time in the application, you can call ActionSet.getAction(...).setEnabled(...) to enable/disable all components using that action.

  • UIX choice component event handling

    Hi, I am using UIX in JDEV 10G. My page has a few dependent uix choice components on it. The first choice populates the second choice box and so on. I am using primaryClientActions to handle firing the event of populating the choice box. Below is the EventHandler for the fired event. I have a viewObject and AppModule. I set the where clause on the viewobject with the parameters from the previous choice selection. My question is: How do I get my query results back to my UIX choice component. I thought if I called executequery() it would update the view Objects query and update my page, but I think I am missing a step.
    public static EventResult fminstEventHandler(BajaContext context,Page page,PageEvent event) throws Throwable
    result = new EventResult();
    fmInst = event.getParameter("FmName");
    DeptAppModuleImpl dam = new DeptAppModuleImpl();
    ViewObject deptView = dam.getDeptView1();
    deptView.setWhereClause("where inst ='" + fmInstNum +"' and dept != '*****' and guide_yr ='"+guideyr +"' union select 'ALL', '0' from dual");
    deptView.executeQuery();
    return result; //result is nothing right now.
    Thanks for your help.
    McKell

    Sure. Thanks for responding to my question. Below is the UIX file:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <page xmlns="http://xmlns.oracle.com/uix/controller"
    xmlns:ui="http://xmlns.oracle.com/uix/ui"
    xmlns:data="http://xmlns.oracle.com/uix/ui"
    xmlns:ctrl="http://xmlns.oracle.com/uix/controller"
    xmlns:html="http://www.w3.org/TR/REC-html40" expressionLanguage="el"
    xmlns:myTemplate="CourseTransferTemplate">
    <templates xmlns="http://xmlns.oracle.com/uix/ui">
    <templateImport source="CrsTranTemplate.uit"/>
    </templates>
    <content>
    <dataScope xmlns="http://xmlns.oracle.com/uix/ui">
    <provider>
    <!-- Add DataProviders (<data> elements) here -->
    </provider>
    <contents>
    <document xlmns="http://xmlns.oracle.com/uix/ui">
    <metaContainer>
    <!-- Set the page title -->
    <head title="Course Transfer Search"/>
    </metaContainer>
    <contents>
    <body>
    <contents>
    <form name="form0">
    <contents>
    <!-- <formParameter name="event"/> -->
    <myTemplate:CourseTransferTemplate selectedTab="0"
    title="Course Transfer Search"
    xmlns:myTemplate="CourseTransferTemplate">
    <contents>
    <rawText
    text="<p>Welcome to the Utah System of Higher Education (USHE) Course Transfer Guide on the Web!
    <p>The USHE Course Transfer Guide provides course-by-course articulation and transfer information. It shows how a course at the institution you are transferring from (the 'from' school) articulates with a course at the institution to which you plan to transfer (the 'to' school). The USHE Course Transfer Guide has been developed by the Utah Transfer Articulation Committee and the ">
    <contents>
    <link text="Utah System of Higher Education"
    destination="http://www.utahsbr.edu"/>
    <rawText text="(USHE). It is updated every year by participating institutions and a new guide is published in the fall.<p>"/>
    </contents>
    </rawText>
    <!-- GuideYR -->
    <rawText text="Guide Year ">
    <contents>
    <choice model="${data.TransferGuideUIModel.GuideYr2}" name="GuideYr2" prompt="GuideYr2" >
    <primaryClientAction>
    <firePartialAction event="guideyrEvent"
    formSubmitted="true"
    />
    </primaryClientAction>
    <contents childData="${data.TransferGuideUIModel.GuideYr2.displayData}">
    <option model="${uix.current}" text="${uix.current.prompt}"
    value="${uix.current.prompt}" />
    </contents>
    </choice>
    </contents>
    </rawText>
    <!-- FmName -->
    <rawText text="From Institution ">
    <contents>
    <choice model="${data.TransferGuideUIModel.Name}"
    name="FmName" prompt="FmName">
    <primaryClientAction>
    <firePartialAction event="FmInstEvent"
    formSubmitted="true"
    targets="Department"/>
    </primaryClientAction>
    <contents
    childData="${data.TransferGuideUIModel.Name.displayData}">
    <option model="${uix.current}"
    text="${uix.current.prompt}"
    value="${uix.current.prompt}"/>
    </contents>
    </choice>
    </contents>
    </rawText>
    <!-- Dept -->
    <rawText text="From Department ">
    <contents>
    <choice model="${data.TransferGuideUIModel.Dept}" name="Dept" prompt="Dept">
    <primaryClientAction>
    <firePartialAction event="DepartmentEvent"
    formSubmitted="true"
    targets="Course"/>
    </primaryClientAction>
    <contents childData="${data.TransferGuideUIModel.Dept.displayData}">
    <option model="${uix.current}"/>
    </contents>
    </choice>
    </contents>
    </rawText>
    <!-- Crs -->
    <rawText text="From Course ">
    <contents>
    <choice id="Course" name="Crs" nodeID="Course">
    <primaryClientAction>
    <firePartialAction event="CourseEvent"
    formSubmitted="true"
    />
    </primaryClientAction>
    </choice>
    </contents>
    </rawText>
    <!-- ToName -->
    <rawText text="To Institution ">
    <contents>
    <choice model="${data.TransferGuideUIModel.Name}"
    name="ToName" prompt="ToName">
    <primaryClientAction>
    <firePartialAction event="ToInstEvent"
    formSubmitted="true"
    />
    </primaryClientAction>
    <contents
    childData="${data.TransferGuideUIModel.Name.displayData}">
    <option model="${uix.current}"
    text="${uix.current.prompt}"
    value="${uix.current.prompt}"/>
    </contents>
    </choice>
    </contents>
    </rawText>
    <button text="Find Articulations"/>
    <rawText text="<p>Choose the academic year you want to search for articulations. Then choose the institution you are transferring from. After you make your selection, a list of departments will be created for you to choose from. Once you choose your department, a list of courses will be created for you to refine your selection. You will then choose which institution you would like to transfer to (you may choose all institutions) and click on 'find articulations'. "/>
    </contents>
    <tabs/>
    <pageButtons/>
    <globalButtons/>
    <pageHeader/>
    <start/>
    <end/>
    <about/>
    <copyright/>
    <privacy/>
    <corporateBranding/>
    <productBranding/>
    </myTemplate:CourseTransferTemplate>
    </contents>
    </form>
    </contents>
    </body>
    </contents>
    </document>
    </contents>
    </dataScope>
    </content>
    <handlers>
    <!-- Add EventHandlers (<event> elements) here -->
    <event name="*" source="FmName">
    <method class="mypackage1.EventHandlers" method="fminstEventHandler"/>
    </event>
    <event name="*" source="Department">
    <method class="mypackage1.EventHandlers" method="deptEventHandler"/>
    </event>
    <event name="*" source="GuideYr2">
    <method class="mypackage1.EventHandlers" method="guideyrEventHandler"/>
    </event>
    <event name="*" source="Course">
    <method class="mypackage1.EventHandlers" method="courseEventHandler"/>
    </event>
    <event name="*" source="ToName">
    <method class="mypackage1.EventHandlers" method="toinstEventHandler"/>
    </event>
    </handlers>
    </page>
    HERE IS THE EVENT HANDLER:
    public static EventResult fminstEventHandler(BajaContext context,Page page,PageEvent event) throws Throwable
    try
    con = new DBConnection();
    catch (SQLException e)
    System.out.println(e);
    fmInst = event.getParameter("FmName");
    ResultSet rset = con.query(namesql); //Here con connects to my database and preforms a query.
    while(rset.next())
    fmInstNum = rset.getString(1);
    System.out.println(fmInstNum);
    //DeptAppModule and DeptView are an Application Module and View Object I created from the JDeveloper wizards
    DeptAppModuleImpl dam = new DeptAppModuleImpl();
    ViewObject DeptView = dam.getDeptView1();
    DeptView.setWhereClause("where inst ='" + fmInstNum +"' and dept != '*****' and guide_yr ='"+guideyr +"' union select 'ALL', '0' from dual");
    DeptView.executeQuery();
    //This is where I don't know how to return the result from the query back to the uix choice component named "Dept"
    return new EventResult(page);
    Thanks you so much for your assistance. I might be approaching this completely wrong. I am new to JDeveloper and the UIX framework. Thank you again.
    McKell

  • How can I execute an external program from within a button's event handler?

    I am using Tomcat ApacheTomcat 6.0.16 with Netbeans 6.1 (with the latest JDK/J2EE)
    I need to execute external programs from an event handler for a button on a JSF page (the program is compiled, and extremely fast compared both to plain java and especially stored procedures written in SQL).
    I tried what I'd do in a standalone program (as shown in the appended code), but it didn't work. Instead I received text saying the program couldn't be found. This error message comes even if I try the Windows command "dir". I thought with 'dir' I'd at least get the contents of the current working directory. :-(
    I can probably get by with cgi on Apache's httpd server (or, I understand tomcat supports cgi, but I have yet to get that to work either), but whatever I do I need to be able to do it from within the button's event handler. And if I resort to cgi, I must be able to maintain session jumping from one server to the other and back.
    So, then, how can I do this?
    Thanks
    Ted
    NB: The programs that I need to run do NOT take input from the user. Rather, my code in the web application processes user selections from selection controls, and a couple field controls, sanitizes the inoputs and places clean, safe data in a MySQL database, and then the external program I need to run gets safe data from the database, does some heavy duty number crunching, and puts the output data into the database. They are well insulated from mischeif.
    NB: In the following array_function_test.pl was placed in the same folder as the web application's jsp pages, (and I'd tried WEB-INF - with the same result), and I DID see the file in the application's war file.
            try {
                java.lang.ProcessBuilder pn = new java.lang.ProcessBuilder("array_function_test.pl");
                //pn.directory(new java.io.File("K:\\work"));
                java.lang.Process pr = pn.start();
                java.io.BufferedInputStream bis = (java.io.BufferedInputStream)pr.getInputStream();
                String tmp = new String("");
                byte b[] = new byte[1000];
                int i = 0;
                while (i != -1) {
                    bis.read(b);
                    tmp += new String(b);
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + tmp);
            } catch (java.io.IOException ex) {
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + ex.getMessage());
            }

    Hi Fonsi!
    One way to execute an external program is to use the System Exec.vi. You find it in the functions pallet under Communication.
    /Thomas

  • Copying text to the clipboard in AVDocDidOpen event handler causes Acrobat 9 to crash

    I'm trying to copy the filename of a document to the clipboard in a plugin with my AVDocDidOpen event handler.  It works for the first file opened; however when a second file is opened, Acrobat crashes.  The description in the application event log is: "Faulting application acrobat.exe, version 9.1.0.163, faulting module gdi32.dll, version 5.1.2600.5698, fault address 0x000074cc."
    I've confirmed that the specific WIN32 function that causes this to happen is SetClipboardData(CF_TEXT, hText);  When that line is commented out and remaining code is left unchanged, Adobe doesn't crash.
    Is there an SDK function that I should be using instead of WIN32's SetClipboardData()?  Alternately, are there other SDK functions that I need to call be before or after I call SetClipboardData()
    Bill Erickson

    Leonard,
    I tried it with both "DURING, HANDLER, END_HANDLER" and "try catch," as shown below.  However, it doesn't crash in the event handler; it crashes later, so the HANDLER/catch block is never hit.
    The string that's passed to SetClipboardData() is good, because I'm able to paste it into the filename text box of the print dialog when I try to create the "connector line" PDF.  I also got rid of all the string manipulation and tried to pass a zero-length string to the clipboard but it still crashes.
    Here's the code:
    ACCB1 void ACCB2 CFkDisposition::myAVDocDidOpenCallback(AVDoc doc, Int32 error, void *clientData)
        PDDoc pdDoc = AVDocGetPDDoc(doc);
        char* pURL = ASFileGetURL(PDDocGetFile(annotDataRec->thePDDoc));
        if (pURL)    {
            if (strstr(pURL, "file://") && strstr(pURL, "Reviewed.pdf")) {
                // Opened from file system so copy filename to clipboard for connector line report
                char myURL[1000];
                strcpy(myURL, pURL);
                ASfree(pURL);    // Do this before we allocate a Windows handle just in case Windows messes with this pointer
                pURL = NULL;
                HGLOBAL hText = GlobalAlloc(GMEM_MOVEABLE, 1000);
                if (hText)    {
                    try
                        // Skip path info and go right to filename
                        char *pText = (char *)GlobalLock(hText);
                        char *pWork = strrchr(myURL,'/');
                        if (pWork)    {
                            strcpy(pText, pWork+1);
                        } else {
                            strcpy(pText, myURL);
                        char *pEnd = pText + strlen(pText);    // Get null terminator address
                        // Replace "%20" in filename with " "
                        pWork = strstr(pText, "%20");
                        while (pWork)    {
                            *pWork = ' ';
                            memmove(pWork+1, pWork+3, (pEnd - (pWork+2)));
                            pWork = strstr(pText, "%20");
                        // Append a new file extension
                        pWork = strstr(pText, ".pdf");
                        *pWork = 0;    // truncate the string before ".pdf"
                        strcat(pWork,".Connectors.pdf");
                        GlobalUnlock(hText);     // Must do this BEFORE SetClipboardData()
                        // Write it to the clipboard
                        OpenClipboard(NULL);
                        EmptyClipboard();
                        SetClipboardData(CF_TEXT, hText);     // Here's the culprit
                        CloseClipboard();
                        GlobalFree(hText);
                    } catch (char * str) {
                        AVAlertNote(str);
            if (pURL)
                ASfree(pURL);

  • Swing: when trying to get the values from a JTable inside an event handler

    Hi,
    I am trying to write a graphical interface to compute the Gauss Elimination procedure for solving linear systems. The class for computing the output of a linear system already works fine on console mode, but I am fighting a little bit to make it work with Swing.
    I put two buttons (plus labels) and a JTextField . The buttons have the following role:
    One of them gets the value from the JTextField and it will be used to the system dimension. The other should compute the solution. I also added a JTable so that the user can type the values in the screen.
    So whenever the user hits the button Dimensiona the program should retrieve the values from the table cells and pass them to a 2D Array. However, the program throws a NullPointerException when I try to
    do it. I have put the code for copying this Matrix inside a method and I call it from the inner class event handler.
    I would thank you very much for the help.
    Daniel V. Gomes
    here goes the code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import AdvanceMath.*;
    public class MathF2 extends JFrame {
    private JTextField ArrayOfFields[];
    private JTextField DimOfSis;
    private JButton Calcular;
    private JButton Ativar;
    private JLabel label1;
    private JLabel label2;
    private Container container;
    private int value;
    private JTable DataTable;
    private double[][] A;
    private double[] B;
    private boolean dimensionado = false;
    private boolean podecalc = false;
    public MathF2 (){
    super("Math Calcs");
    Container container = getContentPane();
    container.setLayout( new FlowLayout(FlowLayout.CENTER) );
    Calcular = new JButton("Resolver");
    Calcular.setEnabled(false);
    Ativar = new JButton("Dimensionar");
    label1 = new JLabel("Clique no bot�o para resolver o sistema.");
    label2 = new JLabel("Qual a ordem do sistema?");
    DimOfSis = new JTextField(4);
    DimOfSis.setText("0");
    JTable DataTable = new JTable(10,10);
    container.add(label2);
    container.add(DimOfSis);
    container.add(Ativar);
    container.add(label1);
    container.add(Calcular);
    container.add(DataTable);
    for ( int i = 0; i < 10 ; i ++ ){
    for ( int j = 0 ; j < 10 ; j++) {
    DataTable.setValueAt("0",i,j);
    myHandler handler = new myHandler();
    Calcular.addActionListener(handler);
    Ativar.addActionListener(handler);
    setSize( 500 , 500 );
    setVisible( true );
    public static void main ( String args[] ){
    MathF2 application = new MathF2();
    application.addWindowListener(
    new WindowAdapter(){
    public void windowClosing (WindowEvent event)
    System.exit( 0 );
    private class myHandler implements ActionListener {
    public void actionPerformed ( ActionEvent event ){
    if ( event.getSource()== Calcular ) {
    if ( event.getSource()== Ativar ) {
    //dimensiona a Matriz A
    if (dimensionado == false) {
    if (DimOfSis.getText()=="0") {
    value = 2;
    } else {
    value = Integer.parseInt(DimOfSis.getText());
    dimensionado = true;
    Ativar.setEnabled(false);
    System.out.println(value);
    } else {
    Ativar.setEnabled(false);
    Calcular.setEnabled(true);
    podecalc = true;
    try {
    InitValores( DataTable, value );
    } catch (Exception e) {
    System.out.println("Erro ao criar matriz" + e );
    private class myHandler2 implements ItemListener {
    public void itemStateChanged( ItemEvent event ){
    private void InitValores( JTable table, int n ) {
    A = new double[n][n];
    B = new double[n];
    javax.swing.table.TableModel model = table.getModel();
    for ( int i = 0 ; i < n ; i++ ){
    for (int j = 0 ; j < n ; j++ ){
    Object temp1 = model.getValueAt(i,j);
    String temp2 = String.valueOf(temp1);
    A[i][j] = Double.parseDouble(temp2);

    What I did is set up a :
    // This code will setup a listener for the table to handle a selection
    players.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel rowSM = players.getSelectionModel();
    rowSM.addListSelectionListener(new Delete_Player_row_Selection(this));
    //Class will take the event and call a method inside the Delete_Player object.
    class Delete_Player_row_Selection
    implements javax.swing.event.ListSelectionListener
    Delete_Player adaptee;
    Delete_Player_row_Selection (Delete_Player temp)
    adaptee = temp;
    public void valueChanged (ListSelectionEvent listSelectionEvent)
    adaptee.row_Selection(listSelectionEvent);
    in the row_Selection function
    if(ex.getValueIsAdjusting()) //To remove double selection
    return;
    ListSelectionModel lsm = (ListSelectionModel) ex.getSource();
    if(lsm.isSelectionEmpty())
    System.out.println("EMtpy");
    else
    int selected_row = lsm.getMinSelectionIndex();
    ResultSetTableModel model = (ResultSetTableModel) players.getModel();
    String name = (String) model.getValueAt(selected_row, 1);
    Integer id = (Integer) model.getValueAt(selected_row, 3);
    This is how I got info out of a table when the user selected it

  • Problem with event handling

    Hello all,
    I have a problem with event handling. I have two buttons in my GUI application with the same name.They are instance variables of two different objects of the same class and are put together in the one GUI.And their actionlisteners are registered with the same GUI. How can I differentiate between these two buttons?
    To be more eloborate here is a basic definition of my classes
    class SystemPanel{
             SystemPanel(FTP ftp){ app = ftp};
             FTP app;
             private JButton b = new JButton("ChgDir");
            b.addActionListener(app);
    class FTP extends JFrame implements ActionListener{
               SystemPanel rem = new SystemPanel(this);
               SystemPanel loc = new SystemPanel(this);
               FTP(){
                       add(rem);
                       add(loc);
                       pack();
                       show();
           void actionPerformed(ActionEvent evt){
            /*HOW WILL I BE ABLE TO KNOW WHICH BUTTON WAS PRESSED AS THEY
               BOTH HAVE SAME ID AND getSouce() ?
               In this case..it if was from rem or loc ?
    }  It would be really helpful if anyone could help me in this regard..
    Thanks
    Hari Vigensh

    Hi levi,
    Thankx..
    I solved the problem ..using same concept but in a different way..
    One thing i wanted to make clear is that the two buttons are in the SAME CLASS and i am forming 2 different objects of the SAME class and then putting them in a GUI.THERE IS NO b and C. there is just two instances of b which belong to the SAME CLASS..
    So the code
    private JButton b = new JButton("ChgDir");
    b.setActionCommand ("1");
    wont work as both the instances would have the label "ChgDir" and have setActionCommand set to 1!!!!
    Actually I have an array of buttons..So I solved the prob by writting a function caled setActionCmdRemote that would just set the action commands of one object of the class differently ..here is the code
    public void setActionCommandsRemote()
         for(int i = 0 ; i <cmdButtons.length ; i++)
         cmdButtons.setActionCommand((cmdButtons[i].getText())+"Rem");
    This just adds "rem" to the existing Actioncommand and i check it as folows in my actionperformed method
         if(button.getActionCommand().equals("DeleteRem") )          
                        deleteFileRemote();
          else if(button.getActionCommand().equals("Delete") )
                     deleteFileLocal();Anyway thanx a milion for your help..this was my first posting and I was glad to get a prompt reply!!!

Maybe you are looking for

  • HP PSC 1510 Windows 7 Driver

    Hello. I can't find Windows 7 drivers for my device and the Vista ones don't seem to work corectly. Can anyone help me?

  • File Sender Adapter - Multiple Source Directory

    Hi all, I have the following file to IDoc Scenaraio: The source file might be in any of 3 directories in source system and so created file sender adapter as follows: File access parameters: Source Directory : Directory1 File Name         : Filename*.

  • What Macbook Do I Have?

    Hi everybody, just picked up my first mac today, an I was wondering which one I have. I have worked with a few macs before and I know this is not the standard American configuration. It seems as if some of the keys are set up to function as if they w

  • Component and Panels - newbie

    sometimes panels are directly added and sometimes a Component is created and panels are added to Component and then they are used in JSplitPane. In what kind of situations can we add directly the panel, and when do we need the Component() ? eg final

  • Can't connect to windows sbs 2003 using Leopard...

    Hey there... I'm one of 3 Mac users at our office. We use Windows Small Business Server 2003. Since upgrading to Leopard, I can no longer access the network shared folders. Didn't even think about this when upgrading. Our IT guy is strictly a Windows