It's not a secret anymore!
The moose likes Struts and the fly likes jquery + struts2 => JSON autocompleter example? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "jquery + struts2 => JSON autocompleter example?" Watch "jquery + struts2 => JSON autocompleter example?" New topic

jquery + struts2 => JSON autocompleter example?

pooja par
Ranch Hand

Joined: Feb 14, 2011
Posts: 31


I want to implement jquery autocompleter in my struts2 application.

I using the below link as reference.

I'm getting compilation errors when I add below annotations in my action class

@ParentPackage(value = "showcase")
@Action(value = "/jsonlanguages", results = {
@Result(type = "json", name = "success", params = {
"root", "languages"


<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<sj:head jqueryui="true"/>
<td align="left"><s:label value= "Manager*:" cssStyle="font-weight:bold;"/></td>
<td align="left">
<s:url id="managerslist" action="ManagersAutoCompleter" />
<sj:autocompleter name="manager" id="managers" href="%{managerslist}" loadMinimumCount="2" />


public class ManagersAutoCompleter extends ActionSupport {

private static final long serialVersionUID = 1L;

private Map<String,String> managerMap = new HashMap<String,String>();
private String manager;

@Action(value = "/ManagersAutoCompleter",
results = {@Result(type = "json", params = {"root", "managers"})}
public String getManagers() throws Exception {
managerMap = ValidationManagerDAOImpl.getInstance().getManagers(getManager());
} else{
managerMap = new HashMap<String,String>();

return Action.SUCCESS;

public Map<String, String> getManagerMap() {
return managerMap;

public void setManagerMap(Map<String, String> managerMap) {
this.managerMap = managerMap;

public String getManager() {
return manager;

public void setManager(String manager) {
this.manager = manager;



<package name="json" namespace="/" extends="json-default">
<result-type name="json" class="com.googlecode.jsonplugin.JSONResult"/>
<action name="ManagersAutoCompleter" method = "getManagers" class="">
<result type="json"><param name="root">managerMap</param></result>


Can anyone please help me with this..
I couldn't find complete source code for this example.

Please suggest me what else I need to add or it would be great if anyone can provide me complete souce code for this example
pooja par
Ranch Hand

Joined: Feb 14, 2011
Posts: 31
Please refer to "struts2 jquery autocompleter"
I agree. Here's the link:
subject: jquery + struts2 => JSON autocompleter example?
It's not a secret anymore!