Hi,

Please find below an extract of the code I use:

public class SearchTermAutoCompleteAction extends BaseActionWithSession  {

   private String searchableTag;

   public String getSearchableTag() {
      return searchableTag;
   }

   public void setSearchableTag(String searchableTag) {
      this.searchableTag = searchableTag;
   }

   private String q;      // JQuery Autocomplete query parameter

   private List<String> listSuggestions;

   private InputStream inputStream;

   public InputStream getInputStream() {
    return inputStream;
   }
..

public String doSuggest() {
...
...
 listSuggestions = new ArrayList<String>();
      StringBuffer sb = new StringBuffer();
      for (DictionaryTerm term : v) {
         listSuggestions.add(term.getText());
         sb.append(term.getField() + "[" + term.getFreq() + "]\t" +
term.getText() + "\n");

      }
      System.out.println(sb.toString());
      try {
         inputStream = new
ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
      } catch (UnsupportedEncodingException ex) {
         ex.printStackTrace();
      }


      return SUCCESS;

   }
As you can see it renders one line per item in the list. The autocomplete
plugins parses this list,
taking each line as a row and each field (delimited by pipes) as a property.

Hope it helps,
Best,
JCD

On Thu, Apr 22, 2010 at 11:42 PM, sharath karnati <karna...@yahoo.com>wrote:

> Hi All,
>
>   Say I have java "arraylist" in action and how to set this in resonse
> object
>
>   ServletActionContext.setResponse()
>
>   How to do this in struts2??
>
> Thanks,
> Sharath.
>
> --- On Thu, 4/22/10, sharath karnati <karna...@yahoo.com> wrote:
>
>
> From: sharath karnati <karna...@yahoo.com>
> Subject: Re: Jquery autocomplete with struts2.
> To: "Struts Users Mailing List" <user@struts.apache.org>
> Date: Thursday, April 22, 2010, 3:36 PM
>
>
> Please find below example
>
> http://makhaer.blogspot.com/2008/12/jquery-autocomplete.html
>
> in this example, he is just using jquery with textfield for doing
> autocomplete with PHP. I'd like to do samething with struts2 action.
>
> Can anyone please let me know, how to send data from action to .jsp to
> display autocomplete rather than using another plug-ins.
>
> Thanks,
> Sharath.
>
> --- On Thu, 4/22/10, Johannes Geppert <jo...@web.de> wrote:
>
>
> From: Johannes Geppert <jo...@web.de>
> Subject: Re: Jquery autocomplete with struts2.
> To: user@struts.apache.org
> Date: Thursday, April 22, 2010, 2:29 PM
>
>
>
> Hello,
>
> since version 2.0.0 the Struts2 jQuery Plugin have a autocompleter tag.
> This is an easy way to implement an Autocompleter.
>
> See:
> http://code.google.com/p/struts2-jquery/wiki/AutocompleterTag
>
> Best Regards
>
> Johannes Geppert
>
>
> sharath wrote:
> >
> > Hi All,
> >
> >    I'm trying to use Jquery autocomplete with struts2. The example for
> > using Jquery autocomplete is given below(link)
> >
> >        http://makhaer.blogspot.com/2008/12/jquery-autocomplete.html
> >
> >    In this example, author is returning data with .php similarly I'd like
> > to return data from struts2 action(not with json object)
> >
> >    Can anyone please let me know how to return data from struts2 action
> > for accomplishing same thing.
> >
> >    Thanks in advance.
> >
> > Regards,
> > Sharath.
> >
>
>
> -----
> ---
> web: http://www.jgeppert.com
> twitter: http://twitter.com/jogep
>
> --
> View this message in context:
> http://old.nabble.com/Jquery-autocomplete-with-struts2.-tp28329744p28332899.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
>
>
>

Reply via email to