Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3378

Struts dojo auto completer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 2.1.8
    • None
    • Plugin - Dojo Tags
    • None
    • windows mysql ie 7

    • Important

    Description

      based on a tutorial,i created an action called AutoCompleteCityAction and configured in struts.xml like
      .....Action.java
      package ajaxstruts;

      import java.util.List;
      import java.util.Map;
      import java.util.HashMap;

      import com.opensymphony.xwork2.ActionSupport;

      public class AutoCompleteCityAction extends ActionSupport {
      Map<String,String> json;
      String city;
      CitiesDAO dao;
      public Map<String, String> getJson ()

      { return json; }

      public void setJson (Map<String, String> json )

      { this.json = json; }

      public String getCity ()

      { return city; }

      public void setCity (String city )

      { this.city = city; }

      public AutoCompleteCityAction() {

      }

      public String execute()throws Exception

      { return SUCCESS; }

      public String getCities() {
      if(city != null && (!city.isEmpty())) {
      json = new HashMap<String,String>();
      dao = new CitiesDAO();
      List<City> list = dao.getCities(city);
      for(City city: list)

      { json.put(""+city.getCityId(),city.getCityName()+","+city.getStateName()); } } return SUCCESS; }

      }

      <package name="ajaxstruts"
      extends="json-default">

      <action name="autoComplete"
      class="ajaxstruts.AutoCompleteCityAction" >

      <result type="json">
      <param name="root">json</param>
      </result>

      </action>
      </package>
      then written as .jsp

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

      <html>
      <head>
      <sx:head />
      </head>
      <body>
      <div align="center">
      <s:label name="City" value="Choose City:" />
      <s:url id="cityList" action="autoComplete" method="getCities" />
      <sx:autocompleter name="city" href="

      {%cityList}

      "
      size="20" />

      </div>
      </body>
      </html>

      when i am running
      the text box is showing
      "message
      type
      number"
      but no auto completion [even after adding autoComplete="true" ]

      please look into

      Attachments

        Activity

          People

            iroughley Ian Roughley
            nandhamyr nandagopal
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: