<logic:iterate> and <logic:radio> confusion

Hi Friends,
Right now,I iterate over an ArrayList that gets populated form the arrayForm class and produce 2 radio buttons.But I want to conditionalize it,so that if param=1,then only first radio button should show up.If param=2,second radio button should show up.I am passing the param value in the url.So rite now,I have this:

<logic:iterate id="arrayList" name="arrayForm" property="arrayList">
 <tr>
    <td>
         <html:radio idName="arrayList" property="array" value="value"/>
   </td>                                    
         <logic:equal parameter="param" value="1">                  
                <logic:equal name="arrayList" property="value" value="XYZ">
         </logic:equal>
   <td>
        <bean:write name="arrayList" property="label"/>
   </td>
   </logic:equal>
                        
   <logic:equal parameter="param" value="2">      
  <logic:equal name="arrayList" property="value" value="ABC">
  </logic:equal>
  <td>
  <bean:write name="arrayList" property="label"/>
   </td>
   </logic:equal>
                        
</tr>
</logic:iterate>


So,please tell me how to remove that <logic:iterator> tag because,if i remove it,then this starts causing problems:

<html:radio idName="arrayList" property="array" value="value"/>

And,for the <bean:write>  too,I want to show only one label at a time,like this works:

<bean:write name="arrayForm" property="arrayList[1].label"/>

is this correct???

Please help
harmeek_80Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fargoCommented:
the way you are using logic:equal is not correct. Two logic equal tags should be nested..but in your case it is not.

Solution:
// just define a bean with label as XYZ (default)
<bean:define id="label" value="XYZ" />                

// now do the parameter handling
<logic:equal parameter="param" value="1">
        <bean:define id="label" value="XYZ" />                
</logic:equal>

<logic:equal parameter="param" value="2">
        <bean:define id="label" value="ABC" />                
</logic:equal>

then just use
<td>
         <html:radio idName="arrayList" property="array" value="value"/>
   </td>                              
   <td>
        <bean:write name="label"/>
   </td>
harmeek_80Author Commented:
Thanks fargo,
But the problem is that solution I jus cannot define any label in the bean write,the names are stored in a labelvaluebean object stored inside the arraylist,so how to do that...pls help.

 
fargoCommented:
may be u need something like this (i couldn't understand much from your last post)
 
<logic:iterate id="arrayList" name="arrayForm" property="arrayList">
 <tr>
    <td>
         <html:radio idName="arrayList" property="array" value="value"/>
   </td>                              
         <logic:equal parameter="param" value="1">              
                <logic:equal name="arrayList" property="value" value="XYZ">
                  <td>
                       <bean:write name="arrayList" property="label"/>
                  </td>
              </logic:equal>
         </logic:equal>
                   
       <logic:equal parameter="param" value="2">    
              <logic:equal name="arrayList" property="value" value="ABC">
              <td>
                    <bean:write name="arrayList" property="label"/>
              </td>
             </logic:equal>
     </logic:equal>
</tr>
</logic:iterate>
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

harmeek_80Author Commented:
Thats the exact same thing,I am doing.But my question is ,thatproduces 2 radio buttons,so how can i remove that iteration logic ,so that it produces only one radio button at a time depending upon the conditions i inpu..thanks
harmeek_80Author Commented:
I got that solved fargo,can u please answer this one:

Hi Friends,
I read in a parameter in struts like this:

<logic:equal parameter="param" value="1">      



But,how to access this "param" inside the block,like i want to do this:

<logic:equal name="addForm" property="arrayList[param].value" value="XYZ">



instead of doin this,that i have right now,

<logic:equal name="addForm" property="arrayList[1].value" value="XYZ">



Any help would be appreciated.Thanks in Advance.
fargoCommented:
this link is exactly what u need.
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=004311

moreover try to do the parameter handling or set for the LabelValueBean in the action class in action form.
read the second section of the posted link and u are all set.
harmeek_80Author Commented:
Hi fargo,
Let me increase the points first..I have gone thru that link.But I need this exactly:

I have an arraylist that i populate using labelvaluebean objects and pass it to my jsp.In my jsp i access it as:

 <logic:equal name="addForm" property="arrayList[0].value" value="XYZ">

 But I don't want to hardcore the index variable,so how can I put the value using a variable,something like this:

 <% int s = 0; %>
 <logic:equal name="addForm" property="arrayList[<%=s%>].value" value="XYZ">

 When i try that, its throwing exceptions,please help.

 Even this is not working:
 <bean:define id="param" value="0"/>
 <logic:equal name="addForm" property="arrayList[<bean:write name="param" />].value" value="XYZ">

Please help.
fargoCommented:
have u tried this
 <logic:equal name="addForm" property="<%= ((LabelValueBean)arrayList.get(0)).getValue()%>" value="XYZ">
if u directly want the value on the label or something, u need to implement that method in the bean and use it straightforward as above without using index (this will make u get rid of iteration)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.