我有这个网站:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head></h:head>
<h:body>
<h:form id="form-some">
<h:inputText id="copingFilePhaseFocus">
<p:ajax event="focus" actionListener="#{installationController.startCopyingWarFile}" />
</h:inputText>
</h:form>
</h:body>
</html>
和支持bean:
@ManagedBean(name = "installationController")
@SessionScoped
public class InstallationController implements IPluginInstallationListener {
// Some methods here (...)
public void startCopyingWarFile(ActionEvent event) {
System.out.println("\n\n\n\nStarted\n\n\n\n");
}
}
此代码在 MyFaces 2.0.0 下运行。但在 MyFaces 2.0.2 或 Mojarra 2.0.2 下没有。通过告诉“不起作用”,我的意思是单击(聚焦)输入文本不会触发 actionListener(文本“已启动”不会出现在标准输出中)。有没有人有类似的问题?
编辑 1(将 p:ajax 更改为 f:ajax 后):
<p:outputPanel id="copingFilePhase">
<p:accordionPanel speed="0.2"
rendered="#{pluginInstallerWebBean.copingFilePhase}">
<p:tab
title="#{msg['installPlugin.copyingWar']} ... #{pluginInstallerWebBean.copingFilePhaseState}">
<h:form prependId="false">
<p:focus for="copingFilePhaseFocus" />
<h:inputText id="copingFilePhaseFocus"
rendered="#{pluginInstallerWebBean.copingFilePhaseFocus}"
style="display:none;">
<f:ajax event="focus"
render="copingFilePhase obtainingPluginInformationPhase"
listener="#{installationController.startCopyingWarFile}" />
</h:inputText>
</h:form>
#{msg['installPlugin.copyingWarDescription']}
</p:tab>
</p:accordionPanel>
</p:outputPanel>
<p:outputPanel id="obtainingPluginInformationPhase">(...)</p:outputPanel>
错误是:
javax.faces.FacesException:包含未知 id 'copingFilePhase' - 无法在组件 copingFilePhaseFocus 的上下文中找到它