You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephan Windmüller <st...@cs.tu-dortmund.de> on 2010/02/09 09:24:54 UTC
Adding textfields to a form dynamically
Hello!
On a page I have a list of strings, each represented by a TextField in a
form.
The user should be able to edit the Strings and add new ones. Also it
should be possible to add many of them and fill them afterwards:
----
Java:
@Property
private List<String> values;
@Property
private String current;
void onSelectedFromAdd() {
values.add("");
}
TML:
<t:form>
<t:loop source="values" value="current">
<t:textfield value="current"/><br/>
</t:loop>
<input t:type="Submit" t:id="add" value="Add"/>
<input t:type="Submit" value="Save"/>
</t:form>
----
My question is: How do I store the List of Strings until it is actually
saved? Adding fields should not use the database. Does anyone know a
solution for this other than @Persist?
TIA
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding textfields to a form dynamically
Posted by Piero Sartini <li...@pierosartini.de>.
> This sounds very promising, thanks for the link!
>
> The demo does not work without JavaScript, I hope it is not a general
> problem with the project.
This is because zones are used to refresh the page. It has nothing to
do with the conversation stuff.
Piero
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding textfields to a form dynamically
Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Am 10.02.2010 13:22, Piero Sartini wrote:
>>> Why don't you want to use @Persist?
>> It breaks tabbed browsing. The user would not be able to open two tabs and
>> edit separate lists before submitting them. Therefore I banned the use of
>> @Persist in my application.
> You may want to have a look at tynamo's tapestry-conversation:
> http://tynamo.org/tapestry-conversations+guide
This sounds very promising, thanks for the link!
The demo does not work without JavaScript, I hope it is not a general
problem with the project.
- Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding textfields to a form dynamically
Posted by Piero Sartini <li...@pierosartini.de>.
>> Why don't you want to use @Persist?
>
> It breaks tabbed browsing. The user would not be able to open two tabs and
> edit separate lists before submitting them. Therefore I banned the use of
> @Persist in my application.
You may want to have a look at tynamo's tapestry-conversation:
http://tynamo.org/tapestry-conversations+guide
Piero
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding textfields to a form dynamically
Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Am 09.02.2010 15:49, Michael Prescott wrote:
> If you can't count on JavaScript, then you need to do a round trip to the
> server to add new form fields.. in which case, you should be okay using
> conventional techniques. (e.g. add a black entry to your List, re-render
> the page).
I solved it now by
- Introducing an index for the loop and implementing getter and setter
based on it
- Using PersistanceContants.FLASH for the list
- Injecting the same page, setting the list and passing the page in
onSuccess
> Why don't you want to use @Persist?
It breaks tabbed browsing. The user would not be able to open two tabs
and edit separate lists before submitting them. Therefore I banned the
use of @Persist in my application.
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding textfields to a form dynamically
Posted by Michael Prescott <mi...@gmail.com>.
If you can't count on JavaScript, then you need to do a round trip to the
server to add new form fields.. in which case, you should be okay using
conventional techniques. (e.g. add a black entry to your List, re-render
the page).
Why don't you want to use @Persist?
Michael
On Tue, Feb 9, 2010 at 4:08 AM, Ulrich Stärk <ul...@spielviel.de> wrote:
> Honestly, I don't know.
>
> On 09.02.2010 09:43 schrieb Stephan Windmüller:
>
> Am 09.02.2010 09:40, schrieb Ulrich Stärk:
>>
>> My question is: How do I store the List of Strings until it is
>>>> actually saved? Adding fields should not use the database. Does
>>>> anyone know a solution for this other than @Persist?
>>>>
>>> Could the AjaxFormLoop component be of help?
>>>
>>
>> Would this also work if the user has JavaScript disabled?
>>
>> Regards
>> Stephan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Adding textfields to a form dynamically
Posted by Ulrich Stärk <ul...@spielviel.de>.
Honestly, I don't know.
On 09.02.2010 09:43 schrieb Stephan Windmüller:
> Am 09.02.2010 09:40, schrieb Ulrich Stärk:
>
>>> My question is: How do I store the List of Strings until it is
>>> actually saved? Adding fields should not use the database. Does
>>> anyone know a solution for this other than @Persist?
>> Could the AjaxFormLoop component be of help?
>
> Would this also work if the user has JavaScript disabled?
>
> Regards
> Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding textfields to a form dynamically
Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Am 09.02.2010 09:40, schrieb Ulrich Stärk:
>> My question is: How do I store the List of Strings until it is
>> actually saved? Adding fields should not use the database. Does
>> anyone know a solution for this other than @Persist?
> Could the AjaxFormLoop component be of help?
Would this also work if the user has JavaScript disabled?
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding textfields to a form dynamically
Posted by Ulrich Stärk <ul...@spielviel.de>.
Could the AjaxFormLoop component be of help?
http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html
Uli
On 09.02.2010 09:24 schrieb Stephan Windmüller:
> Hello!
>
> On a page I have a list of strings, each represented by a TextField in a
> form.
>
> The user should be able to edit the Strings and add new ones. Also it
> should be possible to add many of them and fill them afterwards:
>
> ----
>
> Java:
>
> @Property
> private List<String> values;
>
> @Property
> private String current;
>
> void onSelectedFromAdd() {
> values.add("");
> }
>
> TML:
>
> <t:form>
> <t:loop source="values" value="current">
> <t:textfield value="current"/><br/>
> </t:loop>
> <input t:type="Submit" t:id="add" value="Add"/>
> <input t:type="Submit" value="Save"/>
> </t:form>
>
> ----
>
> My question is: How do I store the List of Strings until it is actually
> saved? Adding fields should not use the database. Does anyone know a
> solution for this other than @Persist?
>
> TIA
> Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org