---
title: "RichFaces按回车键提交表单"
author: "stenlylee"
date: "2009-12-21T11:28:06Z"
tags: ["Bean", "richfaces"]
categories: ["企业架构"]
slug: "richfaces"
draft: false
lastmod: "2009-12-21T11:28:06Z"
id: 552700
url: "https://stenlylee.iteye.com/blog/552700"
---

```
<h:inputText value="#{bean.text}"/>
<a4j:commandButton value="Submit"/>
...
<rich:hotKey key="return" handler="#{rich:element('button')}.click()"/>
```

 

如果想要当焦点放到输入域里面的时候提交，下面的代码可做参考

 

```
<h:inputText id="input" value="#{bean.text}"/>
<a4j:commandButton id="button" value="Submit"/>
...
<rich:hotKey key="return" 
       selector="#input"     
       handler="#{rich:element('button')}.click()"/>
```