You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by cahana <ca...@hawaii.edu> on 2001/07/07 22:39:43 UTC

indexed properties

Hi everyone-

    I need some help on using the indexed properties for html:text option. I've implemented Dave Hay's modification and can get the input boxes to show up using the iterate tag.

<logic:iterate id="course" name="CourseList" property="courseList">
 <tr>
            <td><%= courseNumber++ %></td>
     <td><html:text name="course" property="crstitle" size="25" maxlength="50" indexed="true"/></td>
     <td><html:text name="course" property="crsdept" size="6" maxlength="9" indexed="true"/></td>
     <td><html:text name="course" property="crsnum" size="5" maxlength="6" indexed="true"/></td>
     <td><html:text name="course" property="crshrs" size="5" maxlength="1" indexed="true"/></td>
 </tr>
 </logic:iterate>

This is what my CourseList bean looks like:

public final class CourseList extends ActionForm
{
  private ArrayList courseList = new ArrayList(6);
 
 public ArrayList getCourseList() {
  return(this.courseList);
 }

 public void setCourseList(ArrayList courseList) {
  this.courseList = courseList;
 }

 public CourseForm getCourseForm(int index) {
  return (CourseForm)courseList.get(index);
 }
 
 public void setCourseForm(int index, CourseForm course) {
  this.courseList.add(index, course);
 }
}

The problem i have is that when i try to submit the information and try to access CourseList.getCourseList(), it bombs and says CourseList cannot be found. The scope is request. I tried putting it in the session and can access it that way but it doesn't have the changes that were made on the form. Anybody know what i'm doing wrong?

thanks,
cameron

Re: indexed properties

Posted by cahana <ca...@hawaii.edu>.
Niall-

    Thanks i got the CourseList to work.

Cameron

----- Original Message -----
From: "Niall Pemberton" <ni...@btInternet.com>
To: <st...@jakarta.apache.org>
Sent: Saturday, July 07, 2001 11:10 AM
Subject: RE: indexed properties


> Cameron,
>
> Does the Action that is run when you submit the form have "CourseList"
> associated with it?
>
> If that sorts out the issue with not finding "CourseList" then I think
> "CourseList" should look like this:
>
> public final class CourseList extends ActionForm
> {
>   private ArrayList courseList = new ArrayList(6);
>
>  public ArrayList getCourseList() {
>   return(this.courseList);
>  }
>
>  public void setCourseList(ArrayList courseList) {
>   this.courseList = courseList;
>  }
>
>  public CourseForm getCourseList(int index) {
>   return (CourseForm)courseList.get(index);
>  }
>
> }
>
> Then in your "CourseForm" bean you need setters for all the properties
(i.e.
> crstitle, crsdept, crshrs, crsnum).
>
> Niall
>
>
>



Re: indexed properties

Posted by cahana <ca...@hawaii.edu>.
In my struts-config.xml, i have CourseList as the form associated with the
Action to submit.  I also put a <jsp:useBean> for CourseList in the jsp. But
it still doesn't work. I'll keep trying.

Do you know if there is a way to associate mulitple forms with a single
action in the struts-config.xml file i.e.
<action    path="/registration"
        type="DisplayRegistrationAction"
            name="registrationForm", "accountForm"
            scope="request"
            validate="false" >
      <forward name="success"         path="/acct_create.jsp"/>

    </action>

Cameron
----- Original Message -----
From: "Niall Pemberton" <ni...@btInternet.com>
To: <st...@jakarta.apache.org>
Sent: Saturday, July 07, 2001 11:10 AM
Subject: RE: indexed properties


> Cameron,
>
> Does the Action that is run when you submit the form have "CourseList"
> associated with it?
>
> If that sorts out the issue with not finding "CourseList" then I think
> "CourseList" should look like this:
>
> public final class CourseList extends ActionForm
> {
>   private ArrayList courseList = new ArrayList(6);
>
>  public ArrayList getCourseList() {
>   return(this.courseList);
>  }
>
>  public void setCourseList(ArrayList courseList) {
>   this.courseList = courseList;
>  }
>
>  public CourseForm getCourseList(int index) {
>   return (CourseForm)courseList.get(index);
>  }
>
> }
>
> Then in your "CourseForm" bean you need setters for all the properties
(i.e.
> crstitle, crsdept, crshrs, crsnum).
>
> Niall
>
>
>
> -----Original Message-----
> From: cahana [mailto:cahana@hawaii.edu]
> Sent: 07 July 2001 21:40
> To: struts-user@jakarta.apache.org
> Subject: indexed properties
>
>
> Hi everyone-
>
>     I need some help on using the indexed properties for html:text option.
> I've implemented Dave Hay's modification and can get the input boxes to
show
> up using the iterate tag.
>
> <logic:iterate id="course" name="CourseList" property="courseList">
>  <tr>
>             <td><%= courseNumber++ %></td>
>      <td><html:text name="course" property="crstitle" size="25"
> maxlength="50" indexed="true"/></td>
>      <td><html:text name="course" property="crsdept" size="6"
maxlength="9"
> indexed="true"/></td>
>      <td><html:text name="course" property="crsnum" size="5" maxlength="6"
> indexed="true"/></td>
>      <td><html:text name="course" property="crshrs" size="5" maxlength="1"
> indexed="true"/></td>
>  </tr>
>  </logic:iterate>
>
> This is what my CourseList bean looks like:
>
> public final class CourseList extends ActionForm
> {
>   private ArrayList courseList = new ArrayList(6);
>
>  public ArrayList getCourseList() {
>   return(this.courseList);
>  }
>
>  public void setCourseList(ArrayList courseList) {
>   this.courseList = courseList;
>  }
>
>  public CourseForm getCourseForm(int index) {
>   return (CourseForm)courseList.get(index);
>  }
>
>  public void setCourseForm(int index, CourseForm course) {
>   this.courseList.add(index, course);
>  }
> }
>
> The problem i have is that when i try to submit the information and try to
> access CourseList.getCourseList(), it bombs and says CourseList cannot be
> found. The scope is request. I tried putting it in the session and can
> access it that way but it doesn't have the changes that were made on the
> form. Anybody know what i'm doing wrong?
>
> thanks,
> cameron
>


RE: indexed properties

Posted by Niall Pemberton <ni...@btInternet.com>.
Cameron,

Does the Action that is run when you submit the form have "CourseList"
associated with it?

If that sorts out the issue with not finding "CourseList" then I think
"CourseList" should look like this:

public final class CourseList extends ActionForm
{
  private ArrayList courseList = new ArrayList(6);

 public ArrayList getCourseList() {
  return(this.courseList);
 }

 public void setCourseList(ArrayList courseList) {
  this.courseList = courseList;
 }

 public CourseForm getCourseList(int index) {
  return (CourseForm)courseList.get(index);
 }

}

Then in your "CourseForm" bean you need setters for all the properties (i.e.
crstitle, crsdept, crshrs, crsnum).

Niall



-----Original Message-----
From: cahana [mailto:cahana@hawaii.edu]
Sent: 07 July 2001 21:40
To: struts-user@jakarta.apache.org
Subject: indexed properties


Hi everyone-

    I need some help on using the indexed properties for html:text option.
I've implemented Dave Hay's modification and can get the input boxes to show
up using the iterate tag.

<logic:iterate id="course" name="CourseList" property="courseList">
 <tr>
            <td><%= courseNumber++ %></td>
     <td><html:text name="course" property="crstitle" size="25"
maxlength="50" indexed="true"/></td>
     <td><html:text name="course" property="crsdept" size="6" maxlength="9"
indexed="true"/></td>
     <td><html:text name="course" property="crsnum" size="5" maxlength="6"
indexed="true"/></td>
     <td><html:text name="course" property="crshrs" size="5" maxlength="1"
indexed="true"/></td>
 </tr>
 </logic:iterate>

This is what my CourseList bean looks like:

public final class CourseList extends ActionForm
{
  private ArrayList courseList = new ArrayList(6);

 public ArrayList getCourseList() {
  return(this.courseList);
 }

 public void setCourseList(ArrayList courseList) {
  this.courseList = courseList;
 }

 public CourseForm getCourseForm(int index) {
  return (CourseForm)courseList.get(index);
 }

 public void setCourseForm(int index, CourseForm course) {
  this.courseList.add(index, course);
 }
}

The problem i have is that when i try to submit the information and try to
access CourseList.getCourseList(), it bombs and says CourseList cannot be
found. The scope is request. I tried putting it in the session and can
access it that way but it doesn't have the changes that were made on the
form. Anybody know what i'm doing wrong?

thanks,
cameron