Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 790261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:39:17+00:00 2026-05-14T21:39:17+00:00

I used the jQuery autocompletion for my Struts2 application. Pratically, my action made a

  • 0

I used the jQuery autocompletion for my Struts2 application.

Pratically, my action made a list of strings that jQuery use. This is the script:

$().ready(function() {
        $("#tag").autocomplete("/myAction/Action", {
            multiple : true,
                autoFill : true,
                    minChars:1
                });
            });

During typing appear the box with the suggestions. The problem is that the box render another value,
exactly render the code of my JSP ( links to CSS for the autocomplete plug-in).

How can I solve this?

This is my JSP:

<html>
<head>
    <script src="<%=request.getContextPath()%>/scripts/jquery-latest.js"></script>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/main.css" type="text/css" />
    <link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/jquery.autocomplete.css" type="text/css" />
    <script type="text/javascript" src="<%=request.getContextPath()%>scripts/jquery.bgiframe.min.js"></script>
    <script type="text/javascript" src="/<%=request.getContextPath()%>/query.dimensions.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jquery.autocomplete.js"></script>
    <script type="text/javascript">
    $().ready(function() {
        $("#tag").autocomplete("/myAction/Action", {
            multiple : true,
                autoFill : true,
                    minChars:1
                });
            });
</script>
</head>
<body>
    <s:form action="Action" theme="simple">
        <s:iterator value="elencoMateriali" var="asd">
            <s:property value="#asd" escape="false"/>   
                    </s:iterator>
        <s:textfield id="tag" name="tagField" label="tag" />
    </s:form>
</body>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:39:18+00:00Added an answer on May 14, 2026 at 9:39 pm
    <%@ taglib prefix="s" uri="/struts-tags" %>
        <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
    
    <s:form action="ActionJson" theme="simple">
        <s:url id="elencoFuffa" action="ActionJSON"/>
        <sx:autocompleter  id="autocompleter" name="materiale" loadOnTextChange="true" preload="false" href="%{elencoFuffa}" size="24" loadMinimumCount="1" showDownArrow="false" cssClass="dropDown" onchange="submit();"/>
    
            <s:submit value="Prosegui"/>
            <s:property value="luoghiSmaltimento"/>
        </s:form>  
    

    Now, the Action:

    public class Action extends ActionSupport {
    
    private String materiale;
    private String luoghi;
    private List<String> elencoMateriali;
    private Map<String, String> json;
    
    public String execute() throws Exception {
    
        System.out.println("------------------" + materiale);
    
        return SUCCESS;
    }
    
    public String getMateriali() throws Exception {
        MaterialiDAO dao = new MaterialiDAO();
        List<Materiali> toResult = new ArrayList<Materiali>();
        toResult = dao.findAll();
        elencoMateriali = new ArrayList<String>();
        Iterator i = toResult.iterator();
    
        while (i.hasNext()) {
            Materiali m = (Materiali) i.next();
            elencoMateriali.add(m.getValueNomemateriale());
        }
    
        return SUCCESS;
    
    }
    
    public String getJson() throws Exception {
        json = new HashMap<String, String>();
    
        if (materiale != null && materiale.length() > 0) {
            MaterialiDAO dao = new MaterialiDAO();
            List<Materiali> materiali = dao.findByLikeValue(materiale);
            for (Materiali m : materiali) {
                json.put(m.getValueNomemateriale(), "" + m.getIdMateriali());
            }
        }
    
        return SUCCESS;
    }
    
    public String trovaLuogo() throws Exception {
        LuoghismalDAO daoL = new LuoghismalDAO();
        MaterialiDAO daoM = new MaterialiDAO();
        Materiali m = daoM.findByMaterialiName(materiale);
    
        if (m != null) {
            luoghi = m.getLuoghismal().getValueDescrluogo();
    
            return SUCCESS;
    
        } else {
            luoghi = "-- Scegliere un materiale --";
            return SUCCESS;
        }
    }
    
    /* Getters and setters */
    

    At the end the struts.xml

            <action name="ActionJSON" class="it.action.Action"
            method="getJson">
            <result type="json">
                <param name="root">json</param>
            </result>
        </action>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.