As a simple solution, why not just modify the form tag template and if the
focusElement parameter is set, include a simple javascript block at the
close of the form to set the focus. Just keep in mind that if there are two
forms on a page and both have the focusElement parameter set only the last
will be relevant.
The advantage being you can use javascript code to match your environment
jQuery, Dojo, pure javascript, etc.
Z.
>
> I recommend attaching the focus to the relevant form element purely
> using Javascript,
>
> ie, including in you JSP :
> <script type="test/javascript">
> window.onload = function() {
> document.getElementById('yourInpudId').focus();
> }
> </script>
>
> That way you have a pure javascript implementation, and you can push
> that code to the relevant JSP without having to mess up with your template.
>
> My second recommendation is to use a Javascript framework, instead of
> the plain and ugly javascript as up there (since the example above will
> break if you want to attach more than one thing to the onload).
> So rewritten with jquery ( http://jquery.com/ )
> <script type="test/javascript">
> $(document).ready(function() {
> $('yourInpudId').focus();
> });
> </script>
>
> But the idea is the same in both case, do the focus purely in Javascript.
>
> Denis.
>
> Le 2010-05-12 14:53, Emi Lu a écrit :
>> >
>>>> >>> By using tiles,<body> is in global_layout.jsp page, for decedent
>>>> >>> pages,
>>>> >>> I will not be able to set body onload.
>>>> >>>
>>> >>
>>> >> Admittedly I don't know tiles, but Sitemesh will copy the body onLoad
>>> >> and
>>> >> unload functions to the decorating page and I would be suprised if Tiles
>>> >> didn't support this as well.
>> >
>> > For the global page.jsp: if body onload is set, it's for all
>> > decedents; no, I do not want that.
>> >
>> > (1) Do not bother to create several parents layout files
>> > (2) Only one file needs default focus;
>> > Other hundreds of .jsp foucs will be set differently or
>> > not set at all
>> >
>> > So, I do need s:form to support focus.
>> >
>> > --
>> > Lu Ying
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [email protected]
>> > For additional commands, e-mail: [email protected]
>> >
>> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>