You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Guilherme <ja...@gmail.com> on 2007/04/29 01:37:08 UTC

Help with autocomplete tag

Hi,

I'm using autocomplete tag but it don't work very well. These is my
configurations:

struts.xml

    <package name="example"  extends="json-default">
         <action name="JSONExample" class="action.JSONAction">
            <result name="success" type="json">json.jsp</result>
         </action>
  </package>

action:

public class JSONAction {

     private Map map = new HashMap();

     public String execute() {
        map.put("name", "mário");
        map.put("name", "pedro");
        map.put("name", "carlos");
        return Action.SUCCESS;
     }

     public Map getMap() {
         return map;
     }
     public void setMap(Map map) {
         this.map = map;
     }

}

JSP:

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

<s:head theme="ajax" />

<s:url id="json" value="JSONExample.do" />

<s:autocompleter theme="simple" href="%{json}" autoComplete="true" />

When i run JSP page in firefox, this message is displayed:

Erro: TypeError: this.data[x][0].toLowerCase is not a function
Arquivo-fonte: http://localhost:8080/oficina/struts/dojo/dojo.js
Linha: 94

Somebody can help me to solve this problem ?

Thanks!

-- 
Att
Guilherme Mello do Nascimento
PortalJava.com - A maior comunidade Java do Brasil

Re: Help with autocomplete tag

Posted by Musachy Barroso <mu...@gmail.com>.
The json that is being generated is not "understood" by the autocompleter,
which it is generating is something like:

{
   "map" : {
      "name": "mario"
  }
}

in 2.6 the autocompleter doesn't accept a map  as the datasource. You need
to generate something like:

{
   "map" : [
     ["name", "mario"]
  ]
}

and set the autocompleter's name attribute to "map" (name="map"), or output:

[
   ["name", "mario"]
]

Please check the docs also:

http://struts.apache.org/2.x/docs/ajax-tags.html

musachy

On 4/28/07, Guilherme <ja...@gmail.com> wrote:
>
> Hi,
>
> I'm using autocomplete tag but it don't work very well. These is my
> configurations:
>
> struts.xml
>
>     <package name="example"  extends="json-default">
>          <action name="JSONExample" class="action.JSONAction">
>             <result name="success" type="json">json.jsp</result>
>          </action>
>   </package>
>
> action:
>
> public class JSONAction {
>
>      private Map map = new HashMap();
>
>      public String execute() {
>         map.put("name", "mário");
>         map.put("name", "pedro");
>         map.put("name", "carlos");
>         return Action.SUCCESS;
>      }
>
>      public Map getMap() {
>          return map;
>      }
>      public void setMap(Map map) {
>          this.map = map;
>      }
>
> }
>
> JSP:
>
> <%@ taglib prefix="s" uri="struts-tags" %>
>
> <s:head theme="ajax" />
>
> <s:url id="json" value="JSONExample.do" />
>
> <s:autocompleter theme="simple" href="%{json}" autoComplete="true" />
>
> When i run JSP page in firefox, this message is displayed:
>
> Erro: TypeError: this.data[x][0].toLowerCase is not a function
> Arquivo-fonte: http://localhost:8080/oficina/struts/dojo/dojo.js
> Linha: 94
>
> Somebody can help me to solve this problem ?
>
> Thanks!
>
> --
> Att
> Guilherme Mello do Nascimento
> PortalJava.com - A maior comunidade Java do Brasil
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd