Kalyan Ayyagari wrote the following on 5/10/2005 12:16 PM:
Here is what I'm trying to do: I get the top level list from the backend. The list contains the other lists that I already described before. Apart from that it contains the information based on which I have to generate the UI. That is, my UI might look like this:
-------------------------------------------
GROUP-1: ITEM-11 . component111 . component112 . component113
ITEM-12 = component121 = component122 = component123
GROUP-2: ... ...
--------------------------------------------
The back-end might specify that I need to use radio buttons for components under ITEM-11 and use checkboxes for ITEM-12.
I can use the ids for value of radio buttons instead of trying to set a boolean as you said. But I'm not sure how I can do this.
But what is that you truly need when the user submits this form? Is it just the comonents they selected?
The cleanest solution would be if you could add an
Integer componentSelected property to the Item object.
Then on the form, it depends on how you are building it. I suggest for this using the nested tags... makes thigns clean (I use some JSTL here
using c:out but you can use bean or nested:write if you want).
<nested:form action="/wherever"> <nested:iterate id="group" property="groups"> <c:out value="${group.name}"/><br/> <nested:iterate id="item" property="items"> <c:out value="${item.name}"/><br/> <nested:iterate id="comp" property="components"> <nested:radio property="componentSelected/"> <%--in above '/' is important-goes up a leve to item--%> <c:out value="${comp.name}"/> </nested:iterate> </nested:iterate> </nested:iterate> <input type='submit'/> </nested:form>
When the form submits you'll then be able to pull out all the "Item" objects and look at the "componentSelected" property in each Item which will give you the component ID of the one selected in the Item';s group.
I didn't test the above so there might be a typo. I think the above is your cleanest solution.
There are other ways you can accomplish what you want but what makes it a bit tricky is the "radio" button concept set up in groups. You can avoid using the Item object to hold the componentSelected property if you instead decide to make your own separate object to hold it. In that case you could have...
MyObjectForHoldingSelected Integer componentID;
In form Bean...
List listOfMyObjects //holds list of MyObjectForHoldingSelecte objects
Then this section below would be replaced..
replace..
<nested:iterate id="comp" property="components"> <nested:radio property="componentSelected/"> <%--in above '/' is important-goes up a leve to item--%> <c:out value="${comp.name}"/> </nested:iterate>
with...
<nested:iterate id="comp" property="components" indexId="cIndex">
<nested:radio property="componentSelected/">
<html:checkbox property="listOfMyObjects[<c:out value='${cIndex}'/>].componentID"/>
<c:out value="${comp.name}"/>
</nested:iterate>
With the above though you'll have to use a LazyList or make you give the List and appropriate size to accomodate the number of items you'll need or you'll get indexOfOutOfBounds errors. THe first solution won't give you those problems.
-- Rick
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]