Estou tentando fazer um auto complete mais nao consigo com um INPUT.
JSP
<table class="paletteTable">
<tr><td class="formDivPalette"></td><td class="formDivPalette2"></td></tr>
<tr><td class="formLabel"><bean:message bundle="eGenResources" key="jsp.module"/> <bean:message bundle="eGenWebideResources" key="jsp.fieldnotnull"/></td><td><html:select style="width:105px;" styleId="module" property="module" size="1" onchange="javascript:introduction_action.click();" errorStyleClass="errorField"><html:options property="moduleList" labelProperty="moduleLabelList"/></html:select></td></tr>
[b] <tr><td class="formLabel"><td class="formLabelPalette2"><input id="name" type="text" name="name" size="15"></td></tr>[/b]
<tr><td class="formLabel"><bean:message bundle="eGenResources" key="jsp.dynamic"/></td><td><html:checkbox styleClass="baseFieldCheckBox" property="dynamic" value="true"/></td></tr>
</table>
<script>
$(function() {
function log( message ) {
$( "<div/>" ).text( message ).prependTo( "#log" );
$( "#log" ).attr( "scrollTop", 0 );
}
$( "#name" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: '../egendev/domain/EditDomainReferenceForm.do?=',
//editurl: '../egendev/domain/EditDomainReferenceForm.do?=',
//dataType: "json",
data: {
name: request.term
},
success: function( data ) {
response(data.result);
}
});
},
minLength: 1,
delay:100,
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.value);
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
});
</script>
Class Action
public class EditDomainReferenceAction extends com.egen.util.struts.AbstractAction {
public ActionForward perform_introduction_action(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(true);
ActionForward actionForward = null;
try {
EditDomainReferenceActionForm f = (EditDomainReferenceActionForm) form;
f.setModuleList(new ArrayList<String>());
f.setModuleLabelList(new ArrayList<String>());
f.setNameList(new ArrayList<String>());
f.setNameLabelList(new ArrayList<String>());
Object expressionObject = WebExpressionHelper.retrieve(f.getExpression(), request);
if (expressionObject != null && expressionObject instanceof DomainReference) {
DomainReference domainReference = (DomainReference)expressionObject;
f.setModule(domainReference.getModule());
f.setName(domainReference.getName());
f.setDynamic(domainReference.getDynamic());
} else {
f.setDynamic(true);
}
if (expressionObject != null && expressionObject instanceof ToolEntity) {
Project project = ToolEntityHelper.retrieveProject((ToolEntity)expressionObject);
if (project != null) {
updateLists(f, project);
}
}
session.setAttribute(mapping.getName(), f);
actionForward = mapping.findForward("same");
} catch (Exception e) {
com.egen.webide.util.StrutsMessageHelper.saveMessage(com.egen.webide.util.ErrorHandling.errorDescription(e), com.egen.webide.util.StrutsMessageHelper.ERROR, request);
actionForward = mapping.findForward("same");
}
return actionForward;
}
public ActionForward perform_save_action(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(true);
ActionForward actionForward = null;
try {
EditDomainReferenceActionForm f = (EditDomainReferenceActionForm) form;
Object expressionObject = WebExpressionHelper.retrieve(f.getExpression(), request);
DomainReference domainReference = null;
Object parent = null;
if (expressionObject != null) {
if (expressionObject instanceof DomainReference) {
domainReference = (DomainReference)expressionObject;
parent = domainReference.retrieveParent();
} else {
domainReference = new DomainReference();
}
domainReference.setModule(f.getModule());
domainReference.setName(f.getName());
domainReference.setDynamic(f.getDynamic());
if (parent == null && expressionObject != null && expressionObject instanceof Element) {
parent = expressionObject;
}
if (parent != null && parent instanceof Element) {
Element item = (Element)parent;
boolean circularReference = false;
Domain domain = ToolEntityHelper.retrieveDomain(item);
if (domain != null) {
if (domain.getModule().equals(domainReference.getModule()) && domain.getName().equals(domainReference.getName())) {
circularReference = true;
}
}
if (!circularReference) {
domainReference.assignParent(item);
item.setDomainReference(domainReference);
com.egen.webide.util.StrutsMessageHelper.saveMessage("msg.changessaved", com.egen.webide.util.StrutsMessageHelper.SAVE, request);
} else {
com.egen.webide.util.StrutsMessageHelper.saveMessage("msg.circularreference", com.egen.webide.util.StrutsMessageHelper.ERROR, request);
}
}
}
session.setAttribute(mapping.getName(), f);
actionForward = mapping.findForward("same");
} catch (Exception e) {
com.egen.webide.util.StrutsMessageHelper.saveMessage(com.egen.webide.util.ErrorHandling.errorDescription(e), com.egen.webide.util.StrutsMessageHelper.ERROR, request);
actionForward = mapping.findForward("same");
}
return actionForward;
}
public ActionForward perform_delete_action(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(true);
ActionForward actionForward = null;
try {
EditDomainReferenceActionForm f = (EditDomainReferenceActionForm) form;
Object expressionObject = WebExpressionHelper.retrieve(f.getExpression(), request);
if (expressionObject != null && expressionObject instanceof DomainReference) {
DomainReference domainReference = (DomainReference)expressionObject;
Object parent = domainReference.retrieveParent();
if (parent != null) {
if (parent instanceof Element) {
Element element = (Element)parent;
element.setDomainReference(null);
com.egen.webide.util.StrutsMessageHelper.saveMessage("msg.successfuloperation", com.egen.webide.util.StrutsMessageHelper.DELETE, request);
}
}
}
session.removeAttribute(mapping.getName());
actionForward = mapping.findForward("same");
} catch (Exception e) {
com.egen.webide.util.StrutsMessageHelper.saveMessage(com.egen.webide.util.ErrorHandling.errorDescription(e), com.egen.webide.util.StrutsMessageHelper.ERROR, request);
actionForward = mapping.findForward("same");
}
return actionForward;
}
private void updateLists(EditDomainReferenceActionForm f, Project project) throws Exception {
ArrayList<String> modulesList = ProjectHelper.retrieveModules(project);
modulesList.add(0, "");
f.setModuleList(modulesList);
f.setModuleLabelList(modulesList);
String module = f.getModule();
if (module != null) {
ArrayList<String> domainsList = DomainHelper.listNames(module, project);
f.setNameList(domainsList);
f.setNameLabelList(domainsList);
}
}
}
Da error na URL que passo no Script Jquery url: ‘…/egendev/domain/EditDomainReferenceForm.do?=’, oq realmente eu devo passar como paremetro nessa linha?