开发者

Problem h:selectOneMenu and event onSelect

does anybody knows why I am not reaching this alert??

<h:selectOneMenu id="lang" binding="#{mybind}" onSelect="javascript:alert('Reacheable??')" >

in documentation s开发者_运维知识库ays that it is available. Thanks in advance


my code is OK

<h:selectOneMenu id="creditBank" value="#{fundTranferExt.creditBank}" onchange="alert('Reacheable??')">
    <f:selectItems value="#{fExtBankList}"></f:selectItems>                             
</h:selectOneMenu>                          


I can't comment yet but I would like to clarify nguyên's answer a little bit more. JSF isn't right on implementing onselect attribute. It generates HTML select element with "onselect" attribute but that one isn't valid for select. Instead of it you can use "onchange". That is fired immediately when the user makes a selection with the mouse but if user makes selection with keyboard the event is deferred until the element loses focus. Also you have to remove "javascript:" from onchange value and write whole attribute name with lowercases. Value in onchange attribute is always JavaScript so you don't need to mentioned that explicitly:

<h:selectOneMenu id="lang" binding="#{mybind}" onchange="alert('Reacheable??')" >
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜