Search code examples
javajavascriptjspcalendarstripes

How to detect when a day in a jsp Calendar is clicked (selected) and do some action?


I was searching for a way to update some variable in the Stripes Action (say it selectedDate) when a user clicks a specific date(lets say 11/15/2011) I wanted selectedDate to be updated (may be by binding the field with the selected day) and the page to be refreshed or displayed again. I might consider using ajax (instead of refreshing the page) for this purpose in the future.

If possible, I would like to create a method (that may return a Resoulution) in the ActionBean to display the page again.

FYI: I couldn't decide between <calendar:calendars> and <tags:calendarWidget>. I will consider the simplest one for now. Give me your recommendation.


Solution

  • If your selectedDate field is on an non Ajax HTML form, then the Stripes Action is only executed when you submit/post the form to the server. If you want this form submit to happen automatically when the selectedDate field is changed, you need to add some Javascript code to your page. For example:

    <stripes:text name="selectedDate" onchange="this.form.submit()"/>
    

    In case you use JQuery you might want to checkout:

    How to convert onchange="this.form.submit()" to jquery