IMarkupFragment pageMarkup)
{
Args.notNull(component, "component");
// Create a page object and assign the markup
Page page = createPage();
if (page == null)
{
fail("The automatically created page should not be null.");
}
// Automatically create the page markup if not provided
if (pageMarkup == null)
{
String markup = createPageMarkup(component.getId());
if (markup == null)
{
fail("The markup for the automatically created page should not be null.");
}
try
{
// set a ContainerInfo to be able to use HtmlHeaderContainer so header contribution
// still work. WICKET-3700
ContainerInfo containerInfo = new ContainerInfo(page);
MarkupResourceStream markupResourceStream = new MarkupResourceStream(
new StringResourceStream(markup), containerInfo, page.getClass());
MarkupParser markupParser = getApplication().getMarkupSettings()
.getMarkupFactory()
.newMarkupParser(markupResourceStream);
pageMarkup = markupParser.parse();
}
catch (Exception e)
{
fail("Error while parsing the markup for the autogenerated page: " + e.getMessage());
}
}
if (page instanceof StartComponentInPage)
{
((StartComponentInPage)page).setPageMarkup(pageMarkup);
}
else
{
page.setMarkup(pageMarkup);
}
// Add the child component
page.add(component);
// Preserve 'componentInPage' because #startPage() needs to null-fy it
ComponentInPage oldComponentInPage = componentInPage;
// Process the page