I've been trying to use FormInjector to create a dynamic form and not getting very far. I've taken the demo that Igor gave links to and simply taken it out of the border element. It works fine unless I add the t:label component in the block. It seems to me that as soon as there is more than one kind of component in the injected block, the inserted HTML is just "<li class="t-beaneditor-row"/>" without any form elements. Two textfields work, and a textfield and an 'any' component work, but not label or radio with a textfield. I suspect it's all form components.
Here's the modified demo. Remove the label component to see it working. Add back in to see it broken again. I think this might be connected with TAPESTRY-2322. Am I doing something wrong here, or is it a bug? <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> <head> <title>Tapestry Integration Test Application #1</title> </head> <body> <t:form> <t:block id="newRow"> <div class="t-beaneditor-row"> <t:submitnotifier> <t:radio value="rad"/> <t:textfield t:id="value"/> </t:submitnotifier> </div> </t:block> <ul> <li t:id="forminjector" class="t-beaneditor-row"> <a href="#" id="addnewrow">Add a row</a> </li> </ul> <div class="t-beaneditor-row"> <input type="submit" value="Sum up the values"/> </div> </t:form> <p>Current sum: <span id="sum">${sum}</span></p> </body> </html> public class FormInjectorDemo { @Persist private double _sum; private double _value; @Inject private Block _newRow; @Inject private PageRenderSupport _pageRenderSupport; @Component private FormInjector _formInjector; public double getSum() { return _sum; } public double getValue() { return _value; } public void setValue(double value) { _value = value; } void onPrepareForSubmit() { _sum = 0; } void onAfterSubmit() { _sum += _value; } void afterRender() { _pageRenderSupport.addScript( "$('addnewrow').observe('click', function() { $('%s').trigger(); return false; });", _formInjector.getClientId()); } Object onActionFromFormInjector() { return _newRow; } } > -----Original Message----- > From: Igor Drobiazko [mailto:[EMAIL PROTECTED] > Sent: 15 April 2008 15:28 > To: Tapestry users > Subject: Re: Dynamic list of strings in a form > > Ups, wrong template url. This one is the correct one: > http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry- > core/src/test/app1/FormInjectorDemo.tml?view=markup > > On Tue, Apr 15, 2008 at 4:20 PM, Igor Drobiazko > <[EMAIL PROTECTED]> > wrote: > > > Have a look at the FormInjector component. This component is what you > > need. > > http://tapestry.apache.org/tapestry5/tapestry- > core/ref/org/apache/tapestry/corelib/components/FormInjector.html > > > > An example can be found here: > > > > http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry- > core/src/test/java/org/apache/tapestry/integration/app1/pages/FormInjec > torDemo.java?view=markup > > > > http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry- > core/src/test/app1/FormFragmentDemo.tml?view=markup > > > > > > > > On Tue, Apr 15, 2008 at 3:51 PM, Michael Dukaczewski < > > [EMAIL PROTECTED]> wrote: > > > > > I am using Tapestry 5.0.11 and have a problem with a dynamic list > of > > > strings in a form. What I am trying, is the following: > > > > > > In the Page.java: > > > > > > @Persist > > > private List<String> items; > > > > > > @Property > > > private String item; > > > > > > public List<String> getItems() { > > > if (items == null) { > > > items = new LinkedList<String>(); > > > } > > > return items; > > > } > > > > > > public void onSelectedFromAdd() { > > > getItems().add(""); > > > } > > > > > > And in the Page.tml: > > > > > > <t:form> > > > <div t:type="loop" t:source="items" t:value="item"> > > > <t:textfield value="item" /> > > > </div> > > > <div><t:submit t:id="add" value="more"/></div> > > > <div><t:submit t:id="save" value="save"/></div> > > > </t:form> > > > > > > > > > I have a list of values, the user has to enter. The number of > values, > > > that have to be typed in, is dynamic, so the user has to extend the > form. > > > The add button works, but the values are not saved. Can someone > tell me, > > > that I am doing wrong? > > > > > > > > > ------------------------------------------------------------------- > -- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > -- > > Best regards, > > > > Igor Drobiazko > > > > > -- > Best regards, > > Igor Drobiazko --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]