Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Issues about Command pattern in UI

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I'm thinking of using command pattern together with AbstractAction in UI to separate UI from application logic like openning connection to DB, searching flight, booking flight and closing connection. I have some issues to ask for clarification before I go actual implementation.
  • How to pass parameters to the command's execution method when an event/action is invoked. For example, in a OpenConnection dialog box, you enter DB URL in the text field, then press Connecting button, the text value in the field should be passed the command.
  • How to update UI after you finish the command execute. For example, after you open connection successfully, you should update UI, and go to SearchFlight etc.


  • Additionally, execute() in command patter should be generic so it can serve all logic.
    Your comments are really appreciated.
    Thanks,
    Lijun
     
    Greenhorn
    Posts: 23
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I'm using a command pattern. For my command objects, I implemented a command interface and in the constructor took whatever parameters I needed to perform the behavior. Sometimes this meant passing a reference to the table.
    In my client, I simply added the listner I wanted passing in a new command object (which was taking whatever the command object needed).
    I'm finding as I proceed with my project it is _very_ easy to add the same command object (say book flights) to my client in various areas (such as a menu bar, a JButton or a JToolBar.)
    Hope this helps some...it sounds like you are on the right track.
     
    Don't get me started about those stupid light bulbs.
      Bookmark Topic Watch Topic
    • New Topic