Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
 package org.apache.tapestry.components;
 
 import  org.apache.hivemind.util.Defense;
Prevents its contents from being rendered until triggered by an RenderBlock component. [Component Reference]

Block and RenderBlock are used to build a certain class of complicated component that can't be assembled using the normal wrapping containment. Such a super component would have two or more sections that need to be supplied by the containing page (or component).

Using Blocks, the blocks can be provided as parameters to the super component.

The invoker property gives the components inside the block access to the component (typically an RenderBlock) that rendered the block. More often, the getParameter(String) method is used to get parameters of the invoking component.

Author(s):
Howard Lewis Ship
Since:
0.2.9
 
 
 public abstract class Block extends AbstractComponent
 {
     private IComponent _invoker;

    
Provides access to the invoking component's parameters.

Since:
4.0
 
 
     public Object getParameter(String name)
     {
         return .getBinding(name).getObject();
     }
 
     public void renderForComponent(IMarkupWriter writerIRequestCycle cycleIComponent invoker)
     {
         Defense.notNull(invoker"invoker");
 
         IComponent oldInvoker = ;
 
         try
         {
              = invoker;
             renderBody(writercycle);
         }
         finally
         {
              = oldInvoker;
 
         }
     }

    
Does nothing; the idea of a Block is to defer the rendering of the body of the block until an RenderBlock forces it out.
 
 
     protected void renderComponent(IMarkupWriter writerIRequestCycle cycle)
     {
         // Nothing!
     }

    
Returns the object which invoked this Block's renderForComponent(IMarkupWriter, IRequestCycle, IComponent) method. This is often used to access the informal parameters of a RenderBlock component.

Since:
4.0
 
     public IComponent getInvoker()
     {
         return ;
     }

    
Used for testing only.

Since:
4.0
    void setInvoker(IComponent invoker)
    {
         = invoker;
    }
New to GrepCode? Check out our FAQ X