You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Tan CyberT@n" <qu...@gmail.com> on 2008/12/21 05:21:05 UTC

Loop object question.

hi all,

i'm newbie on java and tapestry ,i have problem on my loop 's data example

<t:loop source="prop:Datalist" value="prop:colvalue">
       <tr>
            <t:loop source="*(i wan to get the array of colvalue here )*"
value="prop:value">
                      <td>
                     ${value}
                        </td>
             </t:loop
        </tr>
</t:loop>

my Datalist is an ArrayList<String[]>  , my colvalue is String.
my data inside the datalist example like below:  ( total 4 lines of records)
["valueLine1-col1" ,"valueLine1-col2", "valueLine1-col3", "valueLine1-col4"]
["valueLine2-col1" ,"valueLine2-col2", "valueLine2-col3", "valueLine2-col4"]
["valueLine3-col1" ,"valueLine3-col2", "valueLine3-col3", "valueLine3-col4"]
["valueLine4-col1" ,"valueLine4-col2", "valueLine4-col3", "valueLine4-col4"]


so that , my table can generate 4 <tr>  and list out 4 <td> of the value in
each row.
may i know how to make it work?

Thank you
Regards,
Tan

Re: Loop object question.

Posted by "Tan CyberT@n" <qu...@gmail.com>.
hi shing,

thank you for your reply.
from your coding.

from my example of data like below:

["valueLine1-col1" ,"valueLine1-col2", "valueLine1-col3", "valueLine1-col4"]
["valueLine2-col1" ,"valueLine2-col2", "valueLine2-col3", "valueLine2-col4"]
["valueLine3-col1" ,"valueLine3-col2", "valueLine3-col3", "valueLine3-col4"]
["valueLine4-col1" ,"valueLine4-col2", "valueLine4-col3", "valueLine4-col4"]


i only able to get my output become :
let's take one example first row of record...

<td>  ["valueLine1-col1" ,"valueLine1-col2", "valueLine1-col3",
"valueLine1-col4"]  </td>

but what i want is

<td> "valueline1-col1" </td> <td> "valueline1-col2" </td> <td>
"valueline1-col3" </td> <td> "valueline1-col4" </td>

therefore,  i will like to have some kind like from a string to string[] and
let it become like
String[] value  = {"valueLine1-col1" ,"valueLine1-col2", "valueLine1-col3",
"valueLine1-col4"};

Thank you.

Regards,
Tan









On Sun, Dec 21, 2008 at 5:01 PM, Shing Hing Man <ma...@yahoo.com> wrote:

>
> Instead of having a loop within a loop, just have a loop and output <tr>
> and <td> manually.
>
> In .tml,
>  <table  border="0">
>
>           <t:loop  source="dataList" value="colValue" index="myIndex">
>
>            <t:if test="startRow">
>                   <t:outputraw value="startTR"/>
>           </t:if>
>           <td >
>                        ${value}
>           </td>
>
>           <t:if test="endRow">
>                   <t:outputraw value="endTR"/>
>           </t:if>
>        </t:loop>
>
> </table>
>
> In page java :
>
>
>     public boolean isStartRow(){
>                return (myIndex%4 ==0);
>        }
>
>        public boolean isEndRow(){
>                return (myIndex%4 ==3);
>        }
>
>        public String getStartTR(){
>                return "<tr>";
>        }
>
>        public String getEndTR(){
>                return "</tr>";
>        }
>
>
> Shing
>
>
>
>
>
>
>
>
> Home page : http://www.lombok.demon.co.uk/
>
>
>
> --- On Sun, 21/12/08, Tan CyberT@n <qu...@gmail.com> wrote:
>
> > From: Tan CyberT@n <qu...@gmail.com>
> > Subject: Loop object question.
> > To: "Tapestry users" <us...@tapestry.apache.org>
> > Cc: "Tan CyberT@n" <qu...@gmail.com>
> > Date: Sunday, 21 December, 2008, 12:21 PM
> > hi all,
> >
> > i'm newbie on java and tapestry ,i have problem on my
> > loop 's data example
> >
> > <t:loop source="prop:Datalist"
> > value="prop:colvalue">
> >        <tr>
> >             <t:loop source="*(i wan to get the
> > array of colvalue here )*"
> > value="prop:value">
> >                       <td>
> >                      ${value}
> >                         </td>
> >              </t:loop
> >         </tr>
> > </t:loop>
> >
> > my Datalist is an ArrayList<String[]>  , my colvalue
> > is String.
> > my data inside the datalist example like below:  ( total 4
> > lines of records)
> > ["valueLine1-col1" ,"valueLine1-col2",
> > "valueLine1-col3", "valueLine1-col4"]
> > ["valueLine2-col1" ,"valueLine2-col2",
> > "valueLine2-col3", "valueLine2-col4"]
> > ["valueLine3-col1" ,"valueLine3-col2",
> > "valueLine3-col3", "valueLine3-col4"]
> > ["valueLine4-col1" ,"valueLine4-col2",
> > "valueLine4-col3", "valueLine4-col4"]
> >
> >
> > so that , my table can generate 4 <tr>  and list out
> > 4 <td> of the value in
> > each row.
> > may i know how to make it work?
> >
> > Thank you
> > Regards,
> > Tan
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Loop object question.

Posted by Shing Hing Man <ma...@yahoo.com>.
Instead of having a loop within a loop, just have a loop and output <tr> and <td> manually.

In .tml,
  <table  border="0">
      
           <t:loop  source="dataList" value="colValue" index="myIndex">

            <t:if test="startRow">
                   <t:outputraw value="startTR"/>
           </t:if>
	   <td >		
			${value}
	   </td>
         
           <t:if test="endRow">
                   <t:outputraw value="endTR"/>
           </t:if>
	</t:loop>
	
</table>

In page java : 


     public boolean isStartRow(){
		return (myIndex%4 ==0);
	}
	
	public boolean isEndRow(){
		return (myIndex%4 ==3);
	}
	
	public String getStartTR(){
		return "<tr>";
	}
	
	public String getEndTR(){
		return "</tr>";
	}
	

Shing








Home page : http://www.lombok.demon.co.uk/



--- On Sun, 21/12/08, Tan CyberT@n <qu...@gmail.com> wrote:

> From: Tan CyberT@n <qu...@gmail.com>
> Subject: Loop object question.
> To: "Tapestry users" <us...@tapestry.apache.org>
> Cc: "Tan CyberT@n" <qu...@gmail.com>
> Date: Sunday, 21 December, 2008, 12:21 PM
> hi all,
> 
> i'm newbie on java and tapestry ,i have problem on my
> loop 's data example
> 
> <t:loop source="prop:Datalist"
> value="prop:colvalue">
>        <tr>
>             <t:loop source="*(i wan to get the
> array of colvalue here )*"
> value="prop:value">
>                       <td>
>                      ${value}
>                         </td>
>              </t:loop
>         </tr>
> </t:loop>
> 
> my Datalist is an ArrayList<String[]>  , my colvalue
> is String.
> my data inside the datalist example like below:  ( total 4
> lines of records)
> ["valueLine1-col1" ,"valueLine1-col2",
> "valueLine1-col3", "valueLine1-col4"]
> ["valueLine2-col1" ,"valueLine2-col2",
> "valueLine2-col3", "valueLine2-col4"]
> ["valueLine3-col1" ,"valueLine3-col2",
> "valueLine3-col3", "valueLine3-col4"]
> ["valueLine4-col1" ,"valueLine4-col2",
> "valueLine4-col3", "valueLine4-col4"]
> 
> 
> so that , my table can generate 4 <tr>  and list out
> 4 <td> of the value in
> each row.
> may i know how to make it work?
> 
> Thank you
> Regards,
> Tan


      

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