wicket.markup.resolver
Class ScopedComponentResolver

java.lang.Object
  extended by wicket.markup.resolver.ScopedComponentResolver
All Implemented Interfaces:
java.io.Serializable, IComponentResolver

public class ScopedComponentResolver
extends java.lang.Object
implements IComponentResolver

Implement a component resolver which walks up the component tree until a Page or Panel and tries to find a component with a matching wicket id, effectivly providing something like scoping for wicket id resolution.

Note: This resolver is not activated by default. It has to be added by means of Application.getComponentResolvers().add(new InheritComponentResolver()) to be activated..

Example:

 MyPage()
 { 
    add(new Label("hidden-by-cont1","hidden")); 
    add(new Label("global","can be everywhere")); //the intresting case
 
    WebMarkupContainer cont1 = new WebMarkupContainer("cont1"); 
    add(cont1);
 
     cont1.add(new Label("hidden-by-cont1","cont1 hides")); 
     cont1.add(new Label("same-id","cont1 same-id"));
 
     WebMarkupContainer cont2 = new WebMarkupContainer("cont2"); 
     add(cont2);
 
     cont2.add(new Label("same-id","cont2 same-id")); 
 }
 
 HTML:
  
  
   Prints: hidden 
   
Prints: cont1 hides Prints: cont1 same-id
Prints: can be everywhere Prints: cont2 same-id
So you can use the same ids in the same page. If the containing containers are not in the same hierarchy-line nothing changes. A comp with the same id hides the one of the parent-container with the same id.

Author:
Christian Essl, Juergen Donnerstag
See Also:
MarkupContainer.isTransparentResolver(), ParentResolver, Serialized Form

Constructor Summary
ScopedComponentResolver()
          Construct.
 
Method Summary
 boolean resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)
          Try to resolve the tag, then create a component, add it to the container and render it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScopedComponentResolver

public ScopedComponentResolver()
Construct.

Method Detail

resolve

public boolean resolve(MarkupContainer container,
                       MarkupStream markupStream,
                       ComponentTag tag)
Description copied from interface: IComponentResolver
Try to resolve the tag, then create a component, add it to the container and render it.

Specified by:
resolve in interface IComponentResolver
Parameters:
container - The container parsing its markup
markupStream - The current markupStream
tag - The current component tag while parsing the markup
Returns:
True if component-id was handled by the resolver, false otherwise.
See Also:
IComponentResolver.resolve(wicket.MarkupContainer, wicket.markup.MarkupStream, wicket.markup.ComponentTag)


Copyright © 2004-2007 Wicket developers. All Rights Reserved.