【发布时间】:2010-05-20 12:52:41
【问题描述】:
我想关注我的 RichFaces rich:modalPanel 中的第一个 h:inputSecret 组件。我读过我需要使用下面列表中包含的 javascript,但它根本不起作用(Win FF)。谁能告诉我为什么不呢?我已经尝试在 id="Form" 上自动对焦并给 panelGrid 一个 id 并使用它无济于事。任何帮助表示赞赏。
<rich:modalPanel id="PwdPanel" autosized="true" width="300" onshow="autofocus('FormNewP0')">
<a4j:region id="FormCont">
<a4j:form name="Form">
<h:panelGrid columns="2" style="padding: 2px;">
<h:outputText value="New password " />
<h:inputSecret id="FormNewP0"
value="#{MyBacking.dbNewPwd0}" />
<h:outputText value="Re-enter new password " />
<h:inputSecret id="FormNewP1"
value="#{MyBacking.dbNewPwd1}" />
<h:outputText value="" />
<h:panelGroup>
<a4j:commandButton value="Submit"
action="#{MyBacking.dbPwdChange}"
oncomplete="#{MyBacking.dbPwdError == true ? 'Richfaces.showModalPanel(\'ErrorPanel\');' : 'Richfaces.hideModalPanel(\'ErrorPanel\');Richfaces.hideModalPanel(\'PwdPanel\');'}"
reRender="FormCont,FormText" />
<h:outputText value=" " />
<a4j:commandButton value="Cancel"
onclick="#{rich:component('PwdPanel')}.hide();return false;" />
</h:panelGroup>
</h:panelGrid>
</a4j:form>
</a4j:region>
</rich:modalPanel>
<script type="text/javascript" language="JavaScript">
function autofocus(containerId) {
var element = jQuery(":input:not(:button):visible:enabled:first", '#'+containerId);
if (element != null) {
element.focus().select();
}
}
</script>
【问题讨论】:
-
服务器端源代码与故事无关,因为 JavaScript 看不到它的任何行。客户端源代码更有趣,因为它是 JavaScript 唯一可以看到和访问的。在网络浏览器中右键单击页面并选择查看源代码。顺便说一句,您对我在描述与您的症状相同的问题上的其他回答投了反对票,恕我直言有点愚蠢,因为您没有同样的问题。
-
嗯,我实际上正在处理几个类似的问题,所以它可能是相同的。或者这可能是一个错误。
标签: javascript jquery jsf richfaces