I don't get it. What are you trying to do? You aren't persisting your list anywhere.... so at each render or rewind your lists starts off null..... so by the time it gets to the @For loop the @For loop has nothing to iterate over. Am I missing something?
On 1/9/07, Jim Downing <[EMAIL PROTECTED]> wrote:
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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]