my dog learned polymorphism*
The moose likes Struts and the fly likes skip value in  logic: iterate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "skip value in  logic: iterate" Watch "skip value in  logic: iterate" New topic
Author

skip value in logic: iterate

Nimish Patel
Ranch Hand

Joined: Jun 29, 2005
Posts: 84
Hi,

I have two dropdown box(combo box) in one jsp.

In first combo box, I iterate one ArrayList comes from Action class.

In List , I set Property's name and ID.

Propertyname is displayed in combo box.

and propertyID is set in <option> tag's value attribute.

code for first combo box :-
--------------------------------------------------------------------------
<logic:iterate id="prop" name="lstprops">

<bean efine id="iptID" name="prop" property="PropertyID"/>

<option value='<%=String.valueOf(iptID)%>'><bean:write name="prop" property="name"/></option>

</logic:iterate>

----------------------------------------------------------------------
After select one propertyname in the first combo box, now I want to iterate same list in second combo box.

but In second combo box should not be contain "propertyname" which I have selected in first combo box.

How can I do that ?

can I use logic:equal tag ? but How ?

Please help me.

Thanks,
Nimish Patel
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The best way to handle this would be through JavaScript. Think about it: When the server is composing the page, you don't know which option the user is going to select for the first dropdown. The only option for using server-side code would be to submit the page as soon as the user selects an option from the first dropdown, populate the second dropdown without the option from the first dropdown, and redisplay the page.

The javascript solution would be something like this:

1. on the server-side, just populate both dropdown options exactly the same.
2. When the user selects an option from the first dropdown (using the onchange event) save the option selected in a variable, and then iterate through the options in the second dropdown and remove the one that matches the one selected in the first dropdown.
3. If the user changes the first dropdown again, in the second dropdown you will have to replace the option you removed in step 2, and then remove the newly selected option.


Merrill
Consultant, Sima Solutions
 
GeeCON Prague 2014
 
subject: skip value in logic: iterate