Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 Datetime Picker focus is not set using javascript

 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In my Struts2 application, I used Datetime picker, while entering fields of a form, focus need to be set when a user performs an action for date fields.

So, I need to set the focus using javascript in one or more date fields in the forms.

While setting focus to these date fields,it does not set the focus on the fields

this is the code fragment that i used in my application


sales.jsp:-

<s:datetimepicker id="shipdate%{#statusB.index}"
name="salesshipmentvoList[%{#statusB.index}].shipdate"
theme="simple" value="%{#B.shipdate}" required="true"
cssClass="LoginTextBox"></s:datetimepicker>


java application code:-

public String salesShipment(){

setFocus("shipdate");
setFocusIndex("shipdate");

}


<script type="text/javascript">

function focusNextField(focus,focusIndex){
//focusIndex is the index of a list element of the date field
document.getElementById("shipdate"+focusIndex).focus();
}

</script>

the javascript fucntion is called as follows in sales.jsp


<body onload=focusNextField('<s:property value="focus"/>','<s:property value="focusIndex"/>')>

the above code had no effect on focusing the date field 'shipdate0' or 'shipdate1' and so on
 
candid java
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the Better way to Resolve your problem refer this link http://candidjava.com/struts-tutorail
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic