我想通过按Enter来执行搜索按钮后面的代码。任何建议都会很棒!
<html:text property="choiceValue" styleId="gestel999" onkeypress="return updateEnter(event,'refreshPage(this)')" style="margin-top:15px;" size="25"/>
function updateEnter(e,refreshPage){
if(ee.keyCode == 13 || e.which == 13){
refreshPage()
}
}
答案 0 :(得分:1)
ActionListen al = new ActionListener()
{
// implement ActionListener here
}
button.addActionListener( al );
textField.addActionListener( al );
现在,当您单击按钮时将调用相同的Action,或者当焦点位于文本字段时使用Enter。