• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Is there an elegant way to filtering?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there.

I'm using Struts and a bit of JSTL tags to show a couple of select with nested option tags. So i have the next in a form

<html:select property="idCadFed" styleClass="texto" onchange="habilitaColegios()">
<html ptions collection="ListaOrganismos" property="idAsString" labelProperty="desFederacion"/>
</html:select>


<html:select property="idCadCol" disabled="true" styleClass="texto">
<html ptions collection="ListaColegios" property="idAsString" labelProperty="desColegio"/>
</html:select>

Those are the drop-down lists. I get them filled as spected, the value i choose is passed to the action. So far, so good.

Now, what i need to do is to use the first comboBox as a filter, so after i choose a value, the values in the second combo are changed corresponding to what was selected (I need to filter them).

I'm thinking on solving the problem with javascript and some ugly iterations on the Collection to fill an Array in javaScript (maybe something else i still haven't figured out) and change the way i have the second combo filled, as the really convenient (with the <html:select & <html ptions tag) way won't be as easy to use.

But this seems way too ugly and dirty...Also, i don't want to do any reprocesing of the form, i think that would not be any good. i'm hoping there's another way i haven't found.

So, please, if you know an elegant way (well, in fact any way, even if it's not elegant at least it could be useful enough for me) let me know.

Thank you very much in advance, hope what i'm asking is clear, if it's not, reply so i can't explain better.

 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to use javascript.

There are threads all over this place with this same question.
 
Jos� Antonio Ram�rez
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Marc, i was trying to do it unnecessarily hard because i don't know much of javascript... now i know it can be done with javascript. I've done it and it works pretty well.

Thanks a lot.
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic