Re: how to set default focus field in s:form ?

2010-05-13 Thread Zoran Avtarovski
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: user-unsubscr...@struts.apache.org
  For additional commands, e-mail: user-h...@struts.apache.org
 
 
 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org
 



Re: how to set default focus field in s:form ?

2010-05-12 Thread RogerV



Luis Martín Canaval Sánchez wrote:
 
 I would like to know that aswell, so far I have been using javascript with
 jquery that is the lib that I use
 
 
 // somewhere inside the initial function
 $(input:text:visible:first).focus();
 // or
 $(#othercontol).focus();
 // if the first control is not a textbox.
 
 On Mon, May 10, 2010 at 15:52, Emi Lu em...@encs.concordia.ca wrote:
 
 Good afternoon,

 Struts1, I use html:form focus=field_name to focus a default field.

 For *struts2.1.8.1*, may I know the grammar of setting focus value for
 s:form please?

 s:form focus=field_name  does not work.
 
 

I just use body onload=xx e.g;

body onLoad=document.login.j_username.focus()
form action=j_spring_security_check method=post name=login


label for=j_usernameUsername/label
input type=text name=j_username id=j_username value=s:property
value=%{#session.SPRING_SECURITY_LAST_USERNAME}//

-- 
View this message in context: 
http://old.nabble.com/how-to-set-default-focus-field-in-%3Cs%3Aform%3E---tp28516814p28532441.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: how to set default focus field in s:form ?

2010-05-12 Thread Emi Lu

Struts1, I usehtml:form focus=field_name to focus a default field.

For *struts2.1.8.1*, may I know the grammar of setting focus value for
s:form please?

s:form focus=field_name  does not work.





I just usebody onload=xx  e.g;

body onLoad=document.login.j_username.focus()
form action=j_spring_security_check method=post name=login


label for=j_usernameUsername/label
input type=text name=j_username id=j_username value=s:property
value=%{#session.SPRING_SECURITY_LAST_USERNAME}//


I would prefer that s:form supports focus.

By using tiles, body is in global_layout.jsp page, for decedent pages, 
I will not be able to set body onload.


Why s:form does not support focus? This is strange :-(

--
Lu Ying




-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: how to set default focus field in s:form ?

2010-05-12 Thread Roger

 
 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.

Regards 

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: how to set default focus field in s:form ?

2010-05-12 Thread Emi Lu



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: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: how to set default focus field in s:form ?

2010-05-12 Thread Denis Cabasson
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: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org





-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: how to set default focus field in s:form ?

2010-05-11 Thread Alex Rodriguez Lopez

Hi,

I use to do this manually with javascript, didn't know it was part of 
s:form tag. So today I decided to give it a try but it is not working 
for me... how does this works? Does it need some plugin or additional 
config to make it work? Is it compatible with jquery, which I include in 
every page in a tile?


BTW, even if this is a little off-topic, can somebody explain me the 
advantages of using jquery plugin vs. jquery used normally? And Dojo, 
which is used by struts ajax tags? I'm a little bit confused over this 
things, maybe I'll just forget js / ajax integration within s2 and just 
use jquery the normal way, as I recall users of this list suggesting 
preciselly this.



Hi Lu,
does this help http://struts.apache.org/2.1.8.1/docs/form.html ?
Search for  focusElement in this text.

Best greetings,
Paweł Wielgus.


2010/5/10 Emi Luem...@encs.concordia.ca:

Good afternoon,

Struts1, I usehtml:form focus=field_name to focus a default field.

For *struts2.1.8.1*, may I know the grammar of setting focus value for
s:form please?

s:form focus=field_name  does not work.

Thanks a lot!

--
Lu Ying







-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: how to set default focus field in s:form ?

2010-05-11 Thread Emi Lu

Good morning List,


I use to do this manually with javascript, didn't know it was part of
s:form tag. So today I decided to give it a try but it is not working
for me... how does this works? Does it need some plugin or additional
config to make it work?


I tried focusElement as shown in id of element that will receive the 
focus when page loads.


No luck; it doesn't work for me either :-(

s:form theme=simple focusElement=col1... 
   s:textfield name=col1 id=col1 /
... ...
/s:form

col1 is not focused.

Any clue and comments how s:form setups focus as default? struts1 
html:form just saying focus, why s:form does not support this?


Thank you,
--
Lu Ying








Hi Lu,
does this help http://struts.apache.org/2.1.8.1/docs/form.html ?
Search for focusElement in this text.

Best greetings,
Paweł Wielgus.


2010/5/10 Emi Luem...@encs.concordia.ca:

Good afternoon,

Struts1, I usehtml:form focus=field_name to focus a default field.

For *struts2.1.8.1*, may I know the grammar of setting focus value for
s:form please?

s:form focus=field_name does not work.

Thanks a lot!

--
Lu Ying







-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



how to set default focus field in s:form ?

2010-05-10 Thread Emi Lu

Good afternoon,

Struts1, I use html:form focus=field_name to focus a default field.

For *struts2.1.8.1*, may I know the grammar of setting focus value for 
s:form please?


s:form focus=field_name  does not work.

Thanks a lot!

--
Lu Ying







-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: how to set default focus field in s:form ?

2010-05-10 Thread Paweł Wielgus
Hi Lu,
does this help http://struts.apache.org/2.1.8.1/docs/form.html ?
Search for  focusElement in this text.

Best greetings,
Paweł Wielgus.


2010/5/10 Emi Lu em...@encs.concordia.ca:
 Good afternoon,

 Struts1, I use html:form focus=field_name to focus a default field.

 For *struts2.1.8.1*, may I know the grammar of setting focus value for
 s:form please?

 s:form focus=field_name  does not work.

 Thanks a lot!

 --
 Lu Ying







 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: how to set default focus field in s:form ?

2010-05-10 Thread Luis Martín Canaval Sánchez
I would like to know that aswell, so far I have been using javascript with
jquery that is the lib that I use


// somewhere inside the initial function
$(input:text:visible:first).focus();
// or
$(#othercontol).focus();
// if the first control is not a textbox.

On Mon, May 10, 2010 at 15:52, Emi Lu em...@encs.concordia.ca wrote:

 Good afternoon,

 Struts1, I use html:form focus=field_name to focus a default field.

 For *struts2.1.8.1*, may I know the grammar of setting focus value for
 s:form please?

 s:form focus=field_name  does not work.

 Thanks a lot!

 --
 Lu Ying







 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




-- 
Ing. Luis Martín Canaval Sánchez
Keep it small and simple.