This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Select clause for listing cities for refined search  RSS feed

 
Darren Wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All. My requirement uses 2 objects. 1 for accounts and the other the descriptions for them. When my user has to select an account the current page has a select and option menu that gets the account details in an array to the list and pulls the descriptions with it (e.g. City). I need to filter the accounts by the city in this addition. In that a first select and option statement should list the cities (there can be duplicates so that has to be filtered out) and then once chosen all parent accounts and descriptions from child object belonging to that city area should be displayed to choose from another select option. The account number is then set in a servlet, redirecting them to them to the work area.

My logic doesnt seem to work. All i can get is the list of duplicated cities and this doesnt save just that city to then filter by, it stills shows the entire list of accounts belonging to the user. Can anyone assist please.

Thanks in advance.

Bean for session usage...



My Listing....



Ok to explain further. The user interacts via a list that displays account numbers to work with. In an example of 10 accounts there are many descriptions for them. In the standard select procedure a list (The Option list has the account and 3 of its descriptions, name, street and city) is shown and the users chooses one. However in the case of 900 accounts we want to narrow down this list. So we want to display a first option list by reading the descriptions associated to account by the city field that is returned and then in this way if a city has lets say 20 accounts in that city area then a new option list is populated with the accounts etc from that city area only.

I hope that makes more sense to what we are looking for.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step 1: Please UseCodeTags

Step 2: Remove all Java code from JSPs.

Step 3: Explain the interaction more clearly. It sounds like things have to change with user interaction, but it's not clear.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm nearly completely lost.

Why are some variables named with a capital letter and declared far from where they're used? Why is the selectedCity "if" statement body repeated twice when it's just a single difference between the two? Why is this code in a JSP at all? Why isn't JSTL being used? I'm still not clear on what the actual problem is, either.
 
Darren Wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:I'm nearly completely lost.

Why are some variables named with a capital letter and declared far from where they're used? Why is the selectedCity "if" statement body repeated twice when it's just a single difference between the two? Why is this code in a JSP at all? Why isn't JSTL being used? I'm still not clear on what the actual problem is, either.








Sorry. I have added the 2 objects in question and the JSP file that displays the lists. the first list shows all account details by getting the account number and then also showing its associated descriptions from AccountVO. I need the cities from AccountVO to be displayed (filtered without duplicates) allow a user to choose a city then display the account numbers that belong to that city area. Backwards basically as the AccountVO is the child for UserVO.

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Was the additional thousand lines supposed to make things easier to understand?!

Can you explain in a single sentence or two, without code, what is supposed to happen, and what is actually happening?
 
Darren Wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added it all so that it may make life easier to the experts to see it rather than a simple explanation that may be asked for further explanation. But thank you, the simple part is as i was saying a user logs in and currently sees accounts from UserVO that links to AccountVO to get their descriptions.

It combines the account and 3 descriptions into the list box/option menu. Now i have to have a drop down that shows the city descriptions that are retrieved by associated account numbers in UserVO. let them select one (NB: cities and AccountVO is the child of UserVO and account numbers, therefore there maybe more than 1 city so this needs to be filtered) then from that selection show a new list/drop down of the parent UserVO of account numbers belonging to that city.

i cant seem to get the duplicates out though i tried a treeset and .contains method.

Please help and thanks again.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darren Wayne wrote:i cant seem to get the duplicates out though i tried a treeset and .contains method.


I tried to edit the code so that it wasn't six screens wide, and so that somebody who wanted to go through it would
have a fighting chance of reading it. But it was way too much trouble, so I gave up. Sorry about that, anybody who
wanted to read the code.

However without reading any code, I can say this probably means you aren't implementing the compareTo() and the
equals() methods properly for whatever class you are trying to get rid of duplicates of.

So how about just posting the code relevant to that question? Perhaps in a new thread, as this one is way too wide
to be readable.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(I wondered why you had quoted the entire source ;)
 
Darren Wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:(I wondered why you had quoted the entire source ;)


Hi Guys. Sorry I will do that now.
 
Darren Wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darren Wayne wrote:
David Newton wrote:(I wondered why you had quoted the entire source ;)


Hi Guys. Sorry I will do that now.


Hi. I found a solution and have put it here http://www.coderanch.com/t/489348/JSP/java/Select-clause-listing-cities-refined#2200554

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternate post moved here to keep it all in a single topic:
Hi All. in response to a previous post of mine i have moved the topic here. And added the solution as well. I used a hashset to keep the 2 lots of data using unduplicated values listed my cities and then returned this option to a new page listing accounts in that city selected. Mind you it took a bit of help but not to bad in the end...



Using this selection in a new drop down of all details.



Thanks.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You really ought to consider the advice given earlier. Java scriptlets within a JSP have been a discredited practice for over 8 years now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!