我注意到事件类型只是seam中的一个任意字符串,将在component.xml或注释中使用.有时候如果我错误地使用它们就容易出错,例如"org.jboss.seam.security.notLogedIn",实际上它应该是"org.jboss.seam.security.notLoggedIn".有没有其他方法来处理事件类型?
由于大多数事件键(类型)被声明为public static final(作为您引用的那个),因此您可以引用它们而不会出现拼写错误的问题.
@Observer(Identity.EVENT_NOT_LOGGED_IN)
public void handleNotLoggedIn() {
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,你不能在事件类型声明中使用EL component.xml.我最近尝试过.
<event type="#{...}">
<!-- does not work -->
</event>
Run Code Online (Sandbox Code Playgroud)
恕我直言,除了将事件键复制粘贴component.xml到防止拼写错误之外,别无他法.