I managed to get around this by using @Persist on the startIndex property but 
this doesn't seem right - do I need to use the session for a single request?

Toby

----- Original Message ----
From: Toby Hobson <[EMAIL PROTECTED]>
To: users@tapestry.apache.org
Sent: Saturday, 10 May, 2008 1:31:52 PM
Subject: Page property reset during request

Hi

I have a simple problem which is probably due to my lack of understanding about 
the Tapestry request cycle:

I am trying to implement a basic pagination system - I have a form with a 
textfield called startIndex and a loop component which iterates through a list 
of values. Basically I am trying to use the startIndex property to page through 
the list:

public class Pagination {
    
    @Parameter(name="ds")
    private IDataSource ds;
    
    // used by the loop as the current value
    private String value;
    
    private int startIndex;
    
    public int getStartIndex() {
        return startIndex;
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }
    
    public List<String> getSource() {
        return ds.getValues(startIndex);
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
    
}

Pagination.tml:

    <t:loop source="source" value="value">
        ${value}
        <br />
    </t:loop>
    <t:form>
        <t:textfield value="startIndex" />
        <input type="submit" />
    </t:form>

I was hoping that I could enter a value for the startIndex, hit submit which 
would update the startIndex property then the loop will call getSource() which 
will read the startIndex and select the appropriate records. The problem is 
that when I debug the code I see the call to setIndex i made and the property 
is updated but when the call to getSource() is made the property has been reset 
to 0! This all appears to happen during a single request.

Can someone please explain to me why the property is being reset between the 
setStartIndex() and getSource() methods?

Thanks

Toby




Reply via email to