Results 1 to 3 of 3

Thread: import commands-context.xml into application-context.xml

  1. #1
    Join Date
    Mar 2007
    Location
    Germany, Tuebingen
    Posts
    49

    Default import commands-context.xml into application-context.xml

    Hi all,

    does it make sense to import the commands-context.xml into the application-context.xml to get access to the commands / executors via getApplicationContext().getBean("command")?
    Or is it better to define the executor-beans within the application-context.xml?

    Thanks,
    Torsten

  2. #2
    Join Date
    Feb 2006
    Posts
    118

    Default

    This can lead to problems. Keep in mind that the commands-context.xml file is "per window". That is, it is processed by the usual Context mechanisms, as well as a custom bean post processor, which automatically sets the ApplicationWindow property of any ApplicationWindowAware class.

    This makes for interesting experiments, especially if you are trying to have a single toggle command to control some non-GUI, non-window specific (i.e. global) function. Unfortunately, since the contexts are created anew and processed independently when you open more than one window, it means that "singleton" in commands-context doesn't actually mean what you'd hope. It is a singleton *IN THAT CONTEXT*, true, but there is more than one context!

    In order to get around this, I ended up creating a ToggleCommand in the main richclient-application-context.xml, and then referred to it in commands-context.xml. Unfortunately, being that the command was created in the main context, the command was never configured properly. i.e. the .label, .image, etc was never set up. This seems to be a weakness that is not easy to correct within the framework, for some reason.

    I ended up creating a class that is specifically used to configure any Commands defined in the main application-context, and passed the command names/ids as a parameter to the custom configurer.

    Messy, but it actually works. If you need help getting this to work in your app, let me know.

  3. #3
    Join Date
    Mar 2007
    Location
    Germany, Tuebingen
    Posts
    49

    Default

    Hi rdawes,

    thank's for the hint that the commands-context.xml is used per window. I didn't realize that until now - but it makes definitively sense.
    My application uses just one window, so it wouldn't be a problem. But including the commands-context is not a nice solution.
    I ended up with placing the command-executors into the application-context.xml and defining the actual commands within the commands-context.xml.

    Thanks for your advice,
    Torsten

Posting Permissions

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