Never mind -- I fixed it with the following:

<ul>

<c:forEach var="groups" items="${wizardForm.groups}">

        <li>

                <c:out value="${groups.groupName}"/>

                <c:out value="${groups.checkMarked}"/>

        </li>

</c:forEach>

</ul>


-----Original Message-----
From: Simonin, Bradley K. (Brad)
Sent: Fri 11/11/2005 10:38 AM
To: Struts Users Mailing List
Subject: RE: I want to create a List of items and then allow the user to choose 
several items from the List.
 
Okay.  Let me show you what I have real quick.  In my ValidatorForm  I have a 
instance variables and a method:

private List groups = null;
private GroupBean groupBean = null;

public void setGroups() {
     this.groups = new LinkedList();
     this.groupBean = new GroupBean("Cats", false);
     groups.add(groupBean);
     this.groupBean = new GroupBean("Dogs", false);
     groups.add(groupBean);
     this.groupBean = new GroupBean("Birds", false);
     groups.add(groupBean);     
}


external to the ValidatorForm but in the same package I have the following:

public class GroupBean {
    private String groupName = "";
    private boolean checkMarked =false;
    
    public GroupBean() {
        this.groupName = "";
        this.checkMarked = false;
    }
    
    public GroupBean(String groupName, boolean checkMarked) {
        setGroupName(groupName);
        setCheckMark(checkMarked);
    }
    
    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
    
    public String getGroupName() {
        return groupName;
    }
     
    public void setCheckMark(boolean checkMarked) {
        this.checkMarked = checkMarked;
    }
    
    public boolean getCheckMark () {
        return checkMarked;
    }
  
}


How can I use the <c:forEach....> to traverse the List and put the GroupBean 
object in a multibox?  

Thanks in advance,

--Brad.

p.s. Sorry for the trivial question....I have a cold and I am not thinking 
straight.



-----Original Message-----
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Fri 11/11/2005 9:32 AM
To: Struts Users Mailing List
Subject: Re: I want to create a List of items and then allow the user to choose 
several items from the List.
 
On 11/10/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> Would I create a bean that is just a collection and then populate that 
> collection with the List I want the user to choose from?  How would I put the 
> list in the jsp?

... and a multibox example, in case you want checkboxes rather than a
select list:

   <c:forEach items="${accountMap}" var="item" >
       <html-el:multibox property="accounts" value="${item.key}"/>
       <c:out value="${item.key}"/> <br/>
    </c:forEach>

(This uses a Map rather than a List, but you get the idea.)

--
Wendy
http://wiki.wsmoak.net/cgi-bin/wiki.pl?StrutsMultiBox

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






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

Reply via email to