You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Toby Hobson <to...@btinternet.com> on 2008/05/10 14:31:52 UTC

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