2016-08-23 77 views
0

我在我們的應用程序中使用了一個Struts自定義日期標記。當日期發生變化並執行操作時,我需要觸發事件。我嘗試了onchange/onkeyup/onkeydown事件。Struts日期標記事件

<s:date property="data(date)" disabled="false" todayButtonDisabled="true" id="date" /> 

但它引發我一個錯誤如下

Failed to compile JSP /jsp/tiles/date.jsp date.jsp:428:28: This attribute is not recognized. 
       id="date" onkeypress="DateCheck(this)" 

我們是否可以處理這個日期定製標記的onchange事件的任何事件?

+0

日期自定義標籤? –

回答

0

更常見的方式是不要在html代碼中使用任何on *屬性,並使用javascript將(javascript-)操作添加到事件中。我希望您的customtag允許class屬性:

<s:date property="data(date)" disabled="false" todayButtonDisabled="true" id="date" class="dateelements"/> 

而且,使用jQuery:

$('.dateelements').on('keydown', function(evt) { 
    //dosomething 
}); 

或者你可以改變customtag定義(應該是有的TLD文件在您的項目),以允許在*事件。有一個選項<dynamic-attributes>true</dynamic-attributes>應該工作。