hai ragione!!era tutto funzionante perciò non ho messo il codice!!anyway:
Creo l'XML:
lo leggo dal Javascript:codice:XStream xs = new XStream(); List<String> miaList = servizio.prendiLista(); xs.alias("name", java.lang.String.class); File file = new File("C:\\workspaceJ2EE\\j2ee\\Web\\WebContent\\code\\Lista.xml"); if(!file.exists()) { file.createNewFile(); } FileOutputStream fs = new FileOutputStream(file); Writer writer = new OutputStreamWriter(fs, Charset.forName("UTF-8")); writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); xs.toXML(mialist, writer);
se il file List.xml lo metto prima di far partire l'Application Server questo viene visto senza problemi e tutto funziona...se invece il file è generato(nello stesso path) da XStream allora ricevo un FileNotFound lato Javascript...codice:$(function() { $.ajax({ url: "code/Lista.xml", dataType: "xml", success: function( xmlResponse ) { var data = $( "name", xmlResponse ).map(function() { return { value: $( this ).text() }; }).get(); $( "#Campo" ).autocomplete({ source: function(request, responseFn) { var re = $.ui.autocomplete.escapeRegex(request.term); var matcher = new RegExp( "^" + re, "i" ); var a = $.grep(data, function(item,index){ return matcher.test(item.value); }); responseFn( a ); }, change: function(event,ui) { //if (!ui.item) { $(this).val(''); } var source = $(this).val(); var found = $('.ui-autocomplete li').text().search(source); if(found < 0) { $(this).val(''); } }, select: function(event,ui) { //$('#Campo').val(ui.item.value); var source = $(this).val(); var found = $('.ui-autocomplete li').text().search(source); if(found < 0) { $(this).val(''); } else { var valore = ui.item.value; var verify = ui.item.value.lastIndexOf(' ('); if (verify != -1) { valore = valore.substring(0, valore.lastIndexOf(' (')); } $('#Campo').val(valore); return false; } }, selectFirst: false, minLength: 2 }); } }); }); }
PS: scusate non riesco a formattare bene il codice qui sul forum...il codice JS l'ho messo qui: http://jsfiddle.net/8VBLt/

Rispondi quotando