:Elementry, my dear Watson.
:
:public class Hans implements Component, Composable, Disposable {
:     ComponentManager manager;
:     DataSourceComponent datasrc;
:
:     public void compose(ComponentManager manager) {
:         if (this.manager == null) {
:             this.manager = manager;
:             ComponentSelector selector = (ComponentSelector) this.manager.lookup(
:                                           DataSourceComponent.ROLE + "Selector");
:
:             datasrc = (DataSourceComponent) selector.select("documents");
:         }
:     }
:}
:

Firstly, thank you for guiding a stupido on the way through
the Avalon area.

1.

Now that my classes compile, thanks to Mr. Holmes, I'm in
the mood to use them ...

When writing a JSP page, how should I call the Hans.compose(),
I mean, what ComponentManager should I provide as an argument?
The class has it's own manager, so I tried suplying null,
which (surprise!) throws NullPointerException.
I suppose I have to call hans.compose() before I can use
the datasrc (and actually retrieve data from DB).

- cut ---
<%@ page language="java" session="true"
import="org.apache.bizserver.docs.*" %>

<jsp:useBean id="container" scope="page"
class="org.apache.bizserver.docs.ContainerComponent"/>

<jsp:useBean id="hans" scope="page"
class="org.apache.bizserver.docs.Hans"/>

<pre>
initializing container ... <% container.initialize(); %> done
user class composing components ... <%-- hans.compose(null); --%> done
disposing container ... <% container.dispose(); %> done
</pre>

- cut ---


2.

I use scope="page", because when using scope="session",
reloading the page says

javax.servlet.ServletException: Could not get class

and the log gently wheeps

ERROR   10111   [casopis ] (): Could not get class
org.apache.avalon.excalibur.component.ExcaliburComponentSelector for role
org.apache.avalon.excalibur.datasource.DataSourceComponentSelector on
configuration element datasources
org.apache.avalon.framework.component.ComponentException: Cannot add components
to an initialized ComponentManager

What's a natural way to solve this - conditionally include a
'container.initialize()'ing code on the top of every page?


Thanks for any help

Jan


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to