Hi,

for certain pages I want to customize markup loading, so the markup is
loaded from another source instead of the standard file location.

Given a method to obtain the markup, getMarkupFileFromSomewhereElse, this
should work as follows (explanation can be found here:
http://www.mkyong.com/wicket/how-do-change-the-html-file-location-wicket/):

public class MyApplication extends WebApplication {

        @Override
        public void init() {
                super.init();   
                ...
                getResourceSettings().setResourceStreamLocator(new 
MyOwnStreamLocator());
                
        }
        
        public class MyOwnStreamLocator extends ResourceStreamLocator
        {
                @Override
                public IResourceStream locate(Class<?> clazz, String path)
                {
                        File markUp = getMarkupFileFromSomewhereElse(clazz);
                        IResourceStream is = new FileResourceStream(markup);
                        IResourceStream standard = super.locate(clazz, path);

                        //return standard; //works always
                        return is; //works only if the desired markup does not 
contain inherited
markup
                }
        }
}

Even if is.getInputStream() gives exactly the same text as
standard.getInputStream(), this leads for any markup containing inheritance
from another markup to the following stacktrace:

ERROR - MarkupFactory              - Markup not found: Base markup of
inherited markup not found. Component class: my.package.HomePage. Enable
debug messages for
org.apache.wicket.core.util.resource.locator.ResourceStreamLocator to get a
list of all filenames tried.
org.apache.wicket.markup.MarkupNotFoundException: Base markup of inherited
markup not found. Component class: my.package.HomePage. Enable debug
messages for
org.apache.wicket.core.util.resource.locator.ResourceStreamLocator to get a
list of all filenames tried.
        at
org.apache.wicket.markup.loader.InheritedMarkupMarkupLoader.loadMarkup(InheritedMarkupMarkupLoader.java:71)
        at
org.apache.wicket.markup.loader.DefaultMarkupLoader.loadMarkup(DefaultMarkupLoader.java:52)
        at
org.apache.wicket.markup.MarkupFactory.loadMarkup(MarkupFactory.java:412)
        at org.apache.wicket.markup.MarkupCache.loadMarkup(MarkupCache.java:448)
        ...

ERROR - DefaultExceptionMapper     - Unexpected error occurred
org.apache.wicket.markup.MarkupNotFoundException: Can not determine Markup.
Component is not yet connected to a parent. [Page class =
my.package.HomePage, id = 0, render count = 1]
        at org.apache.wicket.Component.getMarkup(Component.java:736)
        at org.apache.wicket.Component.internalRender(Component.java:2335)
        at org.apache.wicket.Component.render(Component.java:2298)
        at org.apache.wicket.Page.renderPage(Page.java:1010)
        at
org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:116)
        ...


A bug in the markup itself may not be the problem since the input streams of
both IResourceStreams contain the same text. Only difference is, the
IResourceStream generated by standard implementation works perfectly fine..

Wicket version is 6.7.0. 

Has anyone ever encountered this problem? Thank you in advance!

Martin



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Overriding-markup-loading-results-in-errors-with-inheritance-tp4658319.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to