Class Fragment

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<Component>, IEventSink, IEventSource, IFeedbackContributor, IConverterLocator, IMetadataContext<java.io.Serializable,​Component>, IQueueRegion, IHeaderContributor, IRequestableComponent, org.apache.wicket.util.IHierarchical<Component>, org.apache.wicket.util.io.IClusterable

    public class Fragment
    extends WebMarkupContainer
    implements IQueueRegion
    Usually you either have a markup file or a xml tag with wicket:id="myComponent" to associate markup with a component. However in some use cases, especially when working with small panels it is a bit awkward to maintain tiny pieces of markup in plenty of panel markup files. Use cases are for example list views where list items are different depending on a state.

    Fragments provide a means to maintain the panels tiny piece of markup. Since it can be anywhere, the component whose markup contains the fragment's markup must be provided (markup provider).

      <span wicket:id="myPanel">Example input (will be removed)</span>
     
      <wicket:fragment wicket:id="frag1">panel 1</wicket:fragment>
      <wicket:fragment wicket:id="frag2">panel 2</wicket:fragment>
     
      add(new Fragment("myPanel1", "frag1", myPage);
     
    Author:
    Juergen Donnerstag
    See Also:
    Serialized Form
    • Constructor Detail

      • Fragment

        public Fragment​(java.lang.String id,
                        java.lang.String markupId,
                        MarkupContainer markupProvider)
        Constructor.
        Parameters:
        id - The component id
        markupId - The associated id of the associated markup fragment
        markupProvider - The component whose markup contains the fragment's markup
        See Also:
        Component(String)
      • Fragment

        public Fragment​(java.lang.String id,
                        java.lang.String markupId,
                        MarkupContainer markupProvider,
                        IModel<?> model)
        Constructor.
        Parameters:
        id - The component id
        markupId - The associated id of the associated markup fragment
        markupProvider - The component whose markup contains the fragment's markup
        model - The model for this fragment
        See Also:
        Component(String)
    • Method Detail

      • newMarkupSourcingStrategy

        protected IMarkupSourcingStrategy newMarkupSourcingStrategy()
        If Component.getMarkupSourcingStrategy() returns null, this method will be called. By default it returns null, which means that a default markup strategy will be attached to the component.

        Please note that markup source strategies are not persisted. Instead they get re-created by calling this method again. That's ok since markup sourcing strategies usually do not maintain a state.

        Overrides:
        newMarkupSourcingStrategy in class Component
        Returns:
        Markup sourcing strategy
      • chooseMarkup

        protected IMarkupFragment chooseMarkup​(MarkupContainer provider)
        Get the markup stream which shall be used to search for the fragment
        Parameters:
        provider -
        Returns:
        The markup stream to be used to find the fragment markup
      • getAssociatedMarkupId

        public final java.lang.String getAssociatedMarkupId()
        Returns:
        the markup id associated to this Fragment