Simon, I'm not entirely sure why the getTicketNumber() gets called before the ticket gets set, maybe you can put in a break point in the method and look at the stack trace and see what's calling it. Just looking at it like this, I have no explanation why it's being called.
On your question of not rendering the component based on its state : it seems that it depends on how you want to do it. If this 'don't render empty' behavior is expected to be a part of the ViewTicket component, you can always use a t:if to inspect the state of the ticket in the component template render nothing if the ticket is in a state that shouldn't be rendered. It seems that the best approach there would be to have 2 blocks : one for empty ticket, one for "displayable" ticket, and then use a t:if to select which block to render, e.g. <div id='content'> <t:delegate to='contentBlock' /> </div> <t:block t:id="fullContent"> .... </t:block> <t:block t:id="emptyBlock"> ...</t:block> ... and then in the component class ... @Component Block fullContent @Component Block emptyBlock public Block getContentBlock() { if (this.ticket.foo='bar') { return emptyBlock; } else { fullContent; } } Something like that.. I haven't tested the exact code above, but I have a few similar examples. I think JumpStart ( http://jumpstart.doublenegative.com.au:8080/jumpstart/) has some examples to illustrate this but I don't have the exact URL for that. Cheers, Alex Kotchnev On Sun, Mar 1, 2009 at 12:09 AM, Simon Raveh <simon.ra...@icann.org> wrote: > Hi, > > I'm switching from Tapestry 4 to to Tapestry 5 and I need help with a > simple component. > I have a component ViewTicket that display Ticket information. The tml file > code: > > <t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd > "> > <div style="display: block;" id="output"> > <div id="assessment_panel"> > <div class="safe" id="box_assessment"> > <h2>Ticket Information</h2> > </div> > </div> > <div id="results_panel"> > <table id="ns_table"> > <tbody> > <tr> > <th>Ticket ID</th> > <th>Status</th> > <th>Queue</th> > <th>Created</th> > </tr> > <tr> > <td>${ticketNumber}</td> > <td>${status}</td> > <td>${queue}</td> > <td>${created}</td> > </tr> > </tbody> > </table> > </div> > </div> > </t:container> > > And the java code > > public class ViewTicket implements TicketViewer { > > @Inject > private Logger logger; > > @Parameter(required = true) > private RTTicket ticket; > > @Log > @BeforeRenderTemplate > void beforeRenderTamplate(){ > } > > @Log > public Long getTicketNumber() { > return ticket == null ? null : ticket.getId(); > } > > @Log > public String getQueue() { > return ticket == null ? null :ticket.getQueue(); > } > > @Log > public String getStatus() { > return ticket == null ? null :ticket.getStatus(); > } > > @Log > public Date getCreated() { > return ticket == null ? null : ticket.getCreated(); > } > > public void addTicket(RTTicket ticket) { > this.ticket = ticket; > } > > public void clearTicket() { > this.ticket = new RTTicketImpl(); > } > } > And my page Index.tml > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html t:type="layout" xmlns:t=" > http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> > <body> > <h1>Request (Ticket) Information</h1> > <p>To check the status of your request, please enter the ticket > number (numerical value only) below: </p> > <form t:type="form" t:id="search_form" action="#"> > <t:errors/> > Ticket ID: > <input t:type="TextField" t:id="ticketId" > t:clientId="id_query" validate="required"/> > <input type="submit" value="Submit Query" > id="form-submit-button"/> > </form> > <span t:type="ViewTicket" t:ticket="prop:ticket" /> > </body> > </html> > > Index.java > > public class Index { > > @Inject > private Logger logger; > > @Property > private long ticketId; > > void onValidateForm() { > > } > > void onSuccess() { > } > > @Log > public RTTicket getTicket() { > return new RTTicketImpl(); > } > } > > My problem is that Tapestry is calling the method getTicketNumber before > the Ticket parameter is bound. > Here are the logging output: > > [DEBUG] components.ViewTicket [ENTER] beforeRenderTamplate() > [DEBUG] components.ViewTicket [ EXIT] beforeRenderTamplate > [DEBUG] components.ViewTicket [ENTER] getTicketNumber() > [DEBUG] pages.Index [ENTER] getTicket() > [DEBUG] pages.Index [ EXIT] getTicket > [org.iana.ietf.ticketstatus.moodel.rtticketi...@3805fd37] > [DEBUG] components.ViewTicket [ EXIT] getTicketNumber [null] > [DEBUG] components.ViewTicket [ENTER] getStatus() > [DEBUG] components.ViewTicket [ EXIT] getStatus [null] > [DEBUG] components.ViewTicket [ENTER] getQueue() > [DEBUG] components.ViewTicket [ EXIT] getQueue [null] > [DEBUG] components.ViewTicket [ENTER] getCreated() > [DEBUG] components.ViewTicket [ EXIT] getCreated [null] > > Any clue to what I'm doing wrong or help will be much appreciate > > My second question is what the best way to cause the component ViewTicket > not to render base on the state of the ticket it gets as parameter > > Thanks, > Simon >