final Session session = Session.get();
final String style = session.getStyle();
final Locale locale = session.getLocale();
MarkupResourceStream markupResourceStream = null;
Class< ? > containerClass = getClass();
while (!(containerClass.equals(MarkupComponentBorder.class)))
{
String path = containerClass.getName().replace('.', '/');
IResourceStream resourceStream = locator.locate(containerClass, path, style, locale,
markupType);
// Did we find it already?
if (resourceStream != null)
{
ContainerInfo ci = new ContainerInfo(containerClass, locale, style, null,
markupType);
markupResourceStream = new MarkupResourceStream(resourceStream, ci, containerClass);
break;
}
// Walk up the class hierarchy one level, if markup has not
// yet been found
containerClass = containerClass.getSuperclass();
}
if (markupResourceStream == null)
{
throw new WicketRuntimeException("Could not find markup for component border `" +
getClass().getName() + "`");
}
try
{
Markup markup = Application.get()
.getMarkupSettings()
.getMarkupParserFactory()
.newMarkupParser(markupResourceStream)
.parse();
return new MarkupStream(markup);
}
catch (Exception e)
{
throw new WicketRuntimeException(
"Could not parse markup from markup resource stream: " +
markupResourceStream.toString());
}
}