You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Gunnar Eketrapp <gu...@gmail.com> on 2009/10/06 16:51:17 UTC

T5 / Creating a form insides a loop ...

Hi !

I am porting a project from a ancient technology (starts with j and ends
with p)  and have come across a loop where
a form is created inside the loop.

The form has three hidden fields + a text field and my question is how is
this best done the T5 way ... I looked in the howto's
but couldn't find a match to my problem.

The problem is that I would like <t:hidden> to take one property as the
inparameter and another as the out parameter.

Ofcourse I have missed something ...

Thanks in advance,
Gunnar Eketrapp

This is the current unfinished TML version  ...

<t:loop source="${items}" value="item">
        <tr>
                <td>
                <t:form>
                    <input type="hidden" name="year" value="${ item.year}"
/>
                    <input type="hidden" name="weekNum" value="${
item.weekNum }" />
                    <input type="hidden" name="grossRevenue" value="${
item.totalRakeInCents / 100.0 }" />
                    Base percentage: <input type="text"
name="payoutPercentage" value="0.40" />
                    <input type="submit" value="Create &raquo;"
class="nicebutton"/>
                </t:form>
                </td>
            </t:if>
...

Re: T5 / Creating a form insides a loop ...

Posted by cordenier christophe <ch...@gmail.com>.
Hello

- Note that if you want to have only one submit button in one form, it is
possible to use the tapestry grid and loop component with a value encoder to
have a global submit.

- If you want to add rows dynamically, have a look the AjaxFormLoop that
also have an encoder parameter.

By the way, using a loop with hiddenfield or a context sounds good to me.
But keep in mind that by using context, i'm not sure that you can enjoy
validation and automatic binding features provided with the Hidden component
(an all the form components)

Christophe.

2009/10/6 Gunnar Eketrapp <gu...@gmail.com>

> Hi !
>
> OK I'll try ...
>
> I have a table where each row contains a form with some hidden fields
> (year,week) + a field to enter percentage value plus s a submit button.
>
> How would you port this!
>
> Currently I am testing to pass a context to the form and It seems like that
> might be the right track ....
>
> /Gunnar
>
> 2009/10/6 Toby Hobson <to...@googlemail.com>
>
> > Hi Gunnar
> >
> > Maybe you could give us a higher level explanation of what you are trying
> > to
> > achieve i.e. what is the business logic driving this? In my experience
> when
> > migrating from a technology like struts or servlets to tapestry it's best
> > to
> > rethink your whole strategy, instead of thinking in terms of "i did this
> in
> > a servlet, how do I do it in tapestry"
> >
> > Toby
> >
> > 2009/10/6 Gunnar Eketrapp <gu...@gmail.com>
> >
> > > Hi!
> > >
> > > Ok the ${} was a typo ... I havent tested the page yeat you know!
> > >
> > > My problem is that each form pass a context (in three hidden fields)
> back
> > > to
> > > the server and how is this best done!
> > >
> > > But I just saw that I could pass a t:context attribute to my form so I
> > will
> > > try that solution.
> > >
> > > E.g I will now try something like ...
> > >
> > > <t:loop source="items" value="item">
> > >         <tr>
> > >                <td>
> > >                <t:form
> t:context="item.year,item.weekNum,item.totalRake">
> > >                     Base percentage: <input type="text"
> > > name="payoutPercentage" value="0.40" />
> > >                    <input type="submit" value="Create &raquo;"
> > > class="nicebutton"/>
> > >                </t:form>
> > >                </td>
> > >            </t:if>
> > > ..
> > >
> > >
> > >
> > >
> > > 2009/10/6 Thiago H. de Paula Figueiredo <th...@gmail.com>
> > >
> > > > Em Tue, 06 Oct 2009 11:51:17 -0300, Gunnar Eketrapp <
> > > > gunnar.eketrapp@gmail.com> escreveu:
> > > >
> > > >  Hi !
> > > >>
> > > >
> > > > Hi!
> > > >
> > > >  The problem is that I would like <t:hidden> to take one property as
> > the
> > > >> inparameter and another as the out parameter.
> > > >>
> > > >
> > > > Why?
> > > >
> > > >  <t:loop source="${items}" value="item">
> > > >>
> > > >
> > > > Never use ${} as a component parameter. Never!
> > > >
> > > > --
> > > > Thiago H. de Paula Figueiredo
> > > > Independent Java consultant, developer, and instructor
> > > > http://www.arsmachina.com.br/thiago
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > [Hem: 08-715 59 57, Mobil: 0708-52 62 90]
> > > Allévägen 2A, 132 42 Saltsjö-Boo
> > >
> >
>
>
>
> --
> [Hem: 08-715 59 57, Mobil: 0708-52 62 90]
> Allévägen 2A, 132 42 Saltsjö-Boo
>

Re: T5 / Creating a form insides a loop ...

Posted by Gunnar Eketrapp <gu...@gmail.com>.
Hi !

OK I'll try ...

I have a table where each row contains a form with some hidden fields
(year,week) + a field to enter percentage value plus s a submit button.

How would you port this!

Currently I am testing to pass a context to the form and It seems like that
might be the right track ....

/Gunnar

2009/10/6 Toby Hobson <to...@googlemail.com>

> Hi Gunnar
>
> Maybe you could give us a higher level explanation of what you are trying
> to
> achieve i.e. what is the business logic driving this? In my experience when
> migrating from a technology like struts or servlets to tapestry it's best
> to
> rethink your whole strategy, instead of thinking in terms of "i did this in
> a servlet, how do I do it in tapestry"
>
> Toby
>
> 2009/10/6 Gunnar Eketrapp <gu...@gmail.com>
>
> > Hi!
> >
> > Ok the ${} was a typo ... I havent tested the page yeat you know!
> >
> > My problem is that each form pass a context (in three hidden fields) back
> > to
> > the server and how is this best done!
> >
> > But I just saw that I could pass a t:context attribute to my form so I
> will
> > try that solution.
> >
> > E.g I will now try something like ...
> >
> > <t:loop source="items" value="item">
> >         <tr>
> >                <td>
> >                <t:form t:context="item.year,item.weekNum,item.totalRake">
> >                     Base percentage: <input type="text"
> > name="payoutPercentage" value="0.40" />
> >                    <input type="submit" value="Create &raquo;"
> > class="nicebutton"/>
> >                </t:form>
> >                </td>
> >            </t:if>
> > ..
> >
> >
> >
> >
> > 2009/10/6 Thiago H. de Paula Figueiredo <th...@gmail.com>
> >
> > > Em Tue, 06 Oct 2009 11:51:17 -0300, Gunnar Eketrapp <
> > > gunnar.eketrapp@gmail.com> escreveu:
> > >
> > >  Hi !
> > >>
> > >
> > > Hi!
> > >
> > >  The problem is that I would like <t:hidden> to take one property as
> the
> > >> inparameter and another as the out parameter.
> > >>
> > >
> > > Why?
> > >
> > >  <t:loop source="${items}" value="item">
> > >>
> > >
> > > Never use ${} as a component parameter. Never!
> > >
> > > --
> > > Thiago H. de Paula Figueiredo
> > > Independent Java consultant, developer, and instructor
> > > http://www.arsmachina.com.br/thiago
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > [Hem: 08-715 59 57, Mobil: 0708-52 62 90]
> > Allévägen 2A, 132 42 Saltsjö-Boo
> >
>



-- 
[Hem: 08-715 59 57, Mobil: 0708-52 62 90]
Allévägen 2A, 132 42 Saltsjö-Boo

Re: T5 / Creating a form insides a loop ...

Posted by Toby Hobson <to...@googlemail.com>.
Hi Gunnar

Maybe you could give us a higher level explanation of what you are trying to
achieve i.e. what is the business logic driving this? In my experience when
migrating from a technology like struts or servlets to tapestry it's best to
rethink your whole strategy, instead of thinking in terms of "i did this in
a servlet, how do I do it in tapestry"

Toby

2009/10/6 Gunnar Eketrapp <gu...@gmail.com>

> Hi!
>
> Ok the ${} was a typo ... I havent tested the page yeat you know!
>
> My problem is that each form pass a context (in three hidden fields) back
> to
> the server and how is this best done!
>
> But I just saw that I could pass a t:context attribute to my form so I will
> try that solution.
>
> E.g I will now try something like ...
>
> <t:loop source="items" value="item">
>         <tr>
>                <td>
>                <t:form t:context="item.year,item.weekNum,item.totalRake">
>                     Base percentage: <input type="text"
> name="payoutPercentage" value="0.40" />
>                    <input type="submit" value="Create &raquo;"
> class="nicebutton"/>
>                </t:form>
>                </td>
>            </t:if>
> ..
>
>
>
>
> 2009/10/6 Thiago H. de Paula Figueiredo <th...@gmail.com>
>
> > Em Tue, 06 Oct 2009 11:51:17 -0300, Gunnar Eketrapp <
> > gunnar.eketrapp@gmail.com> escreveu:
> >
> >  Hi !
> >>
> >
> > Hi!
> >
> >  The problem is that I would like <t:hidden> to take one property as the
> >> inparameter and another as the out parameter.
> >>
> >
> > Why?
> >
> >  <t:loop source="${items}" value="item">
> >>
> >
> > Never use ${} as a component parameter. Never!
> >
> > --
> > Thiago H. de Paula Figueiredo
> > Independent Java consultant, developer, and instructor
> > http://www.arsmachina.com.br/thiago
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> [Hem: 08-715 59 57, Mobil: 0708-52 62 90]
> Allévägen 2A, 132 42 Saltsjö-Boo
>

Re: T5 / Creating a form insides a loop ...

Posted by Gunnar Eketrapp <gu...@gmail.com>.
Hi!

Ok the ${} was a typo ... I havent tested the page yeat you know!

My problem is that each form pass a context (in three hidden fields) back to
the server and how is this best done!

But I just saw that I could pass a t:context attribute to my form so I will
try that solution.

E.g I will now try something like ...

<t:loop source="items" value="item">
        <tr>
                <td>
                <t:form t:context="item.year,item.weekNum,item.totalRake">
                    Base percentage: <input type="text"
name="payoutPercentage" value="0.40" />
                    <input type="submit" value="Create &raquo;"
class="nicebutton"/>
                </t:form>
                </td>
            </t:if>
..




2009/10/6 Thiago H. de Paula Figueiredo <th...@gmail.com>

> Em Tue, 06 Oct 2009 11:51:17 -0300, Gunnar Eketrapp <
> gunnar.eketrapp@gmail.com> escreveu:
>
>  Hi !
>>
>
> Hi!
>
>  The problem is that I would like <t:hidden> to take one property as the
>> inparameter and another as the out parameter.
>>
>
> Why?
>
>  <t:loop source="${items}" value="item">
>>
>
> Never use ${} as a component parameter. Never!
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
[Hem: 08-715 59 57, Mobil: 0708-52 62 90]
Allévägen 2A, 132 42 Saltsjö-Boo

Re: T5 / Creating a form insides a loop ...

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 06 Oct 2009 11:51:17 -0300, Gunnar Eketrapp  
<gu...@gmail.com> escreveu:

> Hi !

Hi!

> The problem is that I would like <t:hidden> to take one property as the
> inparameter and another as the out parameter.

Why?

> <t:loop source="${items}" value="item">

Never use ${} as a component parameter. Never!

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org