Jim,

I'm a bit puzzled myself, but how did you manage to run the app without
providing setters for 'idx' and 'name' fields:
public abstract void setIdx(int idx)
public abstract void setName(String name)?

Regards,

</Firas>

-----Original Message-----
From: Jim Downing [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 09, 2007 3:47 PM
To: users@tapestry.apache.org
Subject: Newbie help with For and TextField components

Hi,

I'm trying to get some simple list editing working using For and TextField
but not having much luck.

Home.html: -

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> <head>
<title>Example app</title> </head> <body jwcid="@Body"> <h1>Hello
world!</h1> <form jwcid="@Form" success="listener:submit">List of names:
<div jwcid="@For" source="ognl:names" value="ognl:name" index="ognl:idx">
<p><span jwcid="@Insert" value="ognl:idx">1</span> <input
    jwcid="@TextField" value="ognl:name" /></p> </div> <input type="submit"
jwcid="@Submit" listener="listener:add" value="Add" /> <input type="submit"
jwcid="@Submit" value="Update" /></form> </body> </html>

Home.java

public abstract class Home extends BasePage implements
PageBeginRenderListener {

    private static final Logger LOG = Logger.getLogger(Home.class);

    public void pageBeginRender(PageEvent event) {
        LOG.info("Begin render. Rewind? " +
getRequestCycle().isRewinding());
        if(getNames()== null) {
            LOG.info("Initializing names list");
            setNames(new ArrayList<String>());
        }
    }

    public void submit() {
        LOG.info("Submitted. List is: " + getNames());
    }

    public void add() {
        LOG.info("Adding a blank name to "+ getNames());
        List<String> nms = getNames();
        nms.add("");
        setNames(nms);
    }
   
    public abstract List<String> getNames();

    public abstract void setNames(List<String> nms);

    public abstract String getName();

    public abstract int getIdx();
}

When I click the "Add" button I get: -

9627410 [btpool0-3] INFO  com.example.pages.Home  - Begin render. 
Rewind? true
9627411 [btpool0-3] INFO  com.example.pages.Home  - Initializing names list
9627423 [btpool0-3] INFO  com.example.pages.Home  - Adding a blank name to
[]
9627424 [btpool0-3] INFO  com.example.pages.Home  - Submitted. List is: 
[    ----    ]
9627424 [btpool0-3] INFO  com.example.pages.Home  - Begin render. 
Rewind? false

Then changing the value in the form input and clicking submit produces
this: -

9638858 [btpool0-3] INFO  com.example.pages.Home  - Begin render. 
Rewind? true
9638858 [btpool0-3] INFO  com.example.pages.Home  - Initializing names list
9638859 [btpool0-3] INFO  com.example.pages.Home  - Submitted. List is: []
9638859 [btpool0-3] INFO  com.example.pages.Home  - Begin render. 
Rewind? false

I'm puzzled - why hasn't the list been populated from the TextFields in the
For loop?

Any pointers gratefully received.

cheers,
jim



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to