I want to add a component into a page dynamicly.For exmaple:

Test.jwc
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
<!-- $Id$ -->

<component-specification class="synthetic.Test"
    allow-body="yes"
    allow-informal-parameters="yes">
    
    <description>add a description</description>
    
    
    
</component-specification>

Test.html
<!-- $Id$ -->
<span jwcid="$content$">
This is a test component.
   
</span>

TestPage.html
<span jwcid="@Foreach" source="ognl:blocks" value="ognl:block">
   <span jwcid="@RenderBlock" block="ognl:block">Page content goes here</span>
</span>
TestPage.page
.....
<property-specification name="block"
type="org.apache.tapestry.components.Block"/>
.....
TestPage.java
public List getBlocks(){
                List blocks=new ArrayList();
                IComponent ic=new Block();
                IResourceLocation
ir=Tapestry.getApplicationRootLocation(this.getPage().getRequestCycle()).getRelativeLocation("/WEB-INF/Test.jwc");
                IComponentSpecification
cs=this.getPage().getEngine().getSpecificationSource().getComponentSpecification(ir);
                ic.setSpecification(cs);
                blocks.add(ic);
                        
                
                if (log.isDebugEnabled()) {
                        log.debug("get blocks size ["+blocks.size()+"]");
                }
                
                return blocks;
        }

But it doesn't work.
I don't use tapestry example about renderblock,beacause my block is producted by
module definition and user state.
Thanks
Jun Tsai


-- 
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to