This week's book giveaway is in the Spring forum.
We're giving away four copies of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 and have Marten Deinum & Iuliana Cosmina on-line!
See this thread for details.
Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • 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
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Struts 2 - jquery plugin - autocompleter

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

I have following problem:

I want to use the autocompleter of the jquery-plugin for Struts 2. I got so far to insert a list of JPA-Entitys in the autocompleter-Input Field. Each Entity represents a City, with name and a City-ID. In the JSP I created the input field via



It creates an input field where it shows the names of the cities. Now I want to open an url on selecting a city, and the link has to have the parameter "cityId=" + the number, e.g. "cityId=112". But it doesn't work! In firebug I can see that jquery creates an hidden input field with the id "selectCity", a hidden select-field (CSS-Class "selectCity_widget") with all the cities in the list "cities" and as the option-values the correct cityIDs and another hidden input field with the CSS-ID ".ui-autocomplete-input".

The HTML in firebug looks like



When selecting an entry from the autocompleter it correctly inserts the cityID in the first hidden input field "#selectCity" as a value, e.g.



I tried it with



But firebug tells me that "ui.item.value" contains the City-Name and not the ID. I have no idea why! How do I get the City-ID for the autocompleteselect-Event? :-(
 
Sascha Kleiber
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found a solution. I used the Tag



and wrote following JavaScript to react on the select-Event:

 
Sascha Kleiber
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know if it is possible to get only results BEGINNING with a given letter, not just CONTAINING it? For example if I enter "a" I only want to get results beginning with "a", e.g. "ape", "alien" etc., but not e.g. "banana". I DON'T want to get EVERY word containing the letter 'a'!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic