>This means .addOrReplace() cannot be used in Page constructor, even
>indirectly.
Please provide a test case and I'll have a look.

>Can we add some check in org.apache.wicket.Component.getMarkupIdFromMarkup()
>so that it immediately returns 'null' if the markup is not available ?
We could but I don't like the idea. The name implies that needs access
to the markup. If markup is not available that clearly is an error =>
exception

>org.apache.wicket.Component.onMarkupAttached() doesn't set any flag that the
>markup is available.
Doesn't need to. The process make sure it's called only once (I hope).

>If we use this approach then we will have to add javadoc line to this method
>that it works only when the markup is available.
good point.

I agree the issue probably is with addOrReplace(). I don't think I
added any testcase for that. But I'm happy to look after if you could
provide a (failing) testcase

Juergen


On Thu, Nov 25, 2010 at 4:34 PM, Martin Grigorov <[email protected]> wrote:
> Quick and dirty workaround to be able to run the app:
>
> if (getFlag(FLAG_INITIALIZED) && parent != null)
> { /* the current body of getMarkupIdFromMarkup() */ }
> return null;
>
> On Thu, Nov 25, 2010 at 4:28 PM, Martin Grigorov <[email protected]>wrote:
>
>> My app is not happy with this new method. I guess other apps will complain
>> too.
>>
>> Moved the code to onInitialize() and now the new exception is:
>>
>> org.apache.wicket.markup.MarkupException: Can not determine Markup.
>> Component is not yet connected to a parent. [WebMarkupContainer [Component
>> id = applyTable]]
>> at org.apache.wicket.Component.getMarkup(Component.java:717)
>> at org.apache.wicket.Component.getMarkupTag(Component.java:1438)
>> at org.apache.wicket.Component.getMarkupIdFromMarkup(Component.java:849)
>> at org.apache.wicket.Component.getMarkupIdImpl(Component.java:1484)
>> at org.apache.wicket.MarkupContainer.replace(MarkupContainer.java:807)
>> at org.apache.wicket.MarkupContainer.addOrReplace(MarkupContainer.java:239)
>>  at com.fredhopper.bm.layout.ControlPanel.setOnApply(ControlPanel.java:192)
>> at com.fredhopper.bm.layout.TopPanel.setOnApply(TopPanel.java:67)
>> at
>> com.fredhopper.bm.pages.search.SynonymsPage.<init>(SynonymsPage.java:123)
>> ......
>>
>> This means .addOrReplace() cannot be used in Page constructor, even
>> indirectly.
>> Can we add some check in
>> org.apache.wicket.Component.getMarkupIdFromMarkup() so that it immediately
>> returns 'null' if the markup is not available ?
>> org.apache.wicket.Component.onMarkupAttached() doesn't set any flag that
>> the markup is available.
>> If we use this approach then we will have to add javadoc line to this
>> method that it works only when the markup is available.
>>
>> On Wed, Nov 24, 2010 at 10:32 PM, Juergen Donnerstag <
>> [email protected]> wrote:
>>
>>> Excepted is:
>>> - if a component provides its own markup either via subclassing
>>> getMarkup() or is expected to have associated markup (e.g. Panel) =>
>>> markup available in ctor
>>> - Component.onMarkupAttached() is invoked as soon as the markup is
>>> available. E.g. a child to a Panel. child.onMarkupAttached() is
>>> invoked when child gets added to panel
>>> - onInitialize() gets called once a path to the Page is available
>>>
>>> Juergen
>>>
>>> On Wed, Nov 24, 2010 at 10:06 PM, Martin Grigorov <[email protected]>
>>> wrote:
>>> > Hi,
>>> >
>>> > I just updated my app to latest 1.5 and the following exception
>>> happened:
>>> >
>>> > org.apache.wicket.WicketRuntimeException: No Page found for component
>>> > [ShortcutsPanel [Component id = componentItem]]
>>> > at org.apache.wicket.Component.getPage(Component.java:1787)
>>> > at
>>> org.apache.wicket.MarkupContainer.getMarkupType(MarkupContainer.java:531)
>>> > at
>>> >
>>> org.apache.wicket.MarkupContainer.getAssociatedMarkup(MarkupContainer.java:441)
>>> > at
>>> >
>>> org.apache.wicket.markup.html.panel.Panel$PanelMarkupHelper.getMarkup(Panel.java:166)
>>> > at org.apache.wicket.markup.html.panel.Panel.getMarkup(Panel.java:142)
>>> > at org.apache.wicket.Component.getMarkup(Component.java:722)
>>> > at org.apache.wicket.Component.getMarkupTag(Component.java:1436)
>>> > at org.apache.wicket.Component.getMarkupIdFromMarkup(Component.java:847)
>>> > <<<<<<<<<<<< new
>>> > at org.apache.wicket.Component.getMarkupIdImpl(Component.java:1482)
>>> > at org.apache.wicket.Component.getMarkupId(Component.java:1537)
>>> > at org.apache.wicket.Component.getMarkupId(Component.java:1599)
>>> > at
>>> >
>>> com.fredhopper.bm.components.savedsearches.ShortcutsPanel.<init>(ShortcutsPanel.java:184)
>>> > ....
>>> >
>>> > In ShortcutsPanel's ctor we need to get the markupId of one of the
>>> > components in this Panel ...
>>> > I know that if I move the code to onInitialize() then everything will be
>>> OK,
>>> > but I wanted to discuss with you whether the new behavior is OK for 1.5.
>>> >
>>>
>>
>>
>

Reply via email to