Observer/Observable design pattern

Is there a way to implement the Observer/Observable pattern in a pure java FX 1.2 desktop Application?
And if yes how ? :)

You can use the real stuff, as shown in some threads (eg. in [Cannot bind a string array|http://forums.sun.com/thread.jspa?threadID=5425718] I show an example).
This is necessary only to bind Java variables to JavaFX code.
Now, as said above, in pure JavaFX code, you use binding. And the 'on replace' facility is useful too, as changes trigger actions.

Similar Messages

  • Observer Design Pattern: Looking for redesign ABAP OO code example

    Hello folks,
    I am looking for an example for ABAP OO code that has been redesigned by applying the Observer Design Pattern. I would be very interested in both the code before as well as the code after the pattern is being applied.
    Thanks in advance and kind regards, Alex

    Observer can be implemented using the EVENTS.
    I had recently implemented the observer at one of my client's place. I had screen with so many ALVs. One ALV was kind of editable and other were just showing the information of the current row as well as some total information. So, initially I started with the Main ALV and SUB(1 and 2) for other ALVs. Now, when I need to refresh my ALVs based on the main ALV data, I had to explicitly update the data of the each Sub ALV. The code was kind of static and requirement was not yet fixed.
    Later on we need to add one more ALV on the same screen. It was easy to change the existing method where I was doing the explicit refresh of each ALV. But I thought of using the Events.
    I created an event REFRESH_DETAILS for main ALV. so, when data gets changed (which I was catching by DATA_CHANGED event of ALV), I raise the event.
      RAISE EVENT REFRESH_DETAILS
        exporting new_data = it_Data.
    In Sub ALVs, I created the event handler method to handle the event REFRESH_DETAILS of the main ALV.
      methods: handle_refresh_details
          for event REFRESH_DETAILS of ZCL_MAIN_ALV.
    I also had to register the Handler.
      SET HANDLER me->handle_refresh_details FOR ALL INSTANCES.
    I'll soon write a post on my [ABAP Help blog|http://help-abap.zevolving.com/] with all the details.
    Regards,
    Naimesh Patel

  • When I use SmartSync Notifier/ Observer design pattern

    Hi all,
    I have development a simple SmartSync Application with S01 syncBO type.
    I not use SmartSync Notifier/ Observer design pattern  for read the local syncbo and local delta.
    When I have to use and I have to implement the SmartSync Notifier/ Observer design pattern ?

    Hi Rocco,
    <b>SmartSync uses Notifier/Observer design pattern for applications to access inbox/outbox. Application has a read-access to the passed SyncBoOutDelta instance during the notification</b>
    The usage of this API depending upon your custom requirement. If u want to monitor the number of new records(for example sales or like thAT) u have created in the client device , then that delta records will be there in the Smart Sync Outbox. If u want to monitor this new records then u have to use the API related with (Outbox - SyncBoOutDelta)..
    Then comes the Inbox.The new records came from the Server will be there in the inbox of the MI client. This new records may be the response of number of new records u ahve created in the client device . If u want to monitor the number of new records that has downloaded to the MI client , then u have to make use of the SmartSyncInboxDelta..
    Using this APIs , u can also find out the errors happened during the particular synchronization. For this APIs are also available...
    refer these helps also..
    SyncBoChange
    This interface is the base interface to describe SyncBo delta change. Application should not use the interface directly, instead, use its sub interfaces - SyncBoInDelta, SyncBoOutDelta.
    http://media.sdn.sap.com/public/html/submitted_docs/MI/MDK_2.5/content/javadoc/com/sap/ip/me/api/smartsync/SyncBoChange.html
    SyncBoInDelta
    http://media.sdn.sap.com/public/html/submitted_docs/MI/MDK_2.5/content/javadoc/com/sap/ip/me/api/smartsync/SyncBoInDelta.html
    SyncBoInDelta is used to apply SyncBo delta data from backend to client. The SyncBoInDelta could may be a delta data from either the backend or other devices, or a response to the previously uploaded SyncBoOutDelta from the client, which can be distinguisehd by the SyncReply information included within the SyncBoInDelta
    SyncBoOutDelta
    SmartSync uses Notifier/Observer design pattern for applications to access inbox/outbox. Application has a read-access to the passed SyncBoOutDelta instance during the notification
    http://media.sdn.sap.com/public/html/submitted_docs/MI/MDK_2.5/content/javadoc/com/sap/ip/me/api/smartsync/SyncBoOutDelta.html
    Regards
    Kishor Gopinathan

  • Confusion about observer design pattern

    Hi all,
    I have a case related to observer design pattern and I feel a bit confusion.
    Suppose there is a gui class which consists of 2 buttons connect and disconnect to the network and a socket class handling these two operations. Then socket class will inform the gui class if the operation is success or not. By applying the observer design pattern. gui class is observer and socket class is obserable. however I feel confusion as observer will send a command e.g. connect to observable.

    dophine wrote:
    my confusion is that the observer is the event source not the listernerIt is an observer but it also takes another role: the controller of the observable.
    kind regards,
    Jos

  • Observer-observable pattern question

    Hi all there!!
    I reckon that in the observer-observable pattern, there is an notfiyObserver(object obj) method to invoke the Observer to receive the reference instance obj, and in the observer class, as there is a method called update(observable obr, object obj2), obj is subsituted into obj2 to complete the whole process. so obj from Observable is sent to Observer as obj2. Am i right?
    Because I've tried such thing, but seems that the observer receives null object...... sorry that I'm not going to post the code here /_\!! Thank you

    Are you sure you are calling notifyObservers(Object arg) and not just notifyObservers()? Because in the later case, the "observer" would receive null as a second argument in its "update" method.
    Try to print or do some operation on your arg object before passing it in notifyObservers method to see if it's really not NULL.
    Hope this helps..

  • Choice of design pattern for data acquisition system

    Hello all
    I have a trouble about selecting the suitable design pattern / architecture for a data acquisition system. 
    Here is the details of the desired system:
    There is data acquisition hardware and I need to use it by observing parameters on User interface. 
    the data acquisiton period, channel list to scan should be chosen on User interface. Besides, there are many user interface interactions. e.g. if user selects a channel to add scanlist, then I need to enable and make visible some other parts on user interface. 
    When user completes the channel selection, then he will press the button to start data acquisition. Then I also need to show the scanned values on a graph in real time and log them in txt file.
    I know that I cannot use producer consumer pattern here. because the data acquisition loop should wait for parameters to scan channels. and it works in a given period by user. so the user interface loop performs higher rate then consumer loop (data acquisition loop). it means queue will be bigger bigger. if I use notifier it will loss some data come from user interface. 
    is there any idea about that ? is there any suitable design pattern for this case ? 
    Thanks in advance
    best regards 
    Veli BAYAR
    Embedded Systems Software and Hardware Engineer 
    "You live in a graphical world. Why not program in one?"
    Solved!
    Go to Solution.

    johnsold wrote:
    Veli,
    I recommend the Producer/Consumer model with some modifications.
    You might need three loops.  I cannot tell for sure from your brief description.
    The User Interface loop responds to the user inputs for configuration and start/stop of acquisition.  The parameters and commands are passed to the Data Acquisition loop via a queue. In this loop is a state machine which has Idle, Configuration, Acquisition, and Shutdown states (and perhaps others). The data is sent to the Processing loop via a different queue. The Processing loop performs any data processing, displays the data to the user, and saves it to file. A notifier can be used to send the Stop or shutdown command from the User Interface loop to the other loops.  If the amount of processing is minimal and the file write times are not too long, the Processing loop functions might be able to occur in the Timeout case of the UI loop Event structure.  This simplifies things somewhat but is not as flexible when changes need to be made.
    I am not sure that a Design Pattern for this exact setup exists but it is basically a combination of the Producer/Consumer (Events) and Producer/Consumer (Data) Design Patterns.
    Lynn
    Check out this thread: http://forums.ni.com/t5/LabVIEW/Multiple-poll-case-structures-to-event-help/td-p/2551309
    There are discussions there about a 3-loop architecture that may help you.
    Jeff
    Jeffrey Zola

  • Design Pattern and ABAP Objects

    Hello Friends,
    I would like to know, if ABAP Objects can be used to do pattern oriented programming ?
    For example GANG of four has provided almost more then 30 design pattern ( MVC, singelton, Obserable, FACADE,,,etc) can we implement patterns using ABAP ??
    Many thanks
    Haider Syed

    Hi,
    Take a look at the following site:
    http://patternshare.org/
    It has all the basic patterns from the GOF and a lot more. I can recommend the ones from Martin Fowler but be sure you start with the ones from the GOF.
    All patterns are described by using UML so it's very easy to translate them into ABAP OO code.
    Regarding your other question. For the observer pattern I used an interface which the SAP had already created if_cm_observer and created my own abstract observable class. The observable class is nearly a 100% copy of the java.util. one
    regards
    Thomas

  • Which Design Pattern and how to design using OOP this scenario

    I am having trouble designing a module, can anybody help me?
    Because it will be hard to maintain this kind of module, I also think that this can test my skill of design pattern usage.
    Requirement
    This is basically an agricultural project (web application). I need to design a module where some calculation takes place.
    There are different crops involved like maize, tomato, okra etc. Each of these crops has different traits.
    Each trait has a measurement scale which lies in integer like 200-1000. Now let's say I have planted the crop and done measurement noted down the traits. Now I want to do some sort of measurement. Some measurements are simple and some are complex.
    Example
    Lets take an example of crop maize. I have recorded observations for 15 traits. (We'll use trait1-trait15 as examples, the actual name can be like plt_ht, yld, etc.)
    I recorded 5 observations for each trait:
    trait1 trait2 trait3 trait5 trait6..... trait15
    01,02,03,04 01,02,03,04 01,02,03,04
    User logs into system and selects his crops and enters data for these observations. I have to calculate either average or sum of the data entered for each trait.
    Complexity / centre of the problem
    So far it's simple but complexity comes when I have some different formulas for some of the traits.
    Example: trait YLD has a formula based on which I have to calculate its value, which may also depend on some other traits. Each different crop can have different traits.
    All this I am able to do - whenever user selects crop I will check for those specific traits and do calculations (if it's not a special trait then I either average or sum it, based on db entry), but there is a lot of hard coding.
    I would like to have suggestions on a better way of handling this.
    My code needs to handle both simple and complex calculations.
    Simple calculations are easy, I have take average of value entered for trait.
    The problem comes when I have to do complex calculations, since each crop have different traits with their own formulas, so to calculate I have to check for crop and then for complex trait. So I have to hardcode the trait name of complex traits.
    Can any tell me how I can design this using Java oops [?!?] so that I can make it generic?
    I have about 10 different crops. Some calculations are specific to crops, so there will be lot of code like the if below:
    hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("MZ") && traitName.equalsIgnoreCase("Shelling")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPoint, dataTraits, traitValues,dataPvalues, dataPoint, type);
        avg=avg*dataPoint;
        traitAvg=getMaizeYeild(traitName, traitAvg, population, avg, hybrid, area);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YLDGM")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPoint, dataTraits, traitValues,dataPvalues, dataPoint, type);
        //avg=avg*dataPoint;
        Object[] dataValues=getOKRAYield(traitName, traitAvg, population, avg, dividend,hasZeroValue,hybrid,repl);
        traitAvg = (HashMap<String, Float>) dataValues[0];
        hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("HP") && traitName.equalsIgnoreCase("w1-w10")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPts, dataTraits, traitValues,dataPvalues, dataPoint, type);
        avg=avg*dataPoint;
        Object[] dataValues=getHotPepperYield(traitName, traitAvg, population, avg,dividend,hasZeroValue,hybrid,repl);
        traitAvg = (HashMap<String, Float>) dataValues[0];
        hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("TLSSG_70")) {
        traitAvg=calculateTLCV(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues,50);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("TLSSG_100")) {
        traitAvg=calculateTLCV(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues,50);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg, dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("ELCV_60")) {Can anybody think of a way to make a generic approach to this?

    There are crops and each crop have traits , traits are actually a mesuremet
    scale to decide growth of a seed of a particular crop.
    This module is to for planters to observe growth of seeds sowed of certain
    crops and take down n no of observation for each trait and upload in csv format.Once they enter
    data i have to either avg out the values or sum the values or sometimes
    there are more complex function that i have to apply it may differe for each
    trait .This is the whole module about.Just to give an idea about how they
    will enter data
    Hyubrid(seed) trait1 trait2 trait3 trait5 trait6..... trait15
    Hybrid1 01 02 03 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    Once they enter data in this format i have to give result something like
    this.
    Here avg colum does not necessaryly mean avg it can be sum or any formula
    based resutl.Hybrid is the seed for which they record the observation.
    I have shown avg column only for two tratis it is actually for all the
    traits.
    Hyubrid(seed) trait1 Avg trait2 avg trait3 trait5 trait6..... trait15
    Hybrid1 01 01 02 04 03 04 01
    HYbrid2 04 04 06 10 08 04 01
    HYbrid2 04 04 06 12 08 04 01
    HYbrid2 04 04 06 14 08 04 01
    HYbrid2 04 04 06 12 08 04 01
    Hope this clarifies atleat a but
    The data are not correctly indented but there is no way i can format it.

  • Design pattern -- using the correct one...?

    I'm in need of some advice regarding design patterns in general.
    I have a prototype whereby Objects B, C and D observe Object A's attribute (let's call it theAttribute -- imaginative, eh? )
    In my system, every time theAttribute is changed, I've implemented the Gang's Observer pattern so that the observer objects are notified (...and do something with the information that Object A has changed in some way... they basically update a theTimestamp attribute when the subject's updated... but that really is beside the point right now).
    However, only ONE observer will ever be created for each observable subject.
    To my dismay, I've just been reading on the IBM Research site that the memory implications of this are horrendous (that for potentially a great many subjects only having a few observers each is bad practice) -- d'oh.
    I've looked at other ways I could achieve what I need to without the above practice, but the only things I can come up with are the Mediator pattern or the State pattern, neither of which I'm sure are ideal (the former because of I'm worried that it'd be total overkill, the latter because I don't really need dynamic reclassification if the truth's told, I think).
    Anyone got any thoughts on this? (I've considered referencing observers with their observables using a hash table but don't really wish to go down that route unless absolutely neccesary... it seems a bit like putting electrical tape over a sparking wire :) I'd rather just do it properly).
    Sarah.

    However, only ONE observer will ever be created for each observable subject.If you can absolutely, positively, definitely, mathematically, logically, legally
    and morally prove that fact, indeed, you're wasting some resources here,
    a couple of hundred bytes mayhap ...
    In the mean time, keep your Observer/Observable pattern/implementation
    or have a look at the PropertyChangeSupport class ...
    kind regards,
    Jos

  • Design Patterns that are used in standard j2se/j2ee classes/interfaces

    Hi All,
    I am understanding following design patterns (used within standard j2se/j2ee):
    Adapter
    Facade
    Composite
    Bridge
    Singleton
    Observer
    Mediator
    Proxy
    Chain of Responsibility
    Flyweight
    Builder
    Factory Method
    Abstract Factory
    Prototype
    Memento
    Template Method
    State
    Strategy
    Command
    Interpreter
    Decorator
    Iterator
    Visitor
    I want to see if/where these design patterns are used in j2se/j2ee classes/interfaces. i am looking for few examples of standard java classes/interfaces/cases where these design patterns are used by jdk developers.
    for e.g.
    WindowAdapter class is an example of Adapter DP.
    JOptionPane is an exmple of Facade DP.
    MouseListener is an example of Observer DP.
    Similarly, where can find examples of jdk classes/interfaces of the remaining DPs.
    I searched a lot of books, but they explain the DPs by creating their own classes/interfaces.
    I would like to see where these DPs are already utilised in std j2se/j2ee
    thanks,
    Madhu_1980

    877316 wrote:
    I searched a lot of books, but they explain the DPs by creating their own classes/interfaces.
    I would like to see where these DPs are already utilised in std j2se/j2eeWell, you can go through the javadocs first, they sometimes mention the pattern used.
    Then you can get the sources for the jdk and go through the classes yourself, identifying the patterns.

  • Design Pattern help needed for MDI application

    Hi,
    I am writing an mdi application which contains a JSplitPane. The left pane contains a JTree and the right contains a JDesktopPane which houses n number of JInternalFrames. The JInternal Frames need access to the JTree. Also both panes (objects w/in) need access to elements of the JFrame. I am currently implemeting access by making most of the JFrame objects static and creating getter/setter methods for access. Does anyone know any desing patterns I might use to solve this dilemma?
    Thanks,
    John

    The observer design pattern causes the child objects to chage state when the parent changes state. The type of pattern I need would allow the child objects of the parent JFrame to be available globally without having to make them static. I am wrong in this? Would the observer pattern solve this issue.

  • What Design Pattern - Change Language functionality

    On my application, I will have a series of buttons to choose
    a language. When the user chooses a language, all control labels,
    pop-up messages and others will change at the chosen language.
    I would like to do this from an OOP point of view and use
    Design Patterns. Which one would you recommend to use?
    My guess is the Strategy Pattern. Am I right?
    Thanks for any comment or link.

    The Strategy Pattern is used to swap algorithms dynamically.
    Based on user input a decision can be made to run a (set of)
    function(s). This behaviour is encapsulated in seperate objects.
    You just want to swap data at runtime. Or maybe set some
    behaviour regarding specific functions in languages like the way
    currencies are handled, measurements and the like. The latter would
    be implemented as Interpreter Pattern.
    When it's merely data that needs to changed/loaded at
    runtime, than it's more like a change of the Model in the MVC
    design pattern, using an Observer to notify all registered
    'listeners' and using a Command to get the thing going.

  • RMI + Observable/Observer trouble

    I'm trying to develop the following:
    Local:
    A Swing JFrame object which contains some JPanels that should Observe the actions of server's BusinessLogic.java
    Both sides:
    An interface that contains the declaration of the methods in server's business logic.
    RemoteObserver.java
    RemoteObservable.java
    RemoteObserverImpl.java
    RemoteObservableImpl.java
    Server:
    One Observable class that contains the business logic and notifies some changes and implements the Interface.
    Other classes.
    I'm using the latest JDK version.
    I have some classes to do the RMI + Observable/Observer thing but I don't know how to apply them to my application.
    Here's what i've done so far:
    public class MainFrame extends JFrame {
         public static final String serviceName = "RemoteServer";
         private String host = "localhost";
         private RemoteBusinessLogicInterface remoteLogic;
         public MainFrame(String frameTitle) {
              super();
              setTitle(frameTitle);
              setSize(700, 600);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              System.setProperty("java.security.policy", "client.policy");
              setRemoteServer();
              ObserverPanel observerPanel = new ObserverPanel(
                        remoteLogic);
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(observerPanel, BorderLayout.CENTER);
              this.setVisible(true);
         public void setRemoteServer(){
              try {
                   if (System.getSecurityManager() == null)
                        System.setSecurityManager(new RMISecurityManager());
                   String rmiUrl = "rmi://" + host  + "/" + serviceName;
                   remoteLogic = (RemoteBusinessLogicInterface) Naming.lookup(rmiUrl);
              } catch (ConnectException ex) {
              } catch (UnknownHostException ex) {
              } catch (Exception ex) {
         public static void main(String[] args) {
              MainFrame f = new MainFrame("Title");
    public class ObserverPanel extends JPanel{
         private DefaultListModel items;
         private JList list;
         public ObserverPanel(RemoteBusinessLogicInterface remoteLogic) {
              items = new DefaultListModel();
              list = new JList(items);
              list.setVisibleRowCount(24);
              JScrollPane scrollPane;
              scrollPane = new JScrollPane(list);
              setLayout(new BorderLayout());
              add(scrollPane,BorderLayout.CENTER);
         public void update(RemoteObservable observable, Object objektua) {
              System.out.println("Change notified");
    public interface RemoteBusinessLogicInterface extends RemoteObservable{
         public void insertData(int number, String code, Date date) throws RemoteException;
         public void submit() throws RemoteException;
         public void clear() throws RemoteException;
    class RemoteBusinessLogic extends RemoteObservableImpl implements
              RemoteBusinessLogicInterface {
         public static final String serviceName = "RemoteServer";
         public RemoteBusinessLogic() throws RemoteException {
         public void clear() throws RemoteException {
              setChanged();
              super.notifyObservers();
         public void insertData(int number, String code,
                   Date date) throws RemoteException {
              System.out.println("Something");
              setChanged();
              super.notifyObservers();
         public void submit() throws RemoteException {
              System.out.println("Something");
              setChanged();
              super.notifyObservers();
         public static void main(String[] args) {
              System.setProperty("java.security.policy", "client.policy");
              if (System.getSecurityManager() == null)
                   System.setSecurityManager(new RMISecurityManager());
              try {
                   RemoteBusinessLogic serverObject = new RemoteBusinessLogic();
                   try {
                        java.rmi.registry.LocateRegistry.createRegistry(1099);
                        Naming.rebind(serviceName, serverObject;
                        System.out.println("Server launched");
                   } catch (MalformedURLException e) {
                   } catch (Exception e) {
              } catch (RemoteException e1) {
    }RMI works OK, but I don't know how to tell the server which are his observers. I know I have to use the addObserver (RemoteObserver ro) method but I don't know how to tell the server which are the GUI instances (which are the observers) so that I can add them.
    Any help will be welcomed. Thanks.
    Bye.

    Hello Vitor,
    Simply have your clients give your observable server object a remote reference to their observer object.
    It would look something like this:
    server.addObserver(new Remote(myObserver));Your server object would keep a list of its observers, and call them whenever it wants, using some interface method like:observer.stateChanged(someData);Essentially, design it just as if the observers were local.
    John

  • Observer/Observable vs. EventListener

    Can anybody tell me why Observer/Observable would be used in a situation rather than implementing EventListener? On the surface they seem redundant, but I'm hoping there's an explanation as to when and why you would use one over the other.
    Thanks.
    craig

    I've been wondering the same thing myself and have been able to make the following reasonings:
    - The Java Observer-Observable mechanism is "quasi-transactional" in the sense that Observers are not strictly notified when any change is made, but rather when the Observer decides to notify its registered Observers. Observers can still inquire (via hasChanged) if the Observable has been updated, so atomicity is not guaranteed for a set of changes (short of providing a bulk mutator).
    - The EventListener pattern is littered with various support implementations for firing events. The java.beans package has support classes for its listeners, as do AWT and Swing. In general the EventListener pattern is more of a pure pattern since the implementation is not embedded (as with the Observer-Observable mechanism).
    - The Observer-Observable mechanism seems to predate the JavaBeans specification in the naming conventions. I am personally not a frequent user of IDE's, so the following statement may be way off, but is an educated guess: It's quite likely that most IDE's cannot introspect the Observer-Observable mechanism the way they can with the EventListener pattern.
    - Referrent to the previous item, it is also not possible to use the standard JavaBeans Introspector to get an EventSetDescriptor for a JavaBean that implements an Observer. (A brief examination of the sources for Introspector shows this to be the case. I suppose one could write a custom BeanInfo to make an aggregated or superclass Observer appear with an EventSetDescriptor...)
    - The notification parameter for the Observer-Observable mechanism is an Object.
    - The notification parameter for an EventListener is an EventObject with some concrete extension that is commensuate with the events processed by the EventListeners.
    As I type this, I think I've convinced myself that the EventListener mechanism is probably preferrable in general to the Observer-Observable pattern for the following reasons:
    - First-class introspection support.
    - Limited contortions to make use of the framework (refer to the countless threads asking for advice on how to use the Observer-Observable mechanism without resorting to aggregation and subclassing).
    The main contention that I'd had with EventListeners over the Observer-Observable mechanism has been the quasi-transactional nature of the latter. In particular, it's nice to sometimes bundle changes to an object before sending out change notifications, especially with GUI applications (versus an "update-model-then-update-views-some-time-later" approach.) Nevertheless, it's possible to bundle change notifications with EventListeners. I guess I was wrapped up in using a PropertyChangeListener which has a property-by-property-change-notification nature.
    Hope my musings help...

  • How can I develop a web application using EJB design pattern?

    I have searched over the web and found quite a lot of tutorials on how to use the EJB design pattern.
    I know that there will be a home interface, EJB object interface and a SessionBean.
    But the tutorials often only cover a single class, this made me unable to get a complete picture of how EJB design pattern can be implemented into a whole system.
    I am now required to devleop an online shopping web application using EJB and JSP page.
    I think I will need to create a lot of classes: Member, ShoppingCart, Product...etc.
    What I want to ask is that, do I need to create a home interface, EJB object interface and a SessionBean for each of these classes?
    I really need some ideas on how to develop this system using EJB + JSP pages.
    Many thanks to you all.

    For every EJB that you want to create, you will need to code a home and remote interface and a bean class.
    You could start getting your ideas here
    http://www.theserverside.com/books/wiley/masteringEJB/
    http://www.coreservlets.com

Maybe you are looking for

  • Taking More Time while inserting into the table (With foriegn key)

    Hi All, I am facing problem while inserting the values into the master table. The problem, Table A -- User Master Table (Reg No, Name, etc) Table B -- Transaction Table (Foreign key reference with Table A). While inserting the data's in Table B, i ne

  • Attachments from Workflow to ABAP Webdynpro launched from UWL

    Hi All, You might have seen a recent post from me for sending attachments from ABAP Webdynpro to Workflow. I could do that by just calling SAP_WAPI_ATTACHMENT_ADD. I didnt have to create an instance of the SOFM object by passing the ATT_ID from this

  • Reg: Interview Question

    Hi all I have an interview on below topics pls calrify 1. Project objective is to propose new SD pricing condition (it will hit CO Module), 2. carry out blueprint workshop discussion, 3. Configuration on CO module, 4. Prepare unit test scripts & carr

  • Drag and drop to HD

    I want to be able to "Drag and Drop" to the Hard Drive.... but don;t seem to be able to.

  • How can I get the values on Xaxis and Yaxis?

    Hi, I would like to get the values that are on the axis X and Y or to get the base value and the ticks interval for calculating the values.