You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mohammad Shamsi <m....@gmail.com> on 2007/10/14 11:07:27 UTC

T5 2 question about loop component parameters

hi all,

please take a look at my page bellow,

        <!-- do i have to define item object in page class ?? i want to use
it just here in page ??? -->
        <t:loop source="items" value="item" >

        <tr>
            <!-- i want to put an index here for each row in table -->
            <td> ??? </td>
            <td>${item.firstName}</td>
            <td>${item.lastName}</td>
            <td>${item.phone}</td>
        </tr>
        </t:loop>

1 - i just want to use  item object here, for iteration, i don't want to
define it at my page class, can i ?

2  - i need an index var for each row, but it seems that for use index
attribute in loop component, i have to define a property at my page class
first, :((

-- 
sincerely yours
M. H. Shamsi

Re: T5 2 question about loop component parameters

Posted by Ted Steen <te...@gmail.com>.
java:
	private int currValue;

	public int getCurrValue()
	{
		return currValue;
	}

	public void setCurrValue(int currValue)
	{
		this.currValue = currValue;
	}


template:
	<t:loop source="1..5" value="currValue">
		${currValue}<br/>
	</t:loop>

2007/10/14, Mohammad Shamsi <m....@gmail.com>:
> dear Nick,
>
> i want index just for iteration, i don't need it in may page class, i think
> that its better to define in Loop component class,
>
> suppose that i want to use Loop, 5 times in a singe page, then i most define
> 5 index value, and five item object ???
>
>
>
> On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
> >
> > The value and index have to go somewhere. Why not in your page class?
> >
> > Cheers,
> > Nick.
> >
> >
> > Mohammad Shamsi wrote:
> > > hi all,
> > >
> > > please take a look at my page bellow,
> > >
> > >         <!-- do i have to define item object in page class ?? i want to
> > use
> > > it just here in page ??? -->
> > >         <t:loop source="items" value="item" >
> > >
> > >         <tr>
> > >             <!-- i want to put an index here for each row in table -->
> > >             <td> ??? </td>
> > >             <td>${item.firstName}</td>
> > >             <td>${item.lastName}</td>
> > >             <td>${item.phone}</td>
> > >         </tr>
> > >         </t:loop>
> > >
> > > 1 - i just want to use  item object here, for iteration, i don't want to
> > > define it at my page class, can i ?
> > >
> > > 2  - i need an index var for each row, but it seems that for use index
> > > attribute in loop component, i have to define a property at my page
> > class
> > > first, :((
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> sincerely yours
> M. H. Shamsi
>


-- 
/ted

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


Re: T5 2 question about loop component parameters

Posted by Ivan Dubrov <wf...@gmail.com>.
Andreas Andreou wrote:
> Not having to create getters & setters (or abstract getters in T4) just so
> that @Loop (and @For) values and indexes can
> become accessible is a fairly often request/question...
>
> Creating a custom binding prefix (perhaps named temp) that attaches objects
> to the currect requestcycle
> and reads from them looks like an elegant solution - of course, the temp
> binding would also need to support
> object navigation if it's going to be of any value, so perhaps it could
> reuse parts of the prop binding?
>   
If I'm not mistaken, prop binding uses static type of the property to
build the accessors, so you cannot use it in cases the type is not known
during page loading time.

In my project I've implemented OGNL binding and put the "state" Map
(which is local to the component and request lifecycle) into the ognl
root context, so I can, for example, write loops like:

<t:loop source="data" value="ognl:#state.current">
  <t:if test="ognl:#state.current.key != null">
  Key: ${ognl:#state.current.key}
  </t:if>
</t:loop>

Of course, this sacrifices the performance a bit, since OGNL will be
slower (probably, much slower) than PropBinding.

-- 
WBR,
Ivan S. Dubrov



Re: T5 2 question about loop component parameters

Posted by Andreas Andreou <an...@gmail.com>.
Not having to create getters & setters (or abstract getters in T4) just so
that @Loop (and @For) values and indexes can
become accessible is a fairly often request/question...

Creating a custom binding prefix (perhaps named temp) that attaches objects
to the currect requestcycle
and reads from them looks like an elegant solution - of course, the temp
binding would also need to support
object navigation if it's going to be of any value, so perhaps it could
reuse parts of the prop binding?



On 10/14/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>
> You can define a variable as a field of your component class.
>
> However, it won't be visible without your providing a getter and setter.
>
> Example:
>
> <t:loop source="database.users" value="user">
>   <p>${user.name}</p>
> </t:loop>
>
> Java code:
>
> public class MyPage {
>
>   @Inject
>   private UserDatabase _database;
>
>   private User _user;
>
>   public UserDatabase getDatabase() { return _database; }
>
>   public void setUser(User user) { _user = user; }
>
>   public User getUser() { return _user;
> }
>
> JSPs are based on a pretty ugly concept: code generation, as in it takes
> your JSP and your snippets and generates and compiles a Java class from
> them. Ugly because a stray "{" in your snippet throws a monkey wrench into
> the works. Tapestry gets a big performance advantage over JSPs because of
> how stupied the JSP code generation tends to be.
>
> Anyway, Tapestry parameters are private fields, to be visible outside the
> component's code they must be exposed as properties: read-only or
> read/write
> (or even write-only) by providing the correct accessors.
>
> My comments was that the Loop component has the values you are looking for
> ... but it's not sharing.  Add an issue and we'll see about getting that
> into 5.0.6 or 5.0.7.
>
> On 10/14/07, Mohammad Shamsi <m....@gmail.com> wrote:
> >
> > hi Howard,
> >
> > i have no experience in Tapestry,  i just test it for replacing  my
> > company
> > framework.
> > i use for 6 years struts, webworks and my own framework that based on
> both
> > struts and webworks.
> >
> > in pages that made from JSP and JSTL , we can simply define a variable
> in
> > page, this variable bind  on specified scope (page, session, ...). I
> guess
> > that if you define a new prefix for inline variables (on space
> variables)
> > ,
> > we can easily use it in components and page templates if need.
> >
> > in  a simple implement each page or component can have a map for holding
> > on
> > space variables an values. (Map<String /*variable name*/, Object
> > /*variable
> > values*/>  )
> >
> > am i right ? i don't know  :(
> >
> > On 10/14/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> > >
> > > If we made the getIndex() and getValue() methods of Loop public, then
> > you
> > > could:
> > >
> > >
> > >        <span t:id="loop" source="1..5">
> > >                ${loop.currValue}<br/>
> > >        </span>
> > >
> > > But then you must define your loop in your Java class and expose it as
> a
> > > property:
> > >
> > > @Component
> > > private Loop _loop;
> > >
> > > public Loop getLoop() { return _loop; }
> > >
> > >
> > > .... however that won't work currently, because those methods are not
> > > visible.  If you add an issue, it's a few second's work to make them
> > > public.
> > >
> > > On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
> > > >
> > > > I can see what you mean, though it is quite common to use the index
> > > inside
> > > > the page class too. T5 keeps things simple to cover the most common
> > > cases.
> > > >
> > > > You can create your own components if you don't like the default
> ones.
> > > > It would be interesting to see an alternative if you write one.
> > > >
> > > > Cheers,
> > > > Nick.
> > > >
> > > >
> > > > Mohammad Shamsi wrote:
> > > > > dear Nick,
> > > > >
> > > > > i want index just for iteration, i don't need it in may page
> class,
> > i
> > > > think
> > > > > that its better to define in Loop component class,
> > > > >
> > > > > suppose that i want to use Loop, 5 times in a singe page, then i
> > most
> > > > define
> > > > > 5 index value, and five item object ???
> > > > >
> > > > >
> > > > >
> > > > > On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
> > > > >> The value and index have to go somewhere. Why not in your page
> > class?
> > > > >>
> > > > >> Cheers,
> > > > >> Nick.
> > > > >>
> > > > >>
> > > > >> Mohammad Shamsi wrote:
> > > > >>> hi all,
> > > > >>>
> > > > >>> please take a look at my page bellow,
> > > > >>>
> > > > >>>         <!-- do i have to define item object in page class ?? i
> > want
> > > > to
> > > > >> use
> > > > >>> it just here in page ??? -->
> > > > >>>         <t:loop source="items" value="item" >
> > > > >>>
> > > > >>>         <tr>
> > > > >>>             <!-- i want to put an index here for each row in
> table
> > > -->
> > > > >>>             <td> ??? </td>
> > > > >>>             <td>${item.firstName}</td>
> > > > >>>             <td>${item.lastName}</td>
> > > > >>>             <td>${item.phone}</td>
> > > > >>>         </tr>
> > > > >>>         </t:loop>
> > > > >>>
> > > > >>> 1 - i just want to use  item object here, for iteration, i don't
> > > want
> > > > to
> > > > >>> define it at my page class, can i ?
> > > > >>>
> > > > >>> 2  - i need an index var for each row, but it seems that for use
> > > index
> > > > >>> attribute in loop component, i have to define a property at my
> > page
> > > > >> class
> > > > >>> first, :((
> > > > >>>
> > > > >>
> > ---------------------------------------------------------------------
> > > > >> 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
> > > >
> > > >
> > >
> > >
> > > --
> > > Howard M. Lewis Ship
> > > Partner and Senior Architect at Feature50
> > >
> > > Creator Apache Tapestry and Apache HiveMind
> > >
> >
> >
> >
> > --
> > sincerely yours
> > M. H. Shamsi
> >
>
>
>
> --
> Howard M. Lewis Ship
> Partner and Senior Architect at Feature50
>
> Creator Apache Tapestry and Apache HiveMind
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

Re: T5 2 question about loop component parameters

Posted by Howard Lewis Ship <hl...@gmail.com>.
You can define a variable as a field of your component class.

However, it won't be visible without your providing a getter and setter.

Example:

<t:loop source="database.users" value="user">
  <p>${user.name}</p>
</t:loop>

Java code:

public class MyPage {

  @Inject
  private UserDatabase _database;

  private User _user;

  public UserDatabase getDatabase() { return _database; }

  public void setUser(User user) { _user = user; }

  public User getUser() { return _user;
}

JSPs are based on a pretty ugly concept: code generation, as in it takes
your JSP and your snippets and generates and compiles a Java class from
them. Ugly because a stray "{" in your snippet throws a monkey wrench into
the works. Tapestry gets a big performance advantage over JSPs because of
how stupied the JSP code generation tends to be.

Anyway, Tapestry parameters are private fields, to be visible outside the
component's code they must be exposed as properties: read-only or read/write
(or even write-only) by providing the correct accessors.

My comments was that the Loop component has the values you are looking for
... but it's not sharing.  Add an issue and we'll see about getting that
into 5.0.6 or 5.0.7.

On 10/14/07, Mohammad Shamsi <m....@gmail.com> wrote:
>
> hi Howard,
>
> i have no experience in Tapestry,  i just test it for replacing  my
> company
> framework.
> i use for 6 years struts, webworks and my own framework that based on both
> struts and webworks.
>
> in pages that made from JSP and JSTL , we can simply define a variable in
> page, this variable bind  on specified scope (page, session, ...). I guess
> that if you define a new prefix for inline variables (on space variables)
> ,
> we can easily use it in components and page templates if need.
>
> in  a simple implement each page or component can have a map for holding
> on
> space variables an values. (Map<String /*variable name*/, Object
> /*variable
> values*/>  )
>
> am i right ? i don't know  :(
>
> On 10/14/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> >
> > If we made the getIndex() and getValue() methods of Loop public, then
> you
> > could:
> >
> >
> >        <span t:id="loop" source="1..5">
> >                ${loop.currValue}<br/>
> >        </span>
> >
> > But then you must define your loop in your Java class and expose it as a
> > property:
> >
> > @Component
> > private Loop _loop;
> >
> > public Loop getLoop() { return _loop; }
> >
> >
> > .... however that won't work currently, because those methods are not
> > visible.  If you add an issue, it's a few second's work to make them
> > public.
> >
> > On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
> > >
> > > I can see what you mean, though it is quite common to use the index
> > inside
> > > the page class too. T5 keeps things simple to cover the most common
> > cases.
> > >
> > > You can create your own components if you don't like the default ones.
> > > It would be interesting to see an alternative if you write one.
> > >
> > > Cheers,
> > > Nick.
> > >
> > >
> > > Mohammad Shamsi wrote:
> > > > dear Nick,
> > > >
> > > > i want index just for iteration, i don't need it in may page class,
> i
> > > think
> > > > that its better to define in Loop component class,
> > > >
> > > > suppose that i want to use Loop, 5 times in a singe page, then i
> most
> > > define
> > > > 5 index value, and five item object ???
> > > >
> > > >
> > > >
> > > > On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
> > > >> The value and index have to go somewhere. Why not in your page
> class?
> > > >>
> > > >> Cheers,
> > > >> Nick.
> > > >>
> > > >>
> > > >> Mohammad Shamsi wrote:
> > > >>> hi all,
> > > >>>
> > > >>> please take a look at my page bellow,
> > > >>>
> > > >>>         <!-- do i have to define item object in page class ?? i
> want
> > > to
> > > >> use
> > > >>> it just here in page ??? -->
> > > >>>         <t:loop source="items" value="item" >
> > > >>>
> > > >>>         <tr>
> > > >>>             <!-- i want to put an index here for each row in table
> > -->
> > > >>>             <td> ??? </td>
> > > >>>             <td>${item.firstName}</td>
> > > >>>             <td>${item.lastName}</td>
> > > >>>             <td>${item.phone}</td>
> > > >>>         </tr>
> > > >>>         </t:loop>
> > > >>>
> > > >>> 1 - i just want to use  item object here, for iteration, i don't
> > want
> > > to
> > > >>> define it at my page class, can i ?
> > > >>>
> > > >>> 2  - i need an index var for each row, but it seems that for use
> > index
> > > >>> attribute in loop component, i have to define a property at my
> page
> > > >> class
> > > >>> first, :((
> > > >>>
> > > >>
> ---------------------------------------------------------------------
> > > >> 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
> > >
> > >
> >
> >
> > --
> > Howard M. Lewis Ship
> > Partner and Senior Architect at Feature50
> >
> > Creator Apache Tapestry and Apache HiveMind
> >
>
>
>
> --
> sincerely yours
> M. H. Shamsi
>



-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

Re: T5 2 question about loop component parameters

Posted by Mohammad Shamsi <m....@gmail.com>.
hi Howard,

i have no experience in Tapestry,  i just test it for replacing  my company
framework.
i use for 6 years struts, webworks and my own framework that based on both
struts and webworks.

in pages that made from JSP and JSTL , we can simply define a variable in
page, this variable bind  on specified scope (page, session, ...). I guess
that if you define a new prefix for inline variables (on space variables) ,
we can easily use it in components and page templates if need.

in  a simple implement each page or component can have a map for holding on
space variables an values. (Map<String /*variable name*/, Object /*variable
values*/>  )

am i right ? i don't know  :(

On 10/14/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>
> If we made the getIndex() and getValue() methods of Loop public, then you
> could:
>
>
>        <span t:id="loop" source="1..5">
>                ${loop.currValue}<br/>
>        </span>
>
> But then you must define your loop in your Java class and expose it as a
> property:
>
> @Component
> private Loop _loop;
>
> public Loop getLoop() { return _loop; }
>
>
> .... however that won't work currently, because those methods are not
> visible.  If you add an issue, it's a few second's work to make them
> public.
>
> On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
> >
> > I can see what you mean, though it is quite common to use the index
> inside
> > the page class too. T5 keeps things simple to cover the most common
> cases.
> >
> > You can create your own components if you don't like the default ones.
> > It would be interesting to see an alternative if you write one.
> >
> > Cheers,
> > Nick.
> >
> >
> > Mohammad Shamsi wrote:
> > > dear Nick,
> > >
> > > i want index just for iteration, i don't need it in may page class, i
> > think
> > > that its better to define in Loop component class,
> > >
> > > suppose that i want to use Loop, 5 times in a singe page, then i most
> > define
> > > 5 index value, and five item object ???
> > >
> > >
> > >
> > > On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
> > >> The value and index have to go somewhere. Why not in your page class?
> > >>
> > >> Cheers,
> > >> Nick.
> > >>
> > >>
> > >> Mohammad Shamsi wrote:
> > >>> hi all,
> > >>>
> > >>> please take a look at my page bellow,
> > >>>
> > >>>         <!-- do i have to define item object in page class ?? i want
> > to
> > >> use
> > >>> it just here in page ??? -->
> > >>>         <t:loop source="items" value="item" >
> > >>>
> > >>>         <tr>
> > >>>             <!-- i want to put an index here for each row in table
> -->
> > >>>             <td> ??? </td>
> > >>>             <td>${item.firstName}</td>
> > >>>             <td>${item.lastName}</td>
> > >>>             <td>${item.phone}</td>
> > >>>         </tr>
> > >>>         </t:loop>
> > >>>
> > >>> 1 - i just want to use  item object here, for iteration, i don't
> want
> > to
> > >>> define it at my page class, can i ?
> > >>>
> > >>> 2  - i need an index var for each row, but it seems that for use
> index
> > >>> attribute in loop component, i have to define a property at my page
> > >> class
> > >>> first, :((
> > >>>
> > >> ---------------------------------------------------------------------
> > >> 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
> >
> >
>
>
> --
> Howard M. Lewis Ship
> Partner and Senior Architect at Feature50
>
> Creator Apache Tapestry and Apache HiveMind
>



-- 
sincerely yours
M. H. Shamsi

Re: T5 2 question about loop component parameters

Posted by Howard Lewis Ship <hl...@gmail.com>.
If we made the getIndex() and getValue() methods of Loop public, then you
could:


       <span t:id="loop" source="1..5">
               ${loop.currValue}<br/>
       </span>

But then you must define your loop in your Java class and expose it as a
property:

@Component
private Loop _loop;

public Loop getLoop() { return _loop; }


.... however that won't work currently, because those methods are not
visible.  If you add an issue, it's a few second's work to make them public.

On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
>
> I can see what you mean, though it is quite common to use the index inside
> the page class too. T5 keeps things simple to cover the most common cases.
>
> You can create your own components if you don't like the default ones.
> It would be interesting to see an alternative if you write one.
>
> Cheers,
> Nick.
>
>
> Mohammad Shamsi wrote:
> > dear Nick,
> >
> > i want index just for iteration, i don't need it in may page class, i
> think
> > that its better to define in Loop component class,
> >
> > suppose that i want to use Loop, 5 times in a singe page, then i most
> define
> > 5 index value, and five item object ???
> >
> >
> >
> > On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
> >> The value and index have to go somewhere. Why not in your page class?
> >>
> >> Cheers,
> >> Nick.
> >>
> >>
> >> Mohammad Shamsi wrote:
> >>> hi all,
> >>>
> >>> please take a look at my page bellow,
> >>>
> >>>         <!-- do i have to define item object in page class ?? i want
> to
> >> use
> >>> it just here in page ??? -->
> >>>         <t:loop source="items" value="item" >
> >>>
> >>>         <tr>
> >>>             <!-- i want to put an index here for each row in table -->
> >>>             <td> ??? </td>
> >>>             <td>${item.firstName}</td>
> >>>             <td>${item.lastName}</td>
> >>>             <td>${item.phone}</td>
> >>>         </tr>
> >>>         </t:loop>
> >>>
> >>> 1 - i just want to use  item object here, for iteration, i don't want
> to
> >>> define it at my page class, can i ?
> >>>
> >>> 2  - i need an index var for each row, but it seems that for use index
> >>> attribute in loop component, i have to define a property at my page
> >> class
> >>> first, :((
> >>>
> >> ---------------------------------------------------------------------
> >> 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
>
>


-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

Re: T5 2 question about loop component parameters

Posted by Nick Westgate <ni...@key-planning.co.jp>.
I can see what you mean, though it is quite common to use the index inside
the page class too. T5 keeps things simple to cover the most common cases.

You can create your own components if you don't like the default ones.
It would be interesting to see an alternative if you write one.

Cheers,
Nick.


Mohammad Shamsi wrote:
> dear Nick,
> 
> i want index just for iteration, i don't need it in may page class, i think
> that its better to define in Loop component class,
> 
> suppose that i want to use Loop, 5 times in a singe page, then i most define
> 5 index value, and five item object ???
> 
> 
> 
> On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
>> The value and index have to go somewhere. Why not in your page class?
>>
>> Cheers,
>> Nick.
>>
>>
>> Mohammad Shamsi wrote:
>>> hi all,
>>>
>>> please take a look at my page bellow,
>>>
>>>         <!-- do i have to define item object in page class ?? i want to
>> use
>>> it just here in page ??? -->
>>>         <t:loop source="items" value="item" >
>>>
>>>         <tr>
>>>             <!-- i want to put an index here for each row in table -->
>>>             <td> ??? </td>
>>>             <td>${item.firstName}</td>
>>>             <td>${item.lastName}</td>
>>>             <td>${item.phone}</td>
>>>         </tr>
>>>         </t:loop>
>>>
>>> 1 - i just want to use  item object here, for iteration, i don't want to
>>> define it at my page class, can i ?
>>>
>>> 2  - i need an index var for each row, but it seems that for use index
>>> attribute in loop component, i have to define a property at my page
>> class
>>> first, :((
>>>
>> ---------------------------------------------------------------------
>> 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: T5 2 question about loop component parameters

Posted by Mohammad Shamsi <m....@gmail.com>.
dear Nick,

i want index just for iteration, i don't need it in may page class, i think
that its better to define in Loop component class,

suppose that i want to use Loop, 5 times in a singe page, then i most define
5 index value, and five item object ???



On 10/14/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
>
> The value and index have to go somewhere. Why not in your page class?
>
> Cheers,
> Nick.
>
>
> Mohammad Shamsi wrote:
> > hi all,
> >
> > please take a look at my page bellow,
> >
> >         <!-- do i have to define item object in page class ?? i want to
> use
> > it just here in page ??? -->
> >         <t:loop source="items" value="item" >
> >
> >         <tr>
> >             <!-- i want to put an index here for each row in table -->
> >             <td> ??? </td>
> >             <td>${item.firstName}</td>
> >             <td>${item.lastName}</td>
> >             <td>${item.phone}</td>
> >         </tr>
> >         </t:loop>
> >
> > 1 - i just want to use  item object here, for iteration, i don't want to
> > define it at my page class, can i ?
> >
> > 2  - i need an index var for each row, but it seems that for use index
> > attribute in loop component, i have to define a property at my page
> class
> > first, :((
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
sincerely yours
M. H. Shamsi

Re: T5 2 question about loop component parameters

Posted by Nick Westgate <ni...@key-planning.co.jp>.
The value and index have to go somewhere. Why not in your page class?

Cheers,
Nick.


Mohammad Shamsi wrote:
> hi all,
> 
> please take a look at my page bellow,
> 
>         <!-- do i have to define item object in page class ?? i want to use
> it just here in page ??? -->
>         <t:loop source="items" value="item" >
> 
>         <tr>
>             <!-- i want to put an index here for each row in table -->
>             <td> ??? </td>
>             <td>${item.firstName}</td>
>             <td>${item.lastName}</td>
>             <td>${item.phone}</td>
>         </tr>
>         </t:loop>
> 
> 1 - i just want to use  item object here, for iteration, i don't want to
> define it at my page class, can i ?
> 
> 2  - i need an index var for each row, but it seems that for use index
> attribute in loop component, i have to define a property at my page class
> first, :((
> 

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