Call JavaScript function in Strut 2

516 views Asked by At

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.

0

There are 0 answers