You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rajesh Kalluri <rk...@manduca.com> on 2002/08/08 19:57:11 UTC

How to call a plugin from an action or some thing

Hi All,

I am trying to use the PlugIn capabilites in 1.1 to load some collections to
populate my dropdowns.

I have a requirement that those collections in the scope be refreshed when
the data changes. What is the prefered method to reload the plugin init()
method.

Is any one doing this kind of stuff, any advice on how to do this.

Regards

Rajesh


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to call a plugin from an action or some thing

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 8 Aug 2002, Rajesh Kalluri wrote:

> Date: Thu, 8 Aug 2002 13:57:11 -0400
> From: Rajesh Kalluri <rk...@manduca.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: How to call a plugin from an action or some thing
>
> Hi All,
>
> I am trying to use the PlugIn capabilites in 1.1 to load some collections to
> populate my dropdowns.
>
> I have a requirement that those collections in the scope be refreshed when
> the data changes. What is the prefered method to reload the plugin init()
> method.
>
> Is any one doing this kind of stuff, any advice on how to do this.
>

Rerunning the plugin's init() method doesn't sound like the right way to
design this sort of thing.  What I would suggest is abstracting the code
that initializes your collections into a separate bean that is called by
the plugin.  Then, you can also have a separate event (say, a background
timer thread, or a request to a special administrative Action that is part
of your app) that can call the same separate bean and trigger the refresh.

The benefits of this include:

* There is still only one copy of the code to maintain the
  collections.

* You don't confuse future maintainers of your code by calling
  the init() method at times other than app startup (and possibly
  breaking other code in the plugin that assumes it is called
  only once).

* You can add additional "triggers" that cause the reload later,
  simply by making the "collections refresh" bean available to them
  (say, as a servlet context attribute) so that anyone who needs to
  can call the refresh() method on it.

> Regards
>
> Rajesh

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>