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

Reply via email to