On Friday 13 August 2004 09:40, Jim Barrows wrote:
> > -----Original Message-----
> > From: Mike Elliott [mailto:[EMAIL PROTECTED]
> > Sent: Friday, August 13, 2004 9:33 AM
> > To: [EMAIL PROTECTED]
> > Subject: Read only iterate?
> >
> >
> > I've been totally defeated in my attempt to alter an html:text
> > element inside a logic:iterate tag.  There must be a way to
> > accomplish this, but I've been beating my head against the wall
> > for three days now without making progress.
> >
> > I have simplified the problem substantially from the initial page.
> > What I have now looks like this:
>
> from
> http://struts.apache.org/userGuide/struts-html.html#text
> I'm guessing that a List won't work and you need to have an array.

No -- changing it to a list makes no difference whatsoever:

package problem;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;

import java.util.ArrayList;
import java.util.List;

public class ProblemBean extends ActionForm {

   final private static int ENTRY_ROW_COUNT = 2;

   public ProblemBean() {
      log.info( "initializing entries" );
      entries = new ArrayList();

      // Create some entries for the form
      for (int ndx = 0 ; ndx < ENTRY_ROW_COUNT; ndx ++) {
         ProblemItem a = new ProblemItem();
         a.setInteger_value( new Integer(ndx));

      entries.add( a );
      }
   }

   private String working_perfectly = "A Value";

   public String getWorking_perfectly() {
      log.info( "getWorking_perfectly" );
      return working_perfectly;
   }

   public void setWorking_perfectly( String working_perfectly ) {
      log.info( "setWorking_perfectly to '" + working_perfectly + "'");
      this.working_perfectly = working_perfectly;
   }

   private List entries;

   public ProblemItem[] getEntries() {
      log.info( "getEntries" );
      ProblemItem[] result = new ProblemItem[entries.size()];
      for (int ndx = 0; ndx < entries.size(); ndx++)
         result[ndx] = (ProblemItem)entries.get( ndx );
      return result;
   }

   public void setEntries( List entries ) {
      log.info( "setEntries" );
      this.entries = entries;
   }

   public static class ProblemItem extends ActionForm {

      // Used so that each item can have a unique value.
      private static Integer incrementing = new Integer( 0 );

      public ProblemItem() {
         this.integer_value = incrementing;
         incrementing = new Integer( incrementing.intValue() + 1 );
      }

      private Integer integer_value;

      public Integer getInteger_value() {
         log.info( "getInteger_value" );
         return integer_value;
      }

      public void setInteger_value( Integer iValue ) {
         log.info( "setInteger_value to " + iValue );
         this.integer_value = iValue;
      }

      private static Logger log = Logger.getLogger( ProblemItem.class );
   }

   private static Logger log = Logger.getLogger( ProblemBean.class );
}


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

Reply via email to