Thanks

My "source" (and whatever the iterator returns) are always null...so I'll have 
to find out why that happens.

On 02/04/2012, at 10:14 PM, Lance Java wrote:

> Tapestry's own loop component might give you some inspiration too
> http://tapestry.apache.org/5.3/apidocs/src-html/org/apache/tapestry5/corelib/components/Loop.html
> 
> 
> On Monday, 2 April 2012, Lance Java <lance.j...@googlemail.com> wrote:
>> 
>> Perhaps this diagram will help to debug
> http://tapestry.apache.org/component-rendering.html
>> 
>> On Monday, 2 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
>>> Hi Tapestry List,
>>> 
>>> After spending a few hours with render phases and all that comes with it
> (heartbeat/resources) I'm in a bit of a jam that I don't know where to go
> next.
>>> I'm setting up a basic component called PhoneView that receives an
> ArrayList of Phone objects...similar to the Tree example on the wiki [1]
>>> 
>>> @CleanupRender & @BeforeRenderBody have the same code to make it easy
> for the beginner (me!) to see his progress...
>>> There are 2 items in the array list I have created using a BeanEditForm,
> so I presume I should see three lots of the div saying "CHRIS! This is your
> amazing test div - " with the render phase name.  (2 x BeforeRenderBody) +
> (1 x CleanupRender).
>>> 
>>> I'm not :(
>>> 
>>> Running your eye over this code/template...can you help me?
>>> 
>>> 
>>>       /**
>>>        * Defines the source of the phones
>>>        */
>>>       @Parameter(required = true)
>>>       private ArrayList<Phone> source ;
>>> 
>>>       /**
>>>        * Iterator to go over the source (Phone) elements
>>>        */
>>>       private Iterator<Phone> iterator;
>>> 
>>>       /**
>>>        *
>>>        */
>>>       @Inject
>>>       private ComponentResources resources ;
>>> 
>>>       /**
>>>        *
>>>        */
>>>       @Parameter
>>>       private Phone currentPhone ;
>>> 
>>>   /**
>>>    *
>>>    */
>>>   @Parameter(defaultPrefix = BindingConstants.LITERAL)
>>>   private Block empty;
>>> 
>>>   /**
>>>    *
>>>    */
>>>   @Environmental
>>>   private Heartbeat heartbeat ;
>>> 
>>>       /**
>>>        * @return
>>>        */
>>>       @SetupRender
>>>       boolean SetupRender(){
>>>                if( source == null ){
>>>                        return false ;
>>>                }
>>>        this.iterator = source.iterator();
>>>        return (iterator.hasNext());
>>>       }
>>> 
>>>       @BeginRender
>>>       void beginRender(){
>>>               currentPhone = iterator.next();
>>>               heartbeat.begin();
>>>       }
>>> 
>>>       @BeforeRenderBody
>>>       void beforeRenderBody(MarkupWriter writer){
>>> 
>>>               Element cur = writer.element("div",
>>> 
> "class","userbackground").addClassName("adifferentbackground");
>>>               cur.text("CHRIS! This is your amazing test div -
> beforeRenderBody");
>>>               writer.end();
>>> 
>>> 
>>>               resources.renderInformalParameters(writer);
>>>       }
>>>       /**
>>>        * @return
>>>        */
>>>       @AfterRender
>>>       boolean afterRender(){
>>>               heartbeat.end();
>>>               return (!iterator.hasNext());
>>>       }
>>> 
>>>       /**
>>>        * @param writer
>>>        */
>>>       @CleanupRender
>>>       void cleanupRender(MarkupWriter writer){
>>>               Element cur = writer.element("div",
>>> 
> "class","userbackground").addClassName("adifferentbackground");
>>>               cur.text("CHRIS! This is your amazing test div -
> cleanupRender");
>>>               writer.end();
>>>       }
>>> 
>>> 
>>> And the tml snippet from Index.tml
>>> 
>>> <t:grid source="phones"/>
>>> <br/>
>>> <t:pagelink page="Phone/Create">Add Phone</t:pagelink>
>>> <br/>
>>> Chris 1
>>> <br/>
>>> <t:PhoneView source="phones"/>
>>> <br/>
>>> Chris 2
>>> 
>>> 
>>> 
>>> Thanks
>>> Chris
>>> 
>>> 
>>> 
>>> [1] =
> https://wiki.apache.org/tapestry/Tapestry5HowToCreateYourOwnComponents


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to