You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sven Meier <sv...@meiers.net> on 2016/07/07 13:19:04 UTC

Re: on upgrade from 7.2 to 7.3 Cannot modify component hierarchy after render phase has started

Hi,

there have been some changes related to queued components recently.
Previously MarkupContainer#onInitialize() would trigger loading of the 
markup, this is no longer the case. See the 7.2 stacktrace:

     HomePage.getMarkupResourceStream(MarkupContainer, Class<?>) line: 28
     MarkupFactory.getMarkupResourceStream(MarkupContainer, Class<?>) 
line: 320
     MarkupCache.getMarkup(MarkupContainer, Class<?>, boolean) line: 296
     MarkupFactory.getMarkup(MarkupContainer, Class<?>, boolean) line: 236
     MarkupFactory.getMarkup(MarkupContainer, boolean) line: 194
     HomePage(MarkupContainer).getAssociatedMarkup() line: 456
     HomePage(MarkupContainer).getRegionMarkup() line: 2224
     HomePage(MarkupContainer).newDequeueContext() line: 2211
     HomePage(MarkupContainer).dequeueAutoComponents() line: 1670 <---- 
no longer called in 7.3
     HomePage(MarkupContainer).onInitialize() line: 1664
     HomePage(Page).onInitialize() line: 299

IMHO your best option is to trigger loading of markup by yourself from 
#onInitialize().

Have fun
Sven


On 07.07.2016 12:15, Renner, Ingo wrote:
>
> Hi,
>
> the page classes  of our wicket application read their html markup 
> from the filesystem, where they are generated by a CMS system.
>
> In the markup of these pages we have special tags which we replace 
> with real tags and add some wicket components to the page.
>
> This is nearly the same way which was/is used in the wicket brix cms.
>
> Last cause: Cannot modify component hierarchy after render phase has 
> started (page version cant change then anymore)
> WicketMessage: Markup of type 'html' for component 'com.lr.HomePage' 
> not found. Enable debug messages for org.apache.wicket.util.resource 
> to get a list of all filenames tried:
> [Page class = com.lr.HomePage, id = 0, render count = 1]
>
> This is just a demo which shows the same technology used in our real 
> code, but in a more simple way:
>
> This is the interesting method from the Page class with some comments:
>
> @Override
>
> *public*IResourceStream getMarkupResourceStream(MarkupContainer 
> container, Class<?> containerClass) {
>
> // This simulates loading the template from external source
>
> InputStream src= HomePage.*class*.getResourceAsStream("HomePageSrc.html");
>
> String srcStr= "";
>
> *try*{
>
> srcStr= Streams./readString/(src);
>
> // now replacing my special _markup_ "tag" with a real _html_ tag
>
> srcStr= srcStr.replace("${tile}", "<div wicket:id=\"tile\"></div>");
>
> // and adding the component to the page
>
> HomePage.*this*.add(*new*Label("tile", Model./of/("Content of dynamic 
> component aka tile.")));
>
> } *catch*(IOException e) {
>
> // *TODO*Auto-generated catch block
>
> e.printStackTrace();
>
> }
>
> StringResourceStream stringResourceStream= 
> *new*StringResourceStream(srcStr, "text/html");
>
> *return*stringResourceStream;
>
> }
>
> A quickstart is attached. Just switch the version number in the 
> pom.xml: It works with 7.2 and breaks with 7.3.
>
> My question now. Is this kind of technology wrong with 7.3 (or was it 
> always a bad idea) and how should it be done now, or is 7.3 overreacting?
>
> Mit freundlichen Gren / Kind regards
>
> Ingo Renner
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org