开发者

Can anyone explain why event type is an arbitrary string in seam?

I noticed that the event type is just an arbitrary开发者_开发百科 string in seam which will be used in component.xml or annotations. Sometimes it is error-prone if I missspell them, for example "org.jboss.seam.security.notLogedIn", actually it should be "org.jboss.seam.security.notLoggedIn". Is there any alternative way to handle event types?


Since most of the event keys (types) are declared as public static final (as the one you reference), you can reference them without having troubles of misspelling.

@Observer(Identity.EVENT_NOT_LOGGED_IN)
public void handleNotLoggedIn() {
}

Unfortunately, you cannot use EL in event type declaration in component.xml. I recently tried that.

<event type="#{...}">
    <!-- does not work -->
</event>

There is, IMHO, no other way than copy-and-paste the event keys into the component.xml to prevent misspelling.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜