简体   繁体   English

JSF 未知系统事件

[英]JSF Unknown System Events

I am working on a JSF 2.0 project, and learning the benefits of using System Events.我正在研究 JSF 2.0 项目,并学习使用系统事件的好处。 However, the book I'm referencing 'Core Java Server Faces 3rd Edition' lists a total of 14 system event types that can be used in the f:event tag's type attribute.但是,我引用的书“Core Java Server Faces 3rd Edition”一共列出了 14 种系统事件类型,可以在 f:event 标签的 type 属性中使用。 Some of them work as I would expect, eg "preRenderComponent" on a UIComponent tag, or "preRenderView" on a UIViewRoot tag.其中一些按我的预期工作,例如 UIComponent 标签上的“preRenderComponent”,或 UIViewRoot 标签上的“preRenderView”。 But, besides those two, and a select few others, none of the other events mentioned in the book work.但是,除了这两个之外,还有一个 select 其他几个,书中提到的其他事件都不起作用。 For example, I can't get the postRestoreState type of event to work on a UIComponent.例如,我无法让 postRestoreState 类型的事件在 UIComponent 上工作。 Instead, when JSF tries to render the page, I get a ClassNotFound Exception, presumably to the System Event class that is supposed to handle postRestoreState events, or whatever event it is I'm trying to listen for.相反,当 JSF 尝试呈现页面时,我得到一个 ClassNotFound 异常,可能是系统事件 class 应该处理 postRestoreState 事件,或者我试图监听的任何事件。

Why don't these other event types work?为什么这些其他事件类型不起作用? Is there some other library I need, or is there some other way of implementing a system event listener that I need to use.是否有我需要的其他库,或者是否有其他方式来实现我需要使用的系统事件侦听器。 Below is an example of one such tag that is failing:下面是一个失败的此类标签的示例:

            <h:commandLink
                action="editPlant"
                value="#{appMessages.UsersNavigationAddPlant}"
                styleClass="#{userSession.selectedStyle}"
                >
                <f:event type="postRestoreState" listener="#{userSession.setSelectedStyle()}" />
            </h:commandLink> 

It appears that you need the full Class name:看来您需要完整的 Class 名称:

<f:event type="javax.faces.event.PostRestoreStateEvent" listener="#{bean.postRestoreState}"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM