Niall Pemberton <niall.pemberton <at> blueyonder.co.uk> writes:

> 
> Why not just try it and see if it works - should do - have and iterate tag
> embedded in another iterate tag
> 
> 
> ----- Original Message ----- 
> From: "LILES, DAVID (CONTRACTOR)" <DAVID.LILES <at> DFAS.MIL>
> To: <struts-user <at> jakarta.apache.org>
> Sent: Friday, February 13, 2004 5:29 PM
> Subject: array iteration
> 
> 
> I am trying to iterate through a two dimensional array and have hit a
> wall.... below is source code from a class that displays the values in a
> calendar style format. How can I do the same thing by using the Struts
> iterate tags?
> 
> public String formatMatrix(int[][] aMatrix) {
>     StringBuffer sb = new StringBuffer();
> 
>         for (int i = 0; i < aMatrix.length; i++) {
>             for (int j = 0; j < aMatrix[i].length; j++) {
>             if (aMatrix[i][j] > 0) {
>                 sb.append(aMatrix[i][j] < 10 ? " " + aMatrix[i][j] :
> String.valueOf(aMatrix[i][j]));
> sb.append(" ");
>             }
>             else {
>             sb.append("   ");
>             }
>             }
> sb.append("\n");
>         }
>         return sb.toString();
>     }
> 
> This is how I'm trying to display the contents....
> 
> 1  2   3  4  5  6  7
> 8  9  10 11 12 17 18
> 19 20 21 22 23 24 25
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe <at> jakarta.apache.org
> For additional commands, e-mail: struts-user-help <at> jakarta.apache.org
> 
wouldn't be simpler to have a calendar bean do the processing and 
use struts to dispaly the calendar bean properties.

Class MonthlyCalender {

private Date dte
private java.util.List days = new ArrayList(42);
private int lastDay;   // 31, 30, 29 or 28
private int strtPos;   // 1 - 7 : day of week for the 1st of the month ** 
public void setDate(String d) {this.dte = new Date(d);  fillDays() }
public Date getDate(return dte.toString()) ;

private void fillDays() {
int counter=1;
   for (int d =0; d < 42; d++) {
      if (d < strtPos -1) 
           days.add("");   // nice would be count back from lstday of lastmon
      else
           days.add(counter++);
   }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to