Any reason why you can't wrap DefaultSpecificationSource in the same way you
wrap DefaultPageSource?
----- Original Message -----
From: "Dorothy Gantenbein" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 24, 2002 11:24 AM
Subject: [Tapestry-developer] Dynamically Loading Pages (Round II)
> Howard -
>
> Thanks for all your input and patience.
>
> Here is another shot at this problem. Whenever a page is requested that
is
> not defined by the application file, then I want to dynamically load the
> specification of the page. To do this, I decorated the PageSource. For
my
> engine class, I added the following method...
>
> public class StudyServerEngine extends SimpleEngine
> {
> ...
>
> protected IPageSource createPageSource()
> {
> return new DynamicPageSource(getResourceResolver());
> }
>
> ...
> }
>
> My DynamicPageSource decorates the page source. Basically, its job is to
> intercept getPage requests and dynamically load the page when it is
needed.
>
> public class DynamicPageSource
> implements IPageSource, IRenderDescription
> {
> public DynamicPageSource(IResourceResolver resolver)
> {
> super();
> _delegate = new PageSource(resolver);
> }
>
> public IPage getPage(IEngine engine, String pageName, IMonitor monitor)
> throws PageLoaderException
> {
> // check if page exists before trying to instantiate page
> ApplicationSpecification applicationSpec =
engine.getSpecification();
> PageSpecification spec =
> applicationSpec.getPageSpecification(pageName);
> if (spec == null) {
> _log.debug("Page not found="+pageName);
> spec = _parser.getFactory().createPageSpecification(pageName);
> _log.debug(" found spec="+spec);
> applicationSpec.setPageSpecification(pageName, spec);
> }
>
> // instantiate the page
> IPage page = _delegate.getPage(engine, pageName, monitor);
> return page;
> }
>
> public void releasePage(IPage page)
> {
> _delegate.releasePage(page);
> }
>
> public void reset()
> {
> _delegate.reset();
> }
>
> public IBinding getFieldBinding(String fieldName)
> {
> return _delegate.getFieldBinding(fieldName);
> }
>
> public IBinding getStaticBinding(String value)
> {
> return _delegate.getStaticBinding(value);
> }
>
> public IAsset getExternalAsset(String URL)
> {
> return _delegate.getExternalAsset(URL);
> }
>
> public IAsset getContextAsset(String assetPath)
> {
> return _delegate.getContextAsset(assetPath);
> }
>
> public IAsset getPrivateAsset(String resourcePath)
> {
> return _delegate.getPrivateAsset(resourcePath);
> }
>
> public void renderDescription(IResponseWriter writer)
> {
> _delegate.renderDescription(writer);
> }
>
> // private stuff
> private static final SpecificationParser _parser = new
> SpecificationParser();
> private static final Logger _log =
> Logger.getLogger(DynamicPageSource.class);
>
> private PageSource _delegate;
> }
>
> What I am still trying to figure out is how to integrate the
> DefaultSpecificationSource decoration.
>
> Thanks...
> Dorothy
>
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer