• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts2 Datetime Picker focus is not set using javascript

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the Better way to Resolve your problem refer this link http://candidjava.com/struts-tutorail
reply
    Bookmark Topic Watch Topic
  • New Topic