You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bharath Kumar <bh...@gmail.com> on 2009/06/13 09:47:32 UTC
Re: How to make readonly textfield in Struts 2.0.11.2
datetimepicker
Hi Guys :),
I too googled for many hours for this and didnt find any solution, so i
tried to do it myself and it worked out luckly :)
In my case i hve this datetimepicker in a TD
--------------------------------------------
<td onkeydown="Javascript:disablekeys();"
onmousedown="Javascript:disableControls()">
<sx:datetimepicker id="startDate" name="startDate"></sx:datetimepicker>
</td>
--------------------------------------------
This is the outerHTML of the datetimepicker when it renders
-----------------------------------------------------------
This is document.getElementById('startDate').outerHTML;
<input type=hidden value=2009-06-11 name="" dojoAttachPoint="valueNode">
<input value=6/11/2009 name="" __doClobber__="true"
dojoAttachPoint="inputNode">
<imag alt="Select a date" src="../images/dateIcon.gif" __doClobber__="true"
dojoAttachPoint="buttonNode" dojoAttachEvent="onclick:onIconClick">
---------------------------------------------------------------
So the solution i found out is
------------------------------
<script languae="javascript">
function disableControls(){
document.getElementById('startDate').childNodes[1].disable='true';
document.getElementById('startDate').childNodes[1].readOnly='readonly';
document.getElementById('startDate').childNodes[1].disable='';
}
function disableKeys(){
var keyCode=(document.all)?event.keyCode:e.which;
if(keyCode==9){
window.event.returnValue=true; //for allowing TAB
}else{
window.event.returnValue=false;
}
}
</script>
------------------------------
Note* -This will work unless and untill struts framework dont change the
order of the childNode.
Thanks
Bharath
Girish Naik wrote:
>
> Hi,
> I have used struts2-core-2.0.11.2 in My Application. And intend to use the
> Struts date time picker, but the text field is coming as an editable
> field.
> I want to make it as a readonly textbox. The funny thing is that the dojo
> is not ready to pass my id to the textbox. Only name is supplied to the
> text
> box.
>
> Any suggesstions on how to make the textbox non editable and only the icon
> clickable?
>
> Thanks in Advance.
>
>
> Regards,
> ---------------------------------------------------------
> Girish Naik
> Mobile:-+91-09740091638
> girish.naik@gmail.com
> Mitch
> Hedberg<http://www.brainyquote.com/quotes/authors/m/mitch_hedberg.html>
> - "My fake plants died because I did not pretend to water them."
>
>
--
View this message in context: http://www.nabble.com/How-to-make-readonly-textfield-in-Struts-2.0.11.2-datetimepicker-tp23784592p24010121.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org