Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Struts Struts2 Struts2uitags Struts 2 Autocompleter,Struts 2 Autocomplete

Related Tutorials


Share on Google+Share on Google+

Struts 2 Autocompleter,Struts 2 Autocomplete

In this tutorial you will learn about struts auto complete
<action name="autocompleter" class="net.roseindia.autocompleter">

Create a list in the action class  and populate them with various states name of U.S. as shown in the  "autocompleter" class.

package net.roseindia;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;

public class autocompleter extends ActionSupport{
  private List state;
  public String execute() throws Exception{
  state = new ArrayList();
  state.add("District of Columbia");
  state.add("New Hampshire");  
  state.add("New Jersey");
  state.add("New Mexico");
  state.add("New York");  
  state.add("North Carolina");
  state.add("North Dakota");  
  state.add("Rhode Island");  
  state.add("South Carolina");  
  state.add("South Dakota");
  state.add("West Virginia");
  return SUCCESS;
  public List getState(){
  return state;

<s:autocompleter theme="simple" list="state" StateName/> it creates a autocompleter list with the name of U.S. sates.


<%taglib prefix="s" uri="/struts-tags" %>

  <title>Struts Autocompleter Example!</title>
  <s:head theme="ajax" />
  <h1>Struts Autocompleter Example!</h1>
  <s:label name="stateName" value="Select State Name:" />
  <s:autocompleter theme="simple" list="state" name="StateName"/>

Output of the autocompleter.jsp :

When you enter the 'c' letter in the textbox. You gets the following:


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 18, 2011

Related Tutorials

Discuss: Struts 2 Autocompleter,Struts 2 Autocomplete  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image