Hi, 

Thanks for the pointer - although Im not sure this is a case for those tags
(at least I cant work out how to solve my problem using them!)

My issue is that I don’t know how many multibox sets I will need on my form
(i.e. it has to have a dynamic number of multiboxes, each with a dynamic
number of name/value pairs).

At present my Action form subclass uses:

    private java.util.ArrayList attributeValues = new java.util.ArrayList();
    private java.util.ArrayList attributeStatus = new java.util.ArrayList();

to store the possible values and 'check status'. The ArrayLists each hold
LabelValueBean[] and String[] respectively.

This allows me to display a variable number of multiboxes as follows:


<html-el:form action="/AdminEditProductAttributes">

  <c:forEach items="${modifyAttributesForm.attributeNames}" var="heading"
varStatus="i">

    <c:forEach items="${modifyAttributesForm.attributeValues[i.index]}"
var="valuePairs" varStatus="j">
       <html-el:multibox property="attributeStatus[${i.index}]">
                ${valuePairs.value}
         </html-el:multibox>
       ${valuePairs.label}
    </c:forEach>

  </c:forEach>
  <html-el:submit value="Update Attributes" />
</html-el:form>

This generates html:

<form name="modifyAttributesForm" method="post"
action="/store-modules/admin/AdminEditProductAttributes.do">
    <h3>Size</h3><br>
    <input type="checkbox" name="attributeStatus[0]" value="0">S
    <input type="checkbox" name="attributeStatus[0]" value="1">M
    <input type="checkbox" name="attributeStatus[0]" value="2">L
                
    <h3>Colour</h3><br>
    <input type="checkbox" name="attributeStatus[1]" value="0">Black
    <input type="checkbox" name="attributeStatus[1]" value="1">White
    <br><br><input type="submit" value="Update Attributes">
</form>

So the display works fine - I just cant work out what setters in need in my
form subsclass. The best I can get is a single value for each multibox being
passed using:

    public void setAttributeStatus(int i, Object in){
       this.attributeStatus.set(i,in);
    }

Any ideas?

TIA

 

-----Original Message-----
From: Hubert Rabago [mailto:[EMAIL PROTECTED] 
Sent: 18 February 2004 20:10
To: Struts Users Mailing List
Subject: Re: N by N multiboxes !!!

Study the tutorials at www.keyboardmonkey.com for using the <nested> Struts
tags.

--- Lawrence Williams <[EMAIL PROTECTED]> wrote:
>  
> Hi,
> 
> I am trying to generate a form allowing attributes in a catalog to be 
> set on or off for particular products.
> 
> So depending on the state of the Database there will be N Attributes 
> each with M slectable values (as attributes are added and new styles 
> become available N and M will vary:
> 
> E.g. 
> 
> Color (red,blue.. N .., green)
> Size  (s,m,l,xl)
> .
> .
> N
> .
> .
> Weight (1,2,3)
> 
> 
> I want a jsp form to display all options for all defined attributes. I 
> currently have a form:
> 
>         <form-bean 
>             name="modifyAttributesForm"
>             type="myproj.product.AttributeForm">
>             <form-property name="attributeNames"
> type="java.lang.String[]"/>
>             <form-property name="attributeValues"
> type="java.lang.Object[]"/>
>         </form-bean>
> 
> Where each attributeValues object array entry has in it a 
> LabelValueBean[] array storing the values for each attribute.
> 
> At present ive got the form of checkboxes rendering using standard 
> html <input type=checkbox... Tags.
> 
> <c:forEach items="${modifyAttributesForm.attributeNames}" var="heading"
> varStatus="i">
> <c:forEach items="${modifyAttributesForm.attributeValues[i.index]}"
> var="valuePairs" varStatus="j">
>       <INPUT name="${heading}" type="checkbox"
> value="${valuePairs.value}">${valuePairs.label}<br>
> 
> </c:forEach>
> </c:forEach>
> 
> I of course now want to use the struts multibox tag to handle all the 
> repopulation for me. However, it seems to me the multibox control is 
> only going to work for a single String[] array of populated values, I 
> need a 2 dimensional structure.
> 
> I cant see how I can do this - perhaps I have hit a common pattern here -
?
> Any Ideas?
> 
> Lawrence
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.590 / Virus Database: 373 - Release Date: 16/02/2004
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools

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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.590 / Virus Database: 373 - Release Date: 16/02/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.592 / Virus Database: 375 - Release Date: 18/02/2004
 


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

Reply via email to