Call JavaScript function in Strut 2

让人想犯罪 __ 提交于 2019-12-12 02:53:32

问题


Good day all,

I have a html code to call function to do date time picker in Stripes framework which is working fine, the code is as follow :

<td class="value" align="left">
    <s:text name="firstProcessDate" id="firstProcessDate" maxlength="16" size="20" readonly="true"/>
    <img alt="Calendar" src="../images/ib/icon_calendar.gif" id="calendar" name="calendar"/>
    <script type="text/javascript">
       Calendar.setup({
        inputField: getObject("firstProcessDate"),
        dateFormat: "%d/%m/%Y",
        trigger: getObject("calendar"),
        min: Calendar.dateToInt(new Date()),
        max: Calendar.dateToInt(new Date()) + 10000, //one year from today's date
        bottomBar: false,
        onSelect: function() { 
            this.hide();
            checkTodayDate(); 
        }
       });
    </script>
   </td> 

Currently, I would like to do it in Strut 2 framework, I change the code as follow:

<td>
    <html:text property="firstProcessDate" maxlength="16" size="20" readonly="true" />
    <html:image alt="Calendar" src="/images/icon_calendar.gif" value="reset" onclick="return test()" />
    <script type="text/javascript">
        Calendar.setup({

            inputField: getObject("firstProcessDate"),
            dateFormat: "%d/%m/%Y", 
            trigger: getObject("calendar"), 
            min: Calendar.dateToInt(new Date()), 
            max: Calendar.dateToInt(new Date()) + 10000, //one year from today's date 
            bottomBar: false, 
            onSelect: function() {  
            this.hide(); 
                checkTodayDate();  
            }           
       }); 
    </script>
            </td>

But it is not working. I am curious that how to call the Calendar.setup function in Strut 2, and inside this function, there is a getObject("firstProcessDate") function, before this, the parameter is id or name, but in strut 2, there is no more id and name attributes, not sure what should I put inside.

Kindly advise.

Thanks a lot.

来源:https://stackoverflow.com/questions/18529078/call-javascript-function-in-strut-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!