You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mazabel <m....@snafu.de> on 2013/04/26 16:48:40 UTC
Overriding markup loading results in errors with inheritance
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Overriding markup loading results in errors with inheritance
Posted by mazabel <m....@snafu.de>.
Thank you for the advice. I was able to reproduce the problem with a few
lines of code. I created an issue here:
https://issues.apache.org/jira/browse/WICKET-5163
<https://issues.apache.org/jira/browse/WICKET-5163>
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Overriding-markup-loading-results-in-errors-with-inheritance-tp4658319p4658400.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Overriding markup loading results in errors with inheritance
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
Please create a quickstart and attach it to a ticket in Jira.
I'm interested to see what breaks.
Thanks!
On Mon, Apr 29, 2013 at 1:02 AM, mazabel <m....@snafu.de> wrote:
> Thank you for your reply.
>
> The Wicket help describes how to change the file location the markup is
> loaded from.
>
> Since some of the markup files will eventually be loaded from a data base,
> simply adding another resource folder is not sufficient. I need to override
> ResourceStreamLocator and return a custom IResourceStream. When I do this,
> I
> get the described error for any markup containing inheritence.
>
> It is irrelevant whether I use a FileResourceStream as in my example code
> or
> a StringResourceStream from the markup code or something else, the error is
> always the same.
>
> Putting *exactly* the same markup code to the default location and
> returning
> super.locate(clazz,path), all works fine. Therefore the markup itself has
> no
> errors. Obviously, there is a difference whether I created the stream
> myself
> or use the stream created by standard ResourceStreamLocator, although
> getInputStream() delivers in both cases the same content.
>
> Martin
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Overriding-markup-loading-results-in-errors-with-inheritance-tp4658319p4658369.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Martin Grigorov
Wicket Training & Consulting
http://jWeekend.com <http://jweekend.com/>
Re: Overriding markup loading results in errors with inheritance
Posted by mazabel <m....@snafu.de>.
Thank you for your reply.
The Wicket help describes how to change the file location the markup is
loaded from.
Since some of the markup files will eventually be loaded from a data base,
simply adding another resource folder is not sufficient. I need to override
ResourceStreamLocator and return a custom IResourceStream. When I do this, I
get the described error for any markup containing inheritence.
It is irrelevant whether I use a FileResourceStream as in my example code or
a StringResourceStream from the markup code or something else, the error is
always the same.
Putting *exactly* the same markup code to the default location and returning
super.locate(clazz,path), all works fine. Therefore the markup itself has no
errors. Obviously, there is a difference whether I created the stream myself
or use the stream created by standard ResourceStreamLocator, although
getInputStream() delivers in both cases the same content.
Martin
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Overriding-markup-loading-results-in-errors-with-inheritance-tp4658319p4658369.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Overriding markup loading results in errors with inheritance
Posted by Paul Bors <pa...@bors.ws>.
"MarkupNotFoundException: Can not determine Markup. Component is not yet
connected to a parent." kind of tells you that perhaps you forgot to use
the add() method?
Also see "How to do things in Wicket":
https://cwiki.apache.org/WICKET/how-to-do-things-in-wicket.html
More precisly "Control where HTML files are loaded
from<https://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html>
":
https://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html
Is a little bit out of date, but it should give you the right ideas.
You should also search this users list for past post such as:
http://apache-wicket.1842946.n4.nabble.com/Advanced-Mounting-amp-Markup-Location-td3705032.html
http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-and-panel-with-different-markup-location-td4651853.html
etc.
BTW, does it work when you place the markup in the expected default
location next to your java classes?
~ Thank you,
Paul Bors
On Fri, Apr 26, 2013 at 10:48 AM, mazabel <m....@snafu.de> wrote:
> 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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>