Can I pass an Object THROUGH to a LISTENER?

I created a class called FuncSelect(), whose constructor takes a JDBCClass object as an argument.
public FuncSelect( JDBCClass dbApp) {
}Passing in this object allows FuncSelect() to reference JDBCClass's Session object and various methods.
FuncSelect implements a listener, which in turn calls method postUpdate(), which needs to reference the dbApp.Session object -- however, I'm getting hung up trying to figure out how pass dbApp through to the listener:
    class OKListener implements ActionListener {
        public void actionPerformed(ActionEvent e ) {
            postUpdate() ;  // <--- need to pass dbApp to this method!!!!
    }Confused? Again need to pass dbApp object as follows:
FuncSelect(JDBCClass dbApp) --> OKListener( ActionEvent e, JDBCClass dbApp) --> postUpdate(JDBCClass dbApp ).
Do I need an abstract class for this? Any samples out there?
Thanks for any assistance.

There's nothing that says that your listener can't have more than just an actionPerformed method. Add a method (or a constructor) to your listener that accepts a JDBCClass object just like the FuncSelect class does.
class OKListener implements ActionListener {
  private JDBCClass dbApp = null;
  public OKListener() { super(); }
  public OKListener (JDBCClass dbApp) {
    super();
    this.dbApp = dbApp;
   public void actionPerformed(ActionEvent e ) {
   postUpdate(dbApp) ;  // <--- need to pass dbApp to this method!!!!       
}

Similar Messages

  • How can I pass an object to a function by value?

    Hi
    I have a function with an argument. this argument is an object. I don't want to alter this object. But java passes this object by reference and some fields in this object are altered after function return.
    How can I pass this object by value and keep my original data unbroken?
    thanks for any help

    a.toraby wrote:
    I have a function with an argument. this argument is an object. I don't want to alter this object. But java passes this object by reference and some fields in this object are altered after function return.
    How can I pass this object by value and keep my original data unbroken?How you approach it is likely to depend on how much control you have over the code in question. If it's legacy code and has been badly designed, there's probably very little you can do to protect existing code short of a complete refactoring.
    What you could do as an interim measure is:
    1. Create an immutable wrapper to your existing mutable class.
    2. Create new methods that replicate the existing ones, but take the immutable class instead.
    3. Deprecate the old methods.
    This won't break client code, but they will now get warnings when they compile and you can add documentation to point them to the new class/methods.
    If you are in control of the code (especially if you're still in the design stages), you've got several options:
    1. As Dr.Clap says, make your class immutable (probably best).
    2. If this isn't possible, create mutable and immutable variants of your class. This is often best achieved by hanging them both from an interface.
    Winston

  • Can I pass serialized object as argument through WebStart?

    I know I can pass argument through WebStart using <argument> element in the application-desc of the jnlp file.
    Does WebStart support placing a Java serialized string inside the <argument> element? The reason is I want my application to behave differently based on the input object(s).
    So my thinking is first to generate a serialized string form of my object , then place this serialized string inside the <argument> and then when my Application starts, maybe somehow Java deserializes it for me or may be I have to deserializes myself?
    Is this possible?
    Thanks
    -ken

    yes, you can. although I am not sure how long that string can be? what are you going to store in the string - what kind of information?
    I would generally store configuartion parameters in a seperate file. You could pass the path to the config file in your arguments...

  • Can we pass delimeted file through PI without converting it to XML ?

    Hi All,
    I will be getting File from Sender in Inbound Payload as delimitted file and not in XML structure using XI adapter. So can you please suggest on how I need to do mapping as file will be passed as it is and which need to transfer from Sender to Target system.
    Target side I will be using file adapter to put the file at desired location and as inbound file is not in XML and directly delimetted file there is no need of File Content Conversion too. Please suggest as I am unable to visualise How mapping needs to be done in case of direct passing of delimitted file from Sender to Targeget throgh PI i.e. inbound payload and outbound payload both contains delimitted file field separated by pipe "|".
    Your valuable inputs will be highly appreciated.
    Regards,
    Nitin Patil

    Hi  Nitin Patil ,
    No need to do mapping in ESR/IR . No FCC also
    Do as follows
    1. Create a namespace in ESR/IR only .
    2. Directly go to ID - configuration
    3. In interface determination  give some dummy name for inbound interface .
    Note : Use the propoer namespace which you have created in ESR/IR
    4 Create sender and receiver FIle adapter  - use the same dummy interface name
    5. Create sender and receiver agreement
    Your file will be picked and droped to desired folder as it is.
    But you ignore the errors in SXMB_MONI .
    Regards.,
    V.Rangarajan

  • How can I pass an object to an inner method?

    Hi all,
    I'm stuck with a tiny problem here, hope someone can help out:
    I receive an UndoableEditEvent object in my method and I then want to apply that object to a JTextArea, my understanding is that I need to add a listener to the JTextArea.. but it won't see my UndoableEditEvent object.
          public static void edit( UndoableEditEvent e ) {
                final UndoManager undo = new UndoManager();
                Document doc = text_in.getDocument();
                doc.addUndoableEditListener(new UndoableEditListener() {
                public void undoableEditHappened(UndoableEditEvent e) {
                    System.out.println(e.getEdit());
                     undo.addEdit(e.getEdit());
    Any ideas?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Well, that looks like the right code for adding a listener to your JTextArea... except for the bit where the code is inside a static method that has an UndoableEditEvent as a parameter. Just get rid of that, and put the inside code immediately after the line of code where you create your JTextArea. You will probably have to make your UndoManager an instance variable of your class, too.

  • Can't set public Object in HTTPService result listener

    Hello.
    I am using a data object class.  The class is based on a class that contains the HTTPService calls.  I want to return the event.results to the local instance of the class by setting a public Object = the results Object. However, the public object is null after the HTTPService event result listener function is finished.
    It is easier to see than to describe:
    In the main application. i make an instace of my activity class:
    myactivity:activity = new activity() ;
    now, I invoke the getdata method:
    myactivity.getdata() ;
    The getdata() method fails at runtime, because it tries to reference the results object.
    See the base class and the activity class below.
    BASECLASS: (just the main parts are listed here):
    public class transferObject
            public var baseurl:String ;
            public var dbresult:Object =new Object();
            public var service:HTTPService ;
            public function transferObject()
            geturl("ghost") ;
            public function geturl(db:String) : void
                    baseurl = "https://xyzzy/" ;
            public function getHttpService(methodname:String):void {
                    service = new HTTPService();
                    service.url = this.baseurl + methodname;
                    service.channelSet ;
                    service.method = "POST";
                    service.addEventListener("result", httpResult );
                    service.addEventListener("fault", httpFault);
                    service.send();
               public function httpResult(event:ResultEvent):void {
                    dbresult = event.result ;
    //DBRESULT IS THE OBJECT I WANT TO REFERENCE IN THE DERIVED CLASS
                 //Do something with the result.
                public function httpFault(event:FaultEvent):void {
                    var faultstring:String = event.fault.faultString;
                    Alert.show('Error sending data: '+faultstring+' '+event.fault);
    HERE IS THE DERIVED CLASS:
    package dataObjects
        public class activity extends transferObject
        import mx.controls.Alert ;   
    [Bindable]
    public var event_id:String ;
    [Bindable]
    public var description:String ;
           public function activity()
                super();
            public function getdata():void
                getHttpService("eventually.sendtest") ;
              this.event_id = dbresult.result.activities.activity.getItemAt(0).event_id ;
    ----> THE LINE ABOVE FAILS AT RUN TIME BECAUSE THE DBRESULT OBJECT IS NULL
    THANK YOU FOR ANYHELP YOU CAN PROVIDE

    Sorry, but parameters of a ServeletRequest can not be modified. Look at the javadocs on ServeletRequest and you will see that "getParameterMap" returns an immutable Map. JSF is simply wrapping that method call with their own "getRequestMap" method. Setting an attribute, request.setAttribute(name, object), is how you pass things using the request to servlets, jsps, etc. on down the line. Just get the attribute instead of the parameter where you need it. Set your "parameter" in the attributes, down the line, check the attribute first, if it exists, use it, otherwise look for the parameter.

  • How to pass serialized object and the string through the socket together?

    I have an application which listens on a port and I usually read string lines from it. Now I want to pass serialised object through it , plus I should indicate (using some string like "object coming") tht the following packet is a serialized object.

    Since Strings are serializable you could just send a stream of serialized objects then you don't have to know anything about the format.

  • Objects through servlet

    How to pass the object through servlet?

    I can venture a guess that the OP wants to 'send' an object as a request parameter or a form field.
    You'd have to turn the object into some data representation that can later on be translated back into the object; serialization comes to mind. It might be easier to just send the properties of the object as seperate request/form fields though!

  • Pass Diadem Parameters through command line

    Hi,
    I am trying to run DIAdem through command line. I have no problem with this but can I pass a variable through the same.
    I would like to pass T1 with some value through command line. Can anyone please help me how can I do this.
    Expecting your earliest reply.
    Thanks,
    Priya

    Hi Priya,
    I am not quite sure what you're trying to do. So are you running a DIAdem SCRIPT from the command line? Is your variable defined within your application? How is the variable initialized when you run the script from within DIAdem. Is it a user Input? Also how exactly are your running the script from the command line?
    I hope to hear from you soon and I will post as soon as I get some info from you side. Thank you for your patience.
    SijinK
    National Instruments

  • Reg: Passing Image url through CSS Class

    Hi,
    How can i pass the image through Css class ?
    Thanks in advance.

    Hi,
    I am not sure if that can be done in css file though.
    I suppose you are using the backing bean for setting the skin (just read your old thread). If yes, you can add two images to your page and set the visible property according to the current skin. Something like
    <af:image id="i1" source="../images/first_logo.gif" visible="#{seesionScope.currentSkin == 'First'}"/>
    <af:image id="i2" source="../images/second_logo.gif" visible="#{seesionScope.currentSkin == 'Second'}"/>
    If i select Second CSS file then the logo will be change according to the style class defined in First CSS file .AFAIK, the company logo would be static ;) .
    -Arun

  • Can we pass value through "EXPORT" in background scheduled report

    hi experts
          my query is can we pass some field using 'EXPORT' statement while scheduling a report to run in background using statement
    submit 'ZXYX' via job jo_name number jo_num and return.
    i am using 'IMPORT" statement in 'ZXYZ'

    EXPORT, as I recall, is limited to your user context.   Check shared objects (which still may not work, although you can propagate to servers) and INDX-like tables.  Research use of INDX-like tables for how data is passed into and out of these tables (import/export).

  • Can we pass objects to pl/sql block

    hi,
    can we pass objects to pl/sql block.i think we can.how to pass it.help me in getting the examples of "passing objects to pl/sql block"

    What exactly do you mean ? You can pass objects like any other parameters
    into and out from procedures/functions:
    SQL> create or replace procedure get_object(myobj in out nocopy my_obj)
      2  is
      3  begin
      4   dbms_output.put_line('ID : ' || myobj.empno);
      5   dbms_output.put_line('Salary : ' || myobj.sal);
      6   dbms_output.put_line('Department : ' || myobj.deptno);
      7   myobj.sal := myobj.sal*2;
      8  end;
      9  /
    Procedure created.
    SQL> declare
      2   mo my_obj := my_obj(1,1000,10);
      3  begin
      4   get_object(mo);
      5   dbms_output.put_line('New salary : ' || mo.sal);
      6  end;
      7  /
    ID : 1
    Salary : 1000
    Department : 10
    New salary : 2000
    PL/SQL procedure successfully completed.Rgds.

  • How can I pass objects across neywork?

    How can I pass a ObjectOutputStream to a ObjectInputStream, across a socket?
    Thanks in advance for your posts!

    Or maybe I am misunderstanding your question?-Probably
    Lets see: ObjectOutputStream passes data trought aout
    Stream; ObjectInputStream receives data trought a in
    Stream: so, I suppose that they can use as streamsthe
    connections betwen two sockets, in one point the
    ObjectOutputStream sending, an in another the
    ObjectInputStream receiving.Yes. The sockets provide the connections, and you can
    call getInputStream or getOutputStream on the sockets
    to read what the other guy is sending, or to write to
    the other guy. You don't actually pass the sockets or
    streams back and forth--they're just the channels by
    which you pass your data.I knew that, thanks anyway. But my question is how can I pass objects throught that streams.
    Anyone knows?
    Thanks

  • How can I pass through error code 1009

    How can I pass through error code 1009

    See this support document. While I do not see an explanation for error code 1009, the closest ones describe 3rd party security software or a hardware fault. You decide which direction you want to head in. http://support.apple.com/kb/TS3694

  • GRE traffic can not pass through LRT224 IPSec Tunnel

    Hi,
    We have a trouble when using Cisco Router GRE tunnel plus LRT224 IPSec Gateway-Gateway Tunnel.
    We found after reboot, GRE packets can not pass trough LRT224 IPSec tunnel. need to restart serval time then gre will back to normal.
    Besides that, GRE keepalive packets can not pass trough LRT224 IPSec Tunnel.
    please help. I had tried to upgrade to latest firmware version.
    Firmware Version : v1.0.3.09 (Dec 26 2014 14:28:46) 
    A-END:
    interface Tunnel1
    ip address 10.216.80.105 255.255.255.252
    ip mtu 1400
    ip nat outside
    ip virtual-reassembly in
    ip tcp adjust-mss 1360
    ip ospf network point-to-point
    ip ospf hello-interval 3
    ip ospf cost 10000
    tunnel source 10.216.81.2
    tunnel destination 10.216.80.90
    end
    B-END:
    interface Tunnel11
    ip address 10.216.80.110 255.255.255.252
    ip mtu 1400
    ip tcp adjust-mss 1360
    ip ospf network point-to-point
    ip ospf cost 10000
    ip ospf hello-interval 3
    tunnel source 10.216.80.91
    tunnel destination 10.216.81.3
    end
    CISCO2911 <> LRT224 <> INTERNET <> LRT224 <> CISCO 2621
    San

    Can you post the results from the below command for the Cisco Routers?
    IOS Command: "sh version"
    Why not static route without NAT through the LRT224 IPSec VPN?
    Just curious why did you use LRT224's for the Site to Site VPN instead of the Cisco Routers?
    Please remember to Kudo those that help you.
    Linksys
    Communities Technical Support

Maybe you are looking for