Accessing object without passing it?

Im making a complicated program with a swing UI. Every component is its own file and is created in the frame classes. There is a controller class that controls the application. I want to be able to access and modify variables in the controller class in each component. Is there a way to do this without passing any variables? Thanks!!

There are a number of ways you could do it (you could make all controller methods and variables static... But please don't do that... or you could monkey around with ThreadLocals... Again, really think hard before going there).
But if you're going to have a single controller I'd recommend enforcing that through a singleton pattern. Expose the controller instance through your Controller.getInstance() and call the methods you need on that.
It's probably the cleanest way to do it and is less of a dependency nightmare than passing the controller or component objects through to each object that needs a connection to it.

Similar Messages

  • Accessing objects without access rights

    Hi,
    does anybody know if is possible to set object's attributes with no matter on its ACL?
    Describe of situation:
    I have an object SeqNum defining form of sequence number for instances of other objects. For example, documents of class Document can have automatically set attribute with sequence numbers "DOC001", "DOC002", "DOC003", etc. on their insert to iFS.
    Each SeqNum object have its ACL, by what I want to say that only admins can manage (change) definition of sequence numbers.
    SeqNum object has also an attribute, containing last used sequence number. The problem is that I need to increment (in background, with setAttribute method) this attribute every time some user inserts document with created sequence number. In order to do that, every SeqNum object must have Public ACL, else I get error message with insufficient access rights. Any idea to solve this?
    Thanks in advance
    Radek Zeman
    [email protected]

    >
    I get "table or view does not exist" error. Is there a way I can wirte refer to objects in this schema without having to indicate the owner. So instead of writing SCOT.EMPLOYEES I want to write just EMPLOYEES.
    >
    Create a public synonym for the object.
    CREATE PUBLIC SYNONYM EMP32 FOR SCOTT.EMP;Then you do not need to specify the schema.
    --- edited to add doc reference
    See CREATE SYNONYM in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_7001.htm
    >
    CREATE SYNONYM Purpose
    Use the CREATE SYNONYM statement to create a synonym, which is an alternative name for a table, view, sequence, operator, procedure, stored function, package, materialized view, Java class schema object, user-defined object type, or another synonym. A synonym places a dependency on its target object and becomes invalid if the target object is changed or dropped.
    >
    Edited by: rp0428 on Apr 5, 2012 10:56 PM

  • How to access the remote Objects Without Db_links?

    Hi ,
    I want to know how to access the remote objects without db_link.That is i want to access a object in some other server which has different database.

    SanjayBala, just so you know that it is possible to create a database link in Oracle to non-Oracle databases in some circumstances. Look up Generic Connectivity aslo know as Heterogenous Services. With 11g Oracle has basically renamed the feature and replaced it with somethinkg named ike DG4ODBC.
    I have not spent time studying the details for DB4ODBC but with HS Oracle provided the interface and you had to obtain the necessary ODBC driver on your own. I had Oracle on AIX reading and writing to SQL Server on Windows but the developers chose to write a java program and connect to both via it. On Windows and Linux platforms the necessary ODBC drivers might be available without the requirement to go out and purchase one.
    The Oracle Open Gateway product is an advanced version of the above features with drivers for specific non-Oracle databases included like DB2 or Informix.
    HTH -- Mark D Powell --

  • Is it possible to find an instance of an object without it being passed to

    Hi all,
    I have a parser class "MessageParser" which i pass a message which is of type "String" to it for it to be parsed. The parsing method signature for the class is
    public void parse(String message);
    I need to pass an instance of "Properties" to it but i dont want to change the signature of the method to add a new argument to it. I have been struggling with this for the last couple of days and have tried a couple of options - see http://stackoverflow.com/questions/5134462/sending-in-an-object-of-type-object-instead-of-string-polymorphism
    The class that calls the parsing method "ParserManager" knows of the properties object. Is there a way for the MessageParser to find the properties object without it being passed to it?
    Thanks
    ps - also posted in http://stackoverflow.com/questions/5140795/is-it-possible-to-find-an-instance-of-an-object-without-it-being-passed-to-the-me

    ziggy wrote:
    I need to pass an instance of "Properties" to it but i dont want to change the signature of the method to add a new argument to it. I have been struggling with this for the last couple of days and have tried a couple of options - see http://stackoverflow.com/questions/5134462/sending-in-an-object-of-type-object-instead-of-string-polymorphism
    The class that calls the parsing method "ParserManager" knows of the properties object. Is there a way for the MessageParser to find the properties object without it being passed to it?I completely agree with Kayaman if you can get away with only the passing the Properties once (as he suggests, at construction time).
    If you can't (ie, you must pass the Properties with each message), then I suspect you have a new type of Parser, and your design will have to reflect that.
    One possibility would be to extend Parser with a PropertiesParser interface that defines a new parse() method and either update the current ParserManager to "understand" the difference, or create a new one.
    The problem with the first option is that the manager then becomes a dispatcher, which kind of goes against the grain of OO programming (what if you need to add a third type of parser, or a fourth?).
    Another possibility (probably better) would be to create a variant of your MessageObject class that includes Properties, and a variant of your MessageCParser that knows how to deal with such an object.
    There are many ways to go, and only you probably know which is best.
    That said, if you can get away with passing the Properties once, definitely follow Kayaman's advice.
    Winston

  • How to access objects in the Child Form from Parent form.

    I have a requirement in which I have to first open a Child Form from a Parent Form. Then I want to access objects in the Child Form from Parent form. For example, I want to insert a record into a block present in Child Form by executing statements from a trigger present in Parent Form.
    I cannot use object groups since I cannot write code into Child Form to first create object groups into Child Form.
    I have tried to achieved it using the following (working of my testcase) :
    1) Created two new Forms TESTFORM1.fmb (parent) and TESTFORM2.fmb (child).
    2) Created a block named BLK1 manually in TESTFORM1.
    3) Created two items in BLK1:
    1.PJC1 which is a text item.
    2.OPEN which is a push button.
    4) Created a new block using data block wizard for a table EMPLOYEE_S1. Created items corresponding to all columns present in EMPLOYEE_S1 table.
    5) In WHEN-NEW-FORM-INSTANCE trigger of TESTFORM1 set the first navigation block to BLK1. In BLK1 first navigable item is PJC1.
    6) In WHEN-NEW-ITEM-INSTANCE of PJC1, code has been written to automatically execute the WHEN-BUTTON-PRESSED trigger for the "Open" button.
    7) In WHEN-BUTTON-PRESSED trigger of OPEN item, TESTFORM2 is opened using the following statement :
    open_form(‘TESTFORM2',no_activate,no_session,SHARE_LIBRARY_DATA);
    Since its NO_ACTIVATE, the code flows without giving handle to TESTFORM2.
    8) After invoking OPEN_FORM, a GO_FORM(‘TESTFORM2’) is now called to set the focus to TESTFORM2
    PROBLEM AT HAND
    ===============
    After Step 8, I notice that it passes the focus to TESTFORM2, and statements after go_form (in Parent Form trigger) doesnot executes.
    I need go_form with no_activate, similar to open_form.
    Edited by: harishgupt on Oct 12, 2008 11:32 PM

    isn't it easier to find a solution without a second form? If you have a second window, then you can navigate and code whatever you want.
    If you must use a second form, then you can handle this with WHEN-WINDOW-ACTIVATED and meta-data, which you have to store in global variables... ( I can give you hints if the one-form-solution is no option for you )

  • Is it possible to get locked objects in passed time?

    Hi,
    I would like to get locked objects in passed time. The oracle version is 9i.
    For example,
    Can I get a list locked objects five days ago? Because I would like to keep locked objects statistics?
    Does these information stored?
    regards,

    Hi,
    your best shot is ASH (active session history). It contains information about active sessions, their wait events, wait times, blockers, objects accessed, SQL running etc. For recent events you may query V$ACTIVE_SESSION_HISTORY, if you are interested in older data then you can try
    looking in DBA_HIST_ACTIVE_SESS_HISTORY.
    There are many limitations when analyzing ASH data, such as:
    1) limited retention time
    2) periodic sampling (you won't be able to see anything that falls in between snapshots)
    3) bias towards longer events
    etc.
    so you need to be careful when analyzing these data.
    Best regards,
    Nikolay

  • Accessing objects with jstl

    Hello forum,
    A question about JSTL - one of the things I have not figured out until now. How can you access an object declared by a specialized tag? Generaly you c:set the variable you wish and you use EL to malipulate it. But how can you access a locale object or resource bundle object? Let's take the bundle object for example:
    The code that would declare it would be:
    <fmt:setLocale value="theLocale"/>
    <fmt:bundle basename="thebasename"/>
    Suppose that later in the code you want to access the created resource bundle object - how can you do that? Obviously a resource bundle object has been created, but how can you call one of its methods?
    Thanks in advance,
    Michael

    "and I really I am not that willing to decide that I will revert them to JSTL, at least not if they are really long"
    Well, right there is your problem. You will need to decide to do it, or not. You are experiencing one of the major problems of NOT using JSTL... when scriptlets get long they are difficult to maintain and change (which is why you shouldn't use them from the beginning.. but that is not pertinent to this topic).
    The issue is that some JSTL and some custom Tags have their own means of working with objects without sharing those objects with the application (it preserves encapsulation.. they can only be sure something is kept correct if they handle it themselves and don't let others mess with it).
    "This is a major problem for using jstl."
    This isn't a problem with JSTL, it is a problem of combining JSTL with scriptlets. JSTL should be used as a replacement for scriplets, in my opinion, not alongside them. It makes it much easier to
    1) plan what you are doing when coding
    2) read the code and understand it later when maintaining.
    So my advice would be to stick with one or the other (further I would suggest going all the way with JSTL, but the time of converting old scriptlet code is a negative that you will have to measure yourself...)

  • Is there a way to access object from other schema?

    1. Is there a way to access object from other schema
    Without using synonym/public synonym without prefixing schema owner?
    2. If you do not see any object in all_objects by same name owned by connected user or public, can there still be objects hidden from this view? for instance synonyms created by SYSTEM
    TIA for help

    Well, you missed something somewhere. If there is no
    ALTER SESSION SET CURRENT_SCHEMA=whoeverthen there must be either public synonym for the object as this shows:
    SQL> CREATE USER a identified by a;
    User created.
    SQL> GRANT CREATE SESSION to a;
    Grant succeeded.
    SQL> CREATE USER b identified by b;
    User created.
    SQL> GRANT CREATE SESSION, CREATE PROCEDURE, CREATE PUBLIC SYNONYM to b;
    Grant succeeded.
    SQL> connect b/b
    Connected.
    SQL> CREATE PACKAGE test AS
      2     PROCEDURE testit;
      3  END;
      4  /
    Package created.
    SQL> CREATE PACKAGE BODY test AS
      2  PROCEDURE testit IS
      3  BEGIN
      4     NULL;
      5  END;
      6  END;
      7  /
    Package body created.
    SQL> connect a/a
    Connected.
    SQL> desc b.test
    ERROR:
    ORA-04043: object b.test does not exist
    SQL> connect b/b
    Connected.
    SQL> GRANT EXECUTE ON test TO a;
    Grant succeeded.
    SQL> connect a/a
    Connected.
    SQL> desc b.test;
    PROCEDURE TESTIT
    SQL> desc test;
    ERROR:
    ORA-04043: object test does not exist
    SQL> connect b/b
    Connected.
    SQL> CREATE PUBLIC SYNONYM test FOR TEST;
    Synonym created.
    SQL> connect a/a
    Connected.
    SQL> desc test
    PROCEDURE TESTITAnother possibility without public synonyms is that crv had granted the other user privileges on some object, and the other user creates a private synonym for that. When crv granted privileges on a different object with the same name, the private synonym became valid again. Something like:
    SQL> connect /
    Connected.
    SQL> drop public synonym test;
    Synonym dropped.
    SQL> GRANT CREATE SYNONYM TO a;
    Grant succeeded.
    SQL> connect a/a
    Connected.
    SQL> desc test;
    ERROR:
    ORA-04043: object test does not exist
    SQL> desc b.test
    PROCEDURE TESTIT
    SQL> CREATE SYNONYM test FOR b.test;
    Synonym created.
    SQL> desc test;
    PROCEDURE TESTIT
    SQL> connect b/b
    Connected.
    SQL> REVOKE EXECUTE ON test FROM a;
    Revoke succeeded.
    SQL> connect a/a
    Connected.
    SQL> desc test;
    ERROR:
    ORA-04043: object "B"."TEST" does not exist
    SQL> desc b.test
    ERROR:
    ORA-04043: object b.test does not exist
    SQL> connect b/b
    Connected.
    SQL> DROP PACKAGE test;
    Package dropped.
    SQL> CREATE FUNCTION test (p_num IN NUMBER) RETURN NUMBER AS
      2  BEGIN
      3     RETURN p_num * 10;
      4  END;
      5  /
    Function created.
    SQL> GRANT EXECUTE ON test TO a;
    Grant succeeded.
    SQL> connect a/a
    Connected.
    SQL> desc test;
    FUNCTION test RETURNS NUMBER
    Argument Name                  Type                    In/Out Default?
    P_NUM                          NUMBER                  INSo, I would go looking for the synonyms.
    TTFN
    John

  • Data access Objects

    Deepak,
    Can you throw some light on the 'Data access Objects" pattern? and how it can be used with Entity beans? I am trying to apply this to the following scenario and having a hard time.
    We need users to be transparent of the data retrieval from various sources like oracle database, flat files or legacy storage. If I use the data access object pattern it is easier to use java classes in place of entity beans.
    Thanks
    Shreyas Kamat

    Shreyas,
    [For those not familiar with our Data Access Object Pattern, the
    beta version of the pattern is available on JDC (needs JDC login) at:
    http://developer.java.sun.com/developer/restricted/patterns/DataAccessObject.html]
    Data Access Objects (or DAOs) are objects that hide the database
    implementation from data clients. Data clients are any objects
    that need to retrieve data from the data source. And the data source
    could be anything that contains data, not necessarily only RDBMSs.
    For example, an external system could be a data source.
    Now using DAOs with Entity beans is applicable only in bean-managed
    persistence (BMP) scenario. In BMP, the entity beans are responsible
    to provide the data load and store implementation in the ejbLoad()
    and ejbStore() methods of the bean implementation. Without using
    the DAOs, the entity bean class will contain all the JDBC code (assuming
    that the data source is an RDBMS), SQL, etc. This makes the
    entity bean class bloated and difficult to manage when changes
    are made to the data logic. In addition, this tightly couples the
    data source implementation with the entity bean implementation.
    By using DAOs, the ejbStore() and ejbLoad() methods are much
    simpler. Also, it is easier to change from one datasource implementation
    to another by replacing the DAOs. Further flexibility is possible
    by employing the DAO factory strategy as described in the DAO pattern
    in our catalog.
    Coming back to you point about making the data access transparent
    to the clients; it is possible to achieve this by using DAO and
    DAO factory strategy. In the current version of the pattern,
    included in the book, we provide sample code to show how
    to design DAO classes and to apply DAO factory strategy.
    On your last point about using java classes instead of entity beans, this
    is not the intention of the DAO pattern. Entity beans serve a different
    purpose in the architecture as coarse-grained transactional components.
    entity beans use DAOs in BMP implementations, but are not replaced
    by DAOs. However, DAO classes are reusable. The same DAO that is
    used by an entity bean to retrieve some data in one application scenario,
    can be reused by a servlet in another application scenario
    that needs the same data, but does not use entity beans.
    So bottom line is that DAOs address the need to data access and
    manipulation and work together with entity beans in BMP implementations.
    thanks,
    -deepak

  • Data Access Object  relationship with other tables

    Hi,
    I have two entities which are related. One is customer other is account.
    I need to get accounts of the customer as well , when I do a search for customer.
    I am using data access objects both for customer and account.
    Now where shall do the above mentioned search.
    Do I have to write one sql in Customer Data Access Object or does the Customer DAO has to refer to Account DAO to get account details.
    Which method is the best.
    Thanking You,
    Chamal.

    I have two entities which are related. One is
    customer other is account.
    I need to get accounts of the customer as well , when
    I do a search for customer.You might want to consider what you want to do if you need to display a list of customers.
    >
    I am using data access objects both for customer and
    account.
    Now where shall do the above mentioned search.
    Do I have to write one sql in Customer Data Access
    Object or does the Customer DAO has to refer to
    Account DAO to get account details.
    Which method is the best.
    If it was me the Account DAO would have a method that takes a customer id and returns a list of Accounts.
    Customer would have a method that used that method.
    That requires two queries though. Your requirements might drive the need for a single query (which returns two result sets.) If that was the case then I would still have the extraction logic in the Account class - the customer class would pass the extracted sub result set to it and it would return an account list.

  • Data Access Objects and associations....

    Ive got a few classes which are 'value based', and represent some configuration for some dynamic part of my application.
    I was going to employ the Data Access Objects pattern (http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html) to decouple the data source (either XML or RDB in this case) from the content.
    In my case though, I have associations between the content.
    E.g, an X contains 0..n Ys' which have 0..1 Zs'.
    So, X has 'getYs()' for example.
    Is the DAO pattern meant for cases like this, or just for single data object cases (E.g, 'Customer') with simple properties?
    I cant see any disadvantages for using it in my case, but wondered if any one has any thoughts on the design?

    The aim of the DAO is to hide the implementation of the datasource to the clients (i.e the classes using it). And the reason is the client should not care how the data is stored. It also means that I can change the way I store my data without changing the client(s) code (the client calls interface methods that do not change).
    If your code satisfies the above, it is implementing DAO, and it should not and does not matter how many Y's are in your X's or Z's...
    Always make a distinction between the general aim of a Design Pattern (its essence) and the (usually simple, even simplistic) examples supplied by different authors to illustrate the pattern.

  • HTTPS:\\ webserive call without passing certificate string

    We are using HTTPS:\\ web service call from our one of the procedure.
    When I did research, I found that, we can't call HTTPS:\\ web service without passing certificate.
    My question is, how should I take care for situation where certificate got expired and need to replace certification.
    I need some alternate way, where there is no need to pass certificate or no need to pass file path as well...

    Hello,
    There was a similar question asked in our alternate forum, see: Access https URLs - SQLA Forum. Currently, certificates are specified manually. We have made an enhancement request for SQL Anywhere web clients to potentially use the OS Certificate store instead, in future versions.
    So in summary, currently you will need to either replace the certificate, or provide an alternate certificate by specifying the certificate string in the stored procedure definition directly:
    CREATE OR REPLACE PROCEDURE ...
    CERTIFICATE '-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----'
    Notably, MobiLink clients can currently use the (Windows or Android) operating system store for certificates if trusted_certificates is not specified at all.
    Regards,
    Jeff Albion
    SAP Active Global Support

  • Close, Hide, Move borderless window without passing Window instance MVVM Light

    Hi everyone,
    I'm now working with an app which is on MVVM Model, and I'm using MVVM Light to make that app . I wonder if I can close the current window and open another one without passing Window instance or not . I've seen a way which helps me to close the current window
    without passing the instance through MVVM Command :
    return new RelayCommand(() => Application.Current.Windows.Cast<Window>().Single(w => w.DataContext == this).Close());
    But what if I handle the MouseDown event, I have to use LinQ so many times.
    Can anyone help me please ?

    If you want to do something with a window without having a reference to it, you could send a message from a class using the Messenger and then subscribe to this message in the window class itself and close it or do whatever from there.
    public class CloseWindowMessage
    ViewModel:
    return new RelayCommand(() => { GalaSoft.MvvmLight.Messaging.Messenger.Default.Send<CloseWindowMessage>(new CloseWindowMessage()); } );
    Window:
    GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<CloseWindowMessage>
    this,
    (action) => this.Close()
    Please refer to the following links for more information about how to use the Messenger in MVVM Light:
    http://stackoverflow.com/questions/16993918/mvvm-light-messenger-sending-and-registering-objects
    https://msdn.microsoft.com/en-us/magazine/dn745866.aspx
    Please remember to close your threads by marking helpful posts as answer.

  • I have all my movies on an external hard drive.  I want to be able to access them without copying everything to my iTunes.  How can I do this?

    I have all my movies on an external hard drive.  I want to be able to access them without copying everything to my iTunes.  How can I do this?

    I think DebinSC might mean using the movies without copying to the iTunes library?
    Maybe the solution is to uncheck this box?
    Or am I barking up the wrong tree?

  • Can I use an radar alarm on my iphone 4, without passing by the telephone card, for example in plane mode?

    Can I use an radar alarm on my iphone 4, without passing by the telephone card, for example in plane mode? This question in order to avoid the roaming when I leave my country for a foreigner one

        Hi there Eartley! That sounds like an amazing opportunity for you! I am glad you are going to be able to study in Italy. The iPhone 6 is an excellent phone to travel with and you should have no problems using a local SIM card while you are in Italy. While I have not been to Italy myself and can not make recommendations for service providers out there, our Global Support Team may be able to help out! Here is where you can get in touch with them http://vz.to/1DgQ1IJ . Have a great trip!
    bryans_vzw
    Follow us at Twitter @vzwsupport

Maybe you are looking for

  • Payment of GR against return PO

    Please note that along with the other purchase order types we have created P.O. Type ZRPO - Return PO. (No. Range – 5000000000- to 5099999999) e.g. Item has been received under ZDOM P.O., GR created, accepted, MIRO Done & payment given to vendor. Aft

  • Very strange!! i got the old web?

    I have a very strange thing that happened and iam trying to figureout what is going on after i tried modifying tens or maybe hundreds of setting trying to solve it. I have a motorola sbg6580 for my home perimeter i have forwared port 80 to my webserv

  • Regarding ABC indicator

    Hi, In our organization if material consumption is more than 1000Qty it will be considered as A category and if it is between 500 to 1000 then B category and less than 500 is C category. Where we can define this in SAP. Thanks and Regards Pavan

  • I wonder how to get the data entries one week to be uploaded into BW system

    HI,SDNs     Our clients requires us to get the whole data entries to be loaded into bw system fo r onw week or get the delta data number to be loaded     How to deal with it? thanks and best regards

  • How do I move/duplicate small objects without CC 2014 live corners getting in the way!?

    Hi folks, I'm finding a problem with live corners on the recent Illustrator CC2014 update... Live Corners used to be a feature of the direct selection tool but now its on both types of selector as default... Much as I love live corners and use it all