JSF页面上的默认操作(即在输入字段上按Enter) [英] Default action on JSF pages (ie pressing enter on input fields)

查看:85
本文介绍了JSF页面上的默认操作(即在输入字段上按Enter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JSF和facelets(xhtml)创建HTML页面。有2个h:forms可以到达不同的地方。用户以一种形式输入数据,然后按 Enter键。
这是棘手的地方。在IE 6及更高版本上,要么提交表单操作(通常指向您所在的页面),然后重新加载页面,要么提交页面上的第一个h:commandbutton / link。它是完全随机的,但在该页面上是一致的。

A HTML page is created using JSF and facelets (xhtml). There are 2 h:forms that goes to different places. The user enters data on one form and presses the "Enter" key. Here is where it gets tricky. On IE 6 and above, either the forms action gets submitted (which usually points to the page you are on) which then just reloads the page, or the first h:commandbutton/link that is on the page. Its totally random, but its consistant on that page.

这是我尝试过的内容,我尝试将必须以其自己的形式提交的组件放置在一起...它有效,但无处不在。然后,我尝试使用按钮的ID创建一个隐藏的输入,它的工作效率很高,但是随后IE试图调用页面上的第一个按钮以某种方式绕过了它。我尝试了一种名为j4j的产品,该产品原本可以创建默认操作,但无法正常工作,而是在呈现的HTML中输出代码本身。当它确实起作用时,它将创建javascript,他们寻找键13,然后调用oamsubmit(....,顺便说一句,我也尝试了不同程度的成功。

Here is what I have tried, I tried placing the components that have to be submitted in their own form...it works but not everywhere. Then I tried creating a hidden input with the id of the button, it works quite effectively, but it is then bypassed somehow by IE trying to invoke the first button on the page. I tried a product called j4j that supposedly creates a default action, but it doesn't work, outputting the tag itself in the rendered HTML. When it does work, it creates javascript they looks for key 13, and then invokes oamsubmit(...., which incidently I tried also with varying degrees of success.

推荐答案

这是我的工作方式吗?在JSF中解决了此问题(只需将其添加到您的h:form中)

This is how I solved it in JSF (just add this to your h:form)

<h:inputText id="StackOverflow1205114" value="Fix IE bug" style="{display:none}" /> 

这将创建输出为此:

<input id="_id3:StackOverflow1205114" type="text" name="_id3:StackOverflow1205114" value="Fix IE bug" style="{display:none}" />

这篇关于JSF页面上的默认操作(即在输入字段上按Enter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆