Results 1 to 3 of 3

Thread: Passing information between views

  1. #1
    Join Date
    Aug 2004
    Posts
    3

    Question Passing information between views

    I have 2 views: one for finding Persons and one for viewing a Person's information. When the user double clicks on the list in the first view, the second view should open with that user's data.

    I tried to stick to the richclient api by using showViewCommand.execute(Collections.singletonMap(" person",getSelectedPerson())), but I don't know how I can get a hold of the parameter in the view that is being opened.

    I have no problem solving the problem by injecting the same personHolder object
    into both views and using that as a means of communication, but I am wondering what the proper spring-richclient way to do this would be?

  2. #2
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    This is more a general swing, of GUI even, concept than specifically a Spring RCP one. But, it's one that doesn't tend to be discussed much in the swing tutorial etc.

    You basically want to use events and listeners of some sort. Decouple your views so they know nothing about each other. The first view fires an event when the double click happens, that's all. The event has a payload containing iinformation (eg whole object, id, ...) about what was selected. The second view listens, and then reacts, to those events.

    The Spring application context has an event mechanism built in that can be used. Personally, I'm using the event listener framework (ELF) which adds a little functionality, such as event channels and throtteling. There's some other (event bus?) projects around also that help with the same thing.

    Jonny

    Quote Originally Posted by karel1980
    I have 2 views: one for finding Persons and one for viewing a Person's information. When the user double clicks on the list in the first view, the second view should open with that user's data.

    I tried to stick to the richclient api by using showViewCommand.execute(Collections.singletonMap(" person",getSelectedPerson())), but I don't know how I can get a hold of the parameter in the view that is being opened.

    I have no problem solving the problem by injecting the same personHolder object
    into both views and using that as a means of communication, but I am wondering what the proper spring-richclient way to do this would be?

  3. #3
    Join Date
    Aug 2004
    Posts
    3

    Default

    That's indeed what I've been doing (the second view calls personHolder.addListener(this) etc...). I'm asking because there might have been be some built-in support in spring-richclient.

    In my case it would have been nice if showViewCommand.execute(Map) would open the view and then call viewToShow.onShowView(Map) if the target view implemented a (hypothetical) interface with an onShowView(Map) method.
    It's just a random idea though, maybe it would just couple the application to the framework more than necessary.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •