为什么在使用javascript自动完成功能时在Eclipse中收到消息:“未处理的事件循环异常Java堆空间”?
25-03-13
9
如果您对为什么在使用javascript自动完成功能时在Eclipse中收到消息:“未处理的事件循环异常Java堆空间”?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于为什
如果您对为什么在使用javascript自动完成功能时在Eclipse中收到消息:“未处理的事件循环异常Java堆空间”? 感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于为什么在使用javascript自动完成功能时在Eclipse中收到消息:“未处理的事件循环异常Java堆空间”? 的详细内容,并且为您提供关于ajax java 实现自动完成功能_javascript技巧、javascript – Ace编辑器的自动完成功能、javascript – jQuery UI自动完成功能无法在IE中运行、javascript – jquery中的自定义自动完成功能 的有价值信息。
本文目录一览:
为什么在使用javascript自动完成功能时在Eclipse中收到消息:“未处理的事件循环异常Java堆空间”? 当我尝试使用任何JavaScript模板时,Eclipse总是挂起,并且出现以下消息:在弹出窗口中显示“未处理的事件循环异常Java堆空间”。
我为Eclipse进程和Java进程启动了一个最高命令(使用Ubuntu),然后尝试在Eclipse上使用自动完成功能。我注意到Java进程将我的CPU占用了100%的内存,而内存保持不变(大约22%)。
我在没有对Eclipse IDE进行任何事先更改的情况下得到了这个…
关于如何解决这个问题的任何想法?
编辑:我还注意到,在首选项窗口下:Javascript / Content Assist / Advanced下,选中了“ Other Javascript Proposals”选项。如果未选中,则问题已解决。但是,它缺少变量和对象的内容辅助。因此,这部分解决了我的问题。
答案1 小编典典 我设法找到问题所在。我将一些js文件临时移到了我的项目中(其中一些重复了原始文件),并且自动完成功能正在搜索太多文件。所以我像这样更改了src文件夹:
右键点击项目 选择属性 Java脚本 包含路径 在“源”选项卡上,我排除了重复的文件/文件夹以及一些我不想在自动完成时使用的文件/文件夹。 这解决了我的问题,并且Eclipse很快就可以自动完成。
ajax java 实现自动完成功能_javascript技巧 百度建议给了我们极大的方便,就像我们跟人说话的时候,你点头他知尾,不用多费唇舌,这样我们与之相处久轻松愉悦。 都知道百度建议是用ajax做的,想要做的快速稳定,可复制可移植就不容易了。网上找了半天,好多都是asp或者php的,还有使用jquery的,但说明性文档太少,花时间研究还不如自己来写。根据一个pdf文档提供的资料,用了小半天时间,终于实现了。在此与大家分享。 原理流程图如下: 流程图很明白了,没什么要说的,以下帖代码。 Javascript代码:
var xmlHttpRequest; var table; var tbody; var div; var input; var curIndex; var size; var r_userId; function createXMLHttpRequest(){ if(window.ActiveXObject){ xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }else if(window.XMLHttpRequest){ xmlHttpRequest = new XMLHttpRequest(); } } //发送请求 function findNames(){ if(event.keyCode==38||event.keyCode==40){ }else{ if(input.value.length>0){ createXMLHttpRequest(); var url = encodeURI(encodeURI("/jforum.html?module=posts&action=findDept&names="+input.value)); xmlHttpRequest.open("GET",url,true); xmlHttpRequest.onreadystatechange=processMatchResponse; xmlHttpRequest.send(null); }else{ clearNames(); } } } function processMatchResponse(){ if(xmlHttpRequest.readyState==4){ if(xmlHttpRequest.status==200){ //alert(xmlHttpRequest.status); //var id = xmlHttpRequest.responseXML.getElementsByTagName("id"); var dept = xmlHttpRequest.responseXML.getElementsByTagName("dept"); var id = xmlHttpRequest.responseXML.getElementsByTagName("id"); setNames(dept,id); }else{ window.alert("您所请求的页面有异常!"); } } } function setNames(depts,ids){ clearNames(); size = depts.length; if(size>0){ div.style.visibility = "visible"; var row,col1,col2,span; for(var i = 0;i row = document.createElement("tr"); col1 = document.createElement("td"); col1.innerText = depts[i].firstChild.data; col2 = document.createElement("td"); col2.setAttribute("align","right"); col2.setAttribute("id","col2"); col2.setAttribute("width","5%"); span = document.createElement("span"); span.innerText = ids[i].firstChild.data; span.style.display = "none"; col2.appendChild(span); row.appendChild(col1); row.appendChild(col2); row.onmouseout = function(){ this.className = ''mouseOut''; } row.onmouseover = function(){ clearSelected(); this.className = ''mouseOver''; curIndex = this.rowIndex; } row.onclick = function(){ input.value = this.cells[0].innerText; r_userId.value = table.rows[curIndex].cells[1].innerText; clearNames(); }; tbody.appendChild(row); } row = document.createElement("tr"); col2 = document.createElement("td"); col1 = document.createElement("td"); col2.setAttribute("align","right"); link = document.createElement("a"); link.href = "javascript:clearNames();"; link.innerHTML = "关闭"; col1.appendChild(link); row.appendChild(col1); row.appendChild(col2); tbody.appendChild(row); } } function setPosition(){ input = document.getElementById("names"); r_userId = document.getElementById("r_userId"); table = document.getElementById("table"); div = document.getElementById("div"); tbody = document.getElementById("tbody"); div.style.width = input.offsetWidth-2; div.style.border = "gray 1px solid"; div.style.left = getLeft(input); div.style.top = getTop(input)+input.offsetHeight+6; curIndex = -1; input.focus();//div.style.left+","+div.style.top } function clearNames(){ var ind = tbody.childNodes.length; for(i=ind-1;i>=0;i--){ tbody.removeChild(tbody.childNodes[i]); } div.style.visibility="hidden"; curIndex = -1; } function clearSelected(){ var ind = tbody.childNodes.length; for(var i = ind-1;i>=0;i--){ tbody.childNodes[i].className = "mouseOut"; } } function keyDown(){ if(div.style.visibility=="visible"){ if(event.keyCode ==38){ if(curIndex>=0){ table.rows[curIndex].className=''mouseOut''; curIndex = curIndex-1; if(curIndex>=0){ table.rows[curIndex].className = ''mouseOver''; input.value = table.rows[curIndex].cells[0].innerText; r_userId.value = table.rows[curIndex].cells[1].innerText; } } } if(event.keyCode==40){ if(curIndexif(curIndex>=0){ table.rows[curIndex].className = ''mouseOut''; } curIndex = curIndex+1; table.rows[curIndex].className = ''mouseOver''; input.value = table.rows[curIndex].cells[0].innerText; r_userId.value = table.rows[curIndex].cells[1].innerText; }else{ table.rows[curIndex].className = ''mouseOut''; curIndex = -1; } } } } //获取元素的纵坐标 function getTop(e){ var offset=e.offsetTop; if(e.offsetParent!=null) offset+=getTop(e.offsetParent); return offset; } //获取元素的横坐标 function getLeft(e){ var offset=e.offsetLeft; if(e.offsetParent!=null) offset+=getLeft(e.offsetParent); return offset; }
代码太多,有点乱,没使用jquery,但更能显示作者的功底。以下分点阐述:
1,setPosition()是用来初始化全局所需要的各个变量,所以在页面加载的时候就要先调用喽,比如在body的onload方法,或者其他方式都可以。
2,findNames()是操作ajax的方法,熟悉ajax的人都可以看明白,里面最主要的是要对参数进行二次编码encodeURI(),相应的在后台要进行解码。
3,processMatchResponse()是回调函数,用来处理从后台返回的数据,这里交给了setNames()来处理。
4,setNames中采用table方式显示提示的内容。这里更多的是JS和node方面的知识。
5,getTop和getLeft方法是获得文本框的绝对位置,相对于浏览器左上角的。
后台java代码如下:
public void findDept() throws IOException{ String partDeptName = this.request.getParameter("names"); partDeptName = java.net.URLDecoder.decode(partDeptName, "UTF-8"); Map userMap = DataAccessDriver.getInstance().newUserDAO().getDeptByPart("%" + partDeptName + "%"); this.response.setContentType("text/xml;charset=UTF-8"); this.response.setHeader("Cache-Control", "no-cache"); ServletOutputStream pw = this.response.getOutputStream(); OutputStreamWriter out = new OutputStreamWriter(pw,"UTF-8"); out.write(""); Iterator> it = userMap.entrySet().iterator(); while(it.hasNext()){ Map.Entry entry=(Map.Entry)it.next(); out.write(""+entry.getKey()+" "); out.write(""+entry.getValue()+" "); } out.write(" "); out.flush(); out.close(); }
要点 : 1,注意对参数进行解码。 2,查询时根据情况进行模糊匹配。 3,返回数据这里采用了xml方式,也可以采用json方式。 4,返回的方式这里采用了
ServletOutputStream pw = this.response.getOutputStream(); OutputStreamWriter out = new OutputStreamWriter(pw,"UTF-8");
这样的流是受本系统框架的限制,如果使用单纯的servlet,可以采用PrintWriter out = response.getWriter();当然out的方法是println(),也可以根据自己框架的情况灵活改变。
javascript – Ace编辑器的自动完成功能 好的,所以这是交易:
>我正在使用Ace Editor >编辑器集成的应用程序,是Objective-C/C++ocoa >我需要AutoCompletion(针对给定的一组关键字)
现在,这是一个问题:
>我知道AutoCompletion尚未得到本机支持 >我知道其他人的尝试(例如Codiad IDE,Gherkin,Alloy-UI),有些尝试使用Jquery UI Autocomplete – 但我仍然无法弄清楚如何将其改编为现有的Ace设置 >我仍然不确定我是否应该选择面向JS的解决方案,或者只是使用Objective-C/C++ocoa
任何帮助都不仅仅是值得赞赏的.
解决方法
可以在ace编辑器中实现AutoCompletion ..
代码:
var editor = ace.edit('editor');
editor.setTheme("ace/theme/eclipse");
editor.getSession().setMode("ace/mode/java");
editor.setShowInvisibles(true);
editor.setdisplayIndentGuides(true);
editor.getSession().setUseWrapMode(true);
var jsonUrl = "JSON/Components/proce.json";
//the url where the json file with the suggestions is present
var langTools = ace.require("ace/ext/language_tools");
editor.setoptions({enableBasicAutocompletion: true});
var rhymeCompleter = {
getCompletions: function(editor,session,pos,prefix,callback) {
if (prefix.length === 0) { callback(null,[]); return }
$.getJSON(jsonUrl,function(wordList) {
callback(null,wordList.map(function(ea) {
return {name: ea.word,value: ea.word,Meta: "optional text"}
}));
})
}
}
langTools.addCompleter(rhymeCompleter);
Json文件格式:
[ {"word":"hello"},{"word":"good morning"},{"word":"suggestions"},{"word":"auto suggest"},{"word":"try this"}]
参考/演示:
http://plnkr.co/edit/6MVntVmXYUbjR0DI82Cr?p=preview
javascript – jQuery UI自动完成功能无法在IE中运行 我在jQuery UI 1.8rc3中有新的自动完成小部件在Firefox中运行良好.它在IE中根本不起作用.有人可以帮我吗?
HTML:
<input type="text" id="ctrSearch" size="30">
<input type="hidden" id="ctrId">
使用Javascript:
$("#ctrSearch").autocomplete({
source: "ctrSearch.do",
minLength: 3,
focus: function(event, ui){
$('#ctrSearch').val(ui.item.ctrLastName + ", " + ui.item.ctrFirstName);
return false;
},
select: function(event, ui){
$('#ctrId').val(ui.item.ctrId);
return false;
}
});
结果(IE 8):
红色框是< ul>由jQuery创建的元素.
http://i40.tinypic.com/6q9quu.jpg
我也得到这个错误:
Line: 116
Error: Invalid argument.
当我在IE8脚本调试器中打开它时,它会突出显示jquery.min.js第116行的f [b] = d.请注意,我正在使用托管在Google服务器上的jQuery版本1.4.2(https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js).
我已经尝试删除一些选项,但即使我在没有选项的情况下调用.autocomplete(),或者只使用source选项,我仍然得到相同的结果.
它再一次在Firefox中运行,但在IE中却没有.有什么建议?
谢谢.
更新:正如所建议的,我使用了jquery.js(而不是jquery.min.js)并在第4618行得到了错误.请参阅下面的jitter答案.请参阅几天前发布的this other Stack Overflow question.
更新2:我发现jQuery UI自动完成使用了无效的属性this.element.height,它应该使用函数this.element.height()
解决方法:
如果我理解这一点,那么你所指的那条线似乎是样式函数中jquery.1.4.2.js中的4618行.这只能意味着Autocompleter插件尝试设置IE8不理解的样式值,或者不允许以这种方式访问/更改.
style[ name ] = value; //style == elem.style from the passed in element
javascript – jquery中的自定义自动完成功能 UPDATE
在@Ziv Weissman和@Fribu的帮助和建议下,我重新编写了整个自动完成功能.
如果有人需要,他/她可以从here下载.
感谢StackOverFlow社区.
我正在创建一个jquery自动完成功能.我创建的功能与单个文本框一起正常工作.但是,只要我在同一页面的另一个文本框中实现它,它就会出现意外行为.它会打开和关闭自动完成列表.
这是我的autofill.js代码:
function setUl(result) {
var $ul = $('<ul>');
if (result !== undefined) {
$.each(result,function (k,v) {
$ul.append('<li data-value="' + v.value + '">' + v.label + '</li>');
});
}
return $ul;
}
$.fn.autofill = function (options) {
if (options == undefined) {
options = {};
}
var $currentInput = $(this);
var autoCompleteData = $currentInput.data('autofill');
var listId='autofill-' + (new Date().getTime()).toString(16);
$currentInput.on('keyup focus',function (e) {
var query = $(this).val();
var result = $.grep(autoCompleteData,function (v) {
return v.label.search(new RegExp(query,'i')) !== -1;
});
$ul = setUl(result,$currentInput);
$ul.attr('id',listId);
$ul.addClass('autofill-show');
$ul.attr('data-target',$currentInput.attr('id'));
var position = $currentInput.position();
$ul.css({
width: $currentInput.width() + parseInt($currentInput.css('padding-left'),10) + parseInt($currentInput.css('padding-right'),10),position: 'absolute',top: position.top + $currentInput.outerHeight(),left: position.left
});
if ($ul.find('li').length >= 6) {
$ul.css({
height: '130px','overflow-y': 'scroll'
});
}
if (result !== undefined) {
if ($(e.target).attr('id') !== $currentInput.attr('id') && $($(e.target).parent()[0]).attr('id') !== listId) {
destroy($ul);
}
$currentInput.after($ul);
}
$currentInput.trigger('onChange',[query,result]);
});
$(document).on('click','.autofill-show li',function (e) {
if($ul!==undefined && $($(this).parent()[0]).attr('id')==$ul.attr('id')){
$ul.trigger('onSelect',[$(this).text(),$(this).data('value')]);
}
e.stopImmediatePropagation();
});
$(document).on('onSelect','#'+listId,function (e,label,value) {
$currentInput.val(label);
if ($.isFunction(options.onSelect)) {
options.onSelect(label,value);
}
if ($(e.target).attr('id') !== $currentInput.attr('id') && $($(e.target).parent()[0]).attr('id') !== listId) {
destroy($ul);
}
e.stopImmediatePropagation();
});
$(document).on('onChange','#'+$currentInput.attr('id'),query,result) {
if($ul!==undefined && $($(this).parent()[0]).attr('id')==$ul.attr('id')) {
result = $.grep(autoCompleteData,function (v) {
return v.label.search(new RegExp('\^' + query + '\$',"gi")) !== -1;
});
if ($.isFunction(options.onChange)) {
options.onChange(query,result[0]);
}
}
e.stopImmediatePropagation();
});
$(document).on('click',function (e) {
console.log($(e.target));
if ($(e.target).attr('id') !== $currentInput.attr('id') && $($(e.target).parent()[0]).attr('id') !== listId) {
destroy($ul);
}
e.stopImmediatePropagation();
});
};
function destroy($ul) {
$ul.remove();
}
这是我的css:
.autofill-show{
list-style: outside none none;
padding: 0;
border: 1px solid #ccc;
margin:0;
z-index: 9999999;
}
.autofill-show li{
border: 1px solid #ccc;
text-align: center;
background: #fff;
}
.autofill-show li:hover{
background: #9bcea3;
cursor: pointer;
}
这就是我调用函数的方式:
$('#autofill').autofill();
$('#autofill_2').autofill();
这是小提琴链接. https://jsfiddle.net/saineshmamgain/cs6g13q9/2/
解决方法
正如我所提及的,以及其他人的帮助,这是您的活动和选择器的问题.
一种解决方案可以是为创建的UL添加唯一ID,而不是“基于日期时间”. 每次您将破坏特定ID,并重新创建它. 事件将通过HTML(添加onclick = …)触发,并使用jQUERY以当前/父级别进行触发.
我已经更新了这个fiddle
它可能有你的小提琴剩下的东西,我没有时间去完善……我会留给你.
解决方案看起来像这样:
function setUl(result) {
var $ul = $('<ul>');
if (result !== undefined) {
$.each(result,v) {
$ul.append('<li data-value="' + v.value + '" onclick="clickHandle(this)">' + v.label + '</li>');
});
}
return $ul;
}
function clickHandle(ele){
var label = $(ele).text();
var value = $(ele).data('value');
var inputId = $(ele).parent("ul").attr("data-target");
$('#'+inputId).val(label);
if ($.isFunction(options.onSelect)) {
options.onSelect(label,value);
}
}
$.fn.autofill = function (options) {
if (options == undefined) {
options = {};
}
var $currentInput = $(this);
console.log($($currentInput).attr('id'));
var autoCompleteData = $currentInput.data('autofill');
var listId='autofill_' + $currentInput.attr('id');
$currentInput.on('keyup focus','i')) !== -1;
});
if($('#'+listId)){
$('#'+listId).remove();
}
$ul = setUl(result,'overflow-y': 'scroll'
});
}
if (result !== undefined) {
destroy($ul);
$currentInput.after($ul);
}
$currentInput.trigger('onChange',result]);
});
//end key up
$('#'+listId).on('onSelect',value);
}
destroy($ul);
e.stopImmediatePropagation();
});
$(document).on('onChange',result[0]);
}
}
e.stopImmediatePropagation();
});
$currentInput.on('blur',function (e) {
window.setTimeout(function(){
destroy($ul);
},100);
});
};
function destroy($ul) {
$ul.remove();
}
关于为什么在使用javascript自动完成功能时在Eclipse中收到消息:“未处理的事件循环异常Java堆空间”? 的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于ajax java 实现自动完成功能_javascript技巧、javascript – Ace编辑器的自动完成功能、javascript – jQuery UI自动完成功能无法在IE中运行、javascript – jquery中的自定义自动完成功能 等相关知识的信息别忘了在本站进行查找喔。