wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "jquery + struts2 => JSON autocompleter example?" Watch "jquery + struts2 => JSON autocompleter example?" New topic
Author

jquery + struts2 => JSON autocompleter example?

pooja par
Ranch Hand

Joined: Feb 14, 2011
Posts: 31

Hi,

I want to implement jquery autocompleter in my struts2 application.

I using the below link as reference.
http://code.google.com/p/struts2-jquery/wiki/AutocompleterTag

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"
})


myJSP

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<html>
<head>
<sj:head jqueryui="true"/>
</head>
<body>
<table>
<tr>
<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" />
</td>
</tr>
</table>
</body>
</html>


my Action.java

@ParentPackage("json")
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 {
if(StringUtils.isNotBlank(getManager())){
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;
}

}


struts.xml

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


Jars:
struts2-json-plugin-2.2.1.jar
struts2-jquery-plugin-2.5.3.jar


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: http://aspose.com/file-tools
 
subject: jquery + struts2 => JSON autocompleter example?
 
Similar Threads
struts2 jquery autocompleter
Autocompleter - NoSuchMethodException
I want to implement editable autocompleter in struts2 using jquery.
Autocompleter Struts2 not working for me:: Please help
Autocompleter