Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 autocompleter

 
Salvatore De Giorgi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a problem with an autocomplete field. Unfortunately, I'm starting to use struts right now, but I have to complete this task in a couple of days.
I have a web application based on struts2, with a graphic template based on the bootstrap. For the persistence, the web application uses a mysql database that is accessed through hibernate.
The autocomplete field is a struts tag called sj:autocompleter. The problem is that I am absolutely unable to get it to work! The field should show, as options, a set of strings extracted from the database. How do I launch an action when typing in the field to view the strings extracted from the db? The online examples only talk about json and I am not able to adapt them to my needs. What I have written so far is:

At the moment, the Login action is only a "test action" so it does not return anything, but I don't receive any error message..absolutely nothing happens when I type in the field...no error, no message, nothing...simply, the action is not called.
How can I solve the problem? what should be the action implementation?

Thanks in advance!

P.S. I have correctly imported the struts2 jquery plugin.
 
Salvatore De Giorgi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no one can help me?
I don't know if the question is too complex, unclear or little detailed.
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be patient. We are all volunteers here, helping people in our spare time.
I am not well-versed in the jQuery plugin, but if you want to use AJAX to load the selections, I think you will have to use JSON. There is no way to return a Java object like a String array via HTTP without transforming it into plain text.
If you don't require AJAX, this example shows how to use the tag with a plain String array.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic