Good day,
The following is my jsp code, I use this to create a datepicker text box :
<head>
<link rel="stylesheet" href="scripts/jquery-ui.css" />
<script src="scripts/jquery-1.9.1.js"></script>
<script src="scripts/jquery-ui.js"></script>
<script type="text/javascript">
$(function(){
//$( "#datepicker" ).datepicker();
$( "#datepicker" ).datepicker({
showOn: "button",
buttonImage: "images/icon_calendar.gif",
buttonImageOnly: true
});
});
</script>
</head>
//some code here
<td class="value"><html:text property="campaignurl" size="50" maxlength="1000" /></td>
<td width="40%">
<input type="text" id="datepicker" name="periodFrom" />
</td>
The following is my action.java code (code behind) :
System.out.println(thisForm.getPeriodFrom()); //this is working fine
thisForm.setCampaignurl("this is url"); // this is working fine, brower display "this is url" in textbox campaignurl
thisForm.setPeriodFrom("09/05/2013"); // this display blank in browser.
Because I want to user JavaScript/Jquery to create the datepicker, thus I change the textbox into <input/>
instead of <html:text />
.
However, I can set value for <html:text />
which is the campaignurl
easily, but I cant set value for the <input/>
textbox which is periodForm
.
Suppose this is simple to done, however I cant find solution after I spending long time on it.
Kindly advise.
With struts-bean.tld
:
<input type="text"
id="datepicker"
name="periodFrom"
value="<bean:write name="yourForm" property="periodFrom"/>" />
See more in Package org.apache.struts.taglib.bean
With JSTL:
<input type="text"
id="datepicker"
name="periodFrom"
value="<c:out value="${yourForm.periodFrom}"/>" />
See more in JSTL Core <c:out>
Tag