Hi all,

I donĀ“t retrive the response of search, what did I do wrong?

the code.

ACTION

public class UserAction extends ActionSupport implements
ModelDriven<User>{

        private static final long serialVersionUID = 1L;
        private User user = new User();
        private UserDAO dao = new UserDAO();
        private String names = "";

        @Override
        public User getModel() {
                return user;
        }

        public User getUser() {
                return user;
        }

        public void setUser(User user) {
                this.user = user;
        }

        public String execute(){
                if (dao.saveOrUpdate(user)){
                        return SUCCESS;
                }
                return ERROR;
        }

        public String usersByName(){

                HttpServletRequest request = ServletActionContext.getRequest();
                List<String> names = 
dao.getUserNames(request.getParameter("q"));

                for (String name : names) {
                        this.names += name + "\n";
                }
                return SUCCESS;
        }

        public String getNames() {
                return names;
        }

        public void setNames(String names) {
                this.names = names;
        }
}


struts.xml
.
.
.
         <action name="consultUserAction" method="usersByName"
class="web.UserAction">
                        <result name="success">/JSP/infoUsers.jsp</result>
         </action>
.
.
.

infoUsers.jsp
.
.
.
<script>
        $(document).ready(function(){
                $("#consultName").autocomplete("consultUserAction.action");
        });
</script>
.
.
<s:form>
        <fieldset><legend>&nbsp;Consulta&nbsp;</legend>
        <p>
        <s:label value="Nome:" cssClass="left" ></s:label>
                                                                        
<s:textfield id="consultName" name="consultName"
cssClass="field"></s:textfield>
                                                                </p>
                                                        </fieldset>
                                                </s:form>

Reply via email to