Gavis
Gavis

Reputation: 117

How to achieve autocomplete dropdown using struts2-dojo-plugin

I want to implement autocomplete dropdown using <sx:autocompleter> in struts2.

The following are the use jar's

struts2-core-2.2.1.1.jar
struts2-dojo-plugin-2.1.8.1.jar
struts2-json-plugin-2.2.1.jar

The ajaxAutocomplete.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<s:form action="ajaxAutoCompleteActionForm" id="ajaxAutocompleteActionForm">
<H1> Bulk Action Form </h1>
<sx:autocompleter size="1" list="countries" name="country"></sx:autocompleter>
</s:form>

After deploying the above code simply shows a normal dropdown with list of countries. There is no <input> field to enter the text. I want to achieve the same behaviour as shown in the following link

http://viralpatel.net/blogs/struts-2-ajax-tutorial-example-d

Also in my console I am getting the following error

"Uncaught ReferenceError: djConfig is not defined"

What I am doing wrong? How to avoid the console error?

How to get the dropdown with text box to search select option value?

Upvotes: 0

Views: 2000

Answers (1)

prem30488
prem30488

Reputation: 2856

You forgot to add head in ajaxAutocomplete.jsp

<head>
 <sx:head/>
</head>

put this before your form tag.

Upvotes: 3

Related Questions