Wicket
  1. Wicket
  2. WICKET-4545

MarkupNotFoundException for Fragment and TransparentWebMarkupContainer

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.6
    • Fix Version/s: 6.16.0, 7.0.0-M2
    • Component/s: wicket
    • Labels:
      None

      Description

      Create a base WebPage with a TransparentWebMarkupContainer to allow subclasses register CSS classes on the body tag. Add a Fragment to one of these subsclasses, the markup of the Fragment is not found.
      See also http://apache-wicket.1842946.n4.nabble.com/MarkupNotFoundException-for-Fragment-and-TransparentWebMarkupContainer-tp4619968.html

      Exception thrown:

      org.apache.wicket.markup.MarkupNotFoundException: No Markup found for Fragment testFragment in providing markup container [Page class = org.foo.HomePage, id = 0, render count = 1]
      at org.apache.wicket.markup.html.panel.FragmentMarkupSourcingStrategy.getMarkup(FragmentMarkupSourcingStrategy.java:143)

      1. quickstart.zip
        25 kB
        Dirk Forchel

        Issue Links

          Activity

          Hide
          Martin Grigorov added a comment -

          Fixed with WICKET-5580.

          Show
          Martin Grigorov added a comment - Fixed with WICKET-5580 .
          Hide
          Jesse Long added a comment -

          WICKET-5580 test definitely covers this situation. It does specifically check for the ability to find a fragment inside the subclass' <wicket:extend> when the subclass' <wicket:extend> is surrounded by a component tag.

          I dont think we need another test.

          Show
          Jesse Long added a comment - WICKET-5580 test definitely covers this situation. It does specifically check for the ability to find a fragment inside the subclass' <wicket:extend> when the subclass' <wicket:extend> is surrounded by a component tag. I dont think we need another test.
          Hide
          Martin Grigorov added a comment - - edited

          Thanks for confirming, Jesse!
          I want to add a test case before closing it.
          Or maybe your mighty test case from WICKET-5580 covers it ? I need to re-read the description/code here to be able to say.

          Show
          Martin Grigorov added a comment - - edited Thanks for confirming, Jesse! I want to add a test case before closing it. Or maybe your mighty test case from WICKET-5580 covers it ? I need to re-read the description/code here to be able to say.
          Hide
          Jesse Long added a comment -

          I can confirm that the quickstart works in 6.16.0-SNAPSHOT with the patch from WICKET-5580 applied.

          Show
          Jesse Long added a comment - I can confirm that the quickstart works in 6.16.0-SNAPSHOT with the patch from WICKET-5580 applied.
          Hide
          Martin Grigorov added a comment -

          Hi Simon,

          Please show us some code (preferably in the users@ mailing lists). The workaround that I posted in my comment at 09/Jan/13 18:20 should help you.

          Show
          Martin Grigorov added a comment - Hi Simon, Please show us some code (preferably in the users@ mailing lists). The workaround that I posted in my comment at 09/Jan/13 18:20 should help you.
          Hide
          Simon Botting added a comment -

          Hi

          I'm having exactly the same problem (MarkupNotFoundException: No Markup found for Fragment etc...) When I add a TransparentWebMarkupContainer at the top of the page heirarchy,

          I'm using Wicket 6.5

          Did anyone have a patch for this in the end?

          Show
          Simon Botting added a comment - Hi I'm having exactly the same problem (MarkupNotFoundException: No Markup found for Fragment etc...) When I add a TransparentWebMarkupContainer at the top of the page heirarchy, I'm using Wicket 6.5 Did anyone have a patch for this in the end?
          Hide
          Martin Grigorov added a comment - - edited

          A workaround:
          Add

          protected Fragment createFragment(String id, String markupId)

          { return new Fragment(id, markupId, transparentContainer); }

          method to the base page. It should use the TransparentWebMarkupContainer as markupProvider. This way all children pages will not know that there is TWMC in the hierarchy and Wicket will be still able to lookup the markup for the Fragment.

          Show
          Martin Grigorov added a comment - - edited A workaround: Add protected Fragment createFragment(String id, String markupId) { return new Fragment(id, markupId, transparentContainer); } method to the base page. It should use the TransparentWebMarkupContainer as markupProvider. This way all children pages will not know that there is TWMC in the hierarchy and Wicket will be still able to lookup the markup for the Fragment.
          Hide
          Martin Grigorov added a comment -

          Sebastian Gooren Please attach a patch and we will evaluate it.

          Show
          Martin Grigorov added a comment - Sebastian Gooren Please attach a patch and we will evaluate it.
          Hide
          Sebastian Gooren added a comment -

          In the meantime, this can be fixed by using the TransparentWebMarkupContainer as the markupProvider constructor argument.

          Cloning the markup stream or marking the TWMC as an auto component seems overkill or abusing the auto flag, no?
          On the other end the wicket internals have become so much cleaner since 1.5 that an "if (component instanceof IComponentResolver) look_deeper" is out of the question?

          Show
          Sebastian Gooren added a comment - In the meantime, this can be fixed by using the TransparentWebMarkupContainer as the markupProvider constructor argument. Cloning the markup stream or marking the TWMC as an auto component seems overkill or abusing the auto flag, no? On the other end the wicket internals have become so much cleaner since 1.5 that an "if (component instanceof IComponentResolver) look_deeper" is out of the question?
          Hide
          Martin Grigorov added a comment -

          Currently org.apache.wicket.Component#internalRenderComponent() gets a mutable ComponentTag from the MarkupStream's current tag and uses it for #onComponentTag(), #onComponentTagBody(), etc.
          The problem can be solved if instead a mutable copy of the MarkupStream is created when a Page starts to render and this mutable MarkupStream is used for the rendering of all components in the page. This way TWMC can mark itself as auto component and Markup#find() will look into its children too.

          Show
          Martin Grigorov added a comment - Currently org.apache.wicket.Component#internalRenderComponent() gets a mutable ComponentTag from the MarkupStream's current tag and uses it for #onComponentTag(), #onComponentTagBody(), etc. The problem can be solved if instead a mutable copy of the MarkupStream is created when a Page starts to render and this mutable MarkupStream is used for the rendering of all components in the page. This way TWMC can mark itself as auto component and Markup#find() will look into its children too.
          Hide
          Martin Grigorov added a comment -

          The problem is in org.apache.wicket.markup.Markup#find(String) method which skips the body of the ComponentTag assigned to TransparentWebMarkupContainer.
          #find() method looks for the child's markup only at one level depth but it should look one more lever deeper for TWMC. But since Component#onComponentTag() works with a copy of the real ComponentTag I see no way how to mark the ComponentTag as auto or to set it some other flag/userData which to be used when deciding whether to skip the children or not.

          Anyone have ideas ?

          Show
          Martin Grigorov added a comment - The problem is in org.apache.wicket.markup.Markup#find(String) method which skips the body of the ComponentTag assigned to TransparentWebMarkupContainer. #find() method looks for the child's markup only at one level depth but it should look one more lever deeper for TWMC. But since Component#onComponentTag() works with a copy of the real ComponentTag I see no way how to mark the ComponentTag as auto or to set it some other flag/userData which to be used when deciding whether to skip the children or not. Anyone have ideas ?
          Hide
          Dirk Forchel added a comment -

          Quickstart attached.

          Show
          Dirk Forchel added a comment - Quickstart attached.

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Dirk Forchel
            • Votes:
              3 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development