You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sergey Livanov <se...@gmail.com> on 2005/07/18 21:36:27 UTC

submit form

How can I submit html:form by pressing CTRL+S ?


-- 
regards,
 Sergey                          mailto:sergey.livanov@gmail.com


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


Re[2]: submit form

Posted by Sergey Livanov <se...@gmail.com>.
Jeff,

The target is to define functional buttons because the staff used to such
combinations. There are not sumbit buttons in my application. It is
controlled by images. In whole it is necessary to create windows
interface which is usual with control buttons ( CTRL+S-save, CRTL-C -
copy, CTRL-F find e.t.c. ) for clients who used to old application.
Excuse me if something is not clear because I wanted to
underline  that I am not able to solve this problem by standard methods.
Your code is the best for me and can solve definitely my problem.
That's why, thank you very much.

Sergey,


> Mnemonics are onlly non-standard because most people don't use them!
> Our application uses them all over the place, and our users love us
> for it.  W3C accessibility guidelines strongly recommend heavy usage
> of mnemonics, also.

> That said, the standard modifier key for mnemonics is Alt, not Ctrl,
> and usually the mnemonic just puts focus on the element with the
> accessKey, it doesn't fire it.  I am also not sure what the accessKey
> on a form would do; it might just focus the first control in that form
> -- I doubt it would submit the form.  For a non-javascript approach,
> put the accessKey of 's' on your submit button:
>   <input type="submit" value="Submit" accessKey="s"/>

> Of course, this highlights a weakness of the <input type="submit"/> --
> there's no way to mark the 'S' as a mnemonic, because it's an
> attribute instead of element content.  If you only have one button in
> your form, you can try the following:

>   <button type="submit" accessKey="s"><u>S</u>ubmit</button>

> However, Internet Explorer's handling of the <BUTTON> element is
> broken; so if you want to perform any logic based on which of several
> buttons was pressed, you can't use <button type="submit"/>

> As Martin suggested, to get this to work with Ctrl+S instead of Alt+S,
> you'll need to use a JavaScript event handler.  I think you'll need to
> register the handler with the BODY element, though, not a BUTTON. We
> do something like the following:

> <script>
>   function init() {
>      body.onclick = doKey;
>   }

>   function doKey() {
>    var keyCode = (document.all) ? event.keyCode : event.which;
>     if (window.event.ctrlKey) {
>       if (keyCode == 83) {
>         // Ctrl+S was pressed
>       } else if (keyCode == 84) {
>         // Ctrl +T was pressed
>       } // and so on for all of our key handlers
>     }
>   }
> </script>

> On 7/18/05, Glen Mazza <gr...@verizon.net> wrote:
>> Still, mnemonics are non-standard for web applications, no?  This
>> doesn't seem right.
>> 
>> Glen
>> 
>> Niall Pemberton escribió:
>> > The short and not v.helpful response is you can't submit <html:form> - its
>> > just a JSP tag that renders a HTML <form> element and has nothing to do with
>> > the submit process.
>> >
>> > Some of the Struts tags have the "accesskey" attribute which defines a key
>> > that can be used with the accelerator key (usually ALT) to invoke a form
>> > control. So if you use the struts submit tag you could do something like...
>> >
>> >   <html:submit accesskey="S"/>
>> >
>> > Niall
>> >
>> > ----- Original Message -----
>> > From: "Sergey Livanov" <se...@gmail.com>
>> > Sent: Monday, July 18, 2005 8:36 PM
>> >
>> >
>> >
>> >>How can I submit html:form by pressing CTRL+S ?
>> >
>> >
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>>

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



-- 
regards,
 Sergey                          mailto:sergey.livanov@gmail.com


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


Re: submit form

Posted by Glen Mazza <gr...@verizon.net>.
Thanks for the information!

Glen


Jeff Beal wrote:
> Mnemonics are onlly non-standard because most people don't use them! 
> Our application uses them all over the place, and our users love us
> for it.  W3C accessibility guidelines strongly recommend heavy usage
> of mnemonics, also.
> 
> That said, the standard modifier key for mnemonics is Alt, not Ctrl,
> and usually the mnemonic just puts focus on the element with the
> accessKey, it doesn't fire it.  I am also not sure what the accessKey
> on a form would do; it might just focus the first control in that form
> -- I doubt it would submit the form.  For a non-javascript approach,
> put the accessKey of 's' on your submit button:
>   <input type="submit" value="Submit" accessKey="s"/>
> 
> Of course, this highlights a weakness of the <input type="submit"/> --
> there's no way to mark the 'S' as a mnemonic, because it's an
> attribute instead of element content.  If you only have one button in
> your form, you can try the following:
> 
>   <button type="submit" accessKey="s"><u>S</u>ubmit</button>
> 
> However, Internet Explorer's handling of the <BUTTON> element is
> broken; so if you want to perform any logic based on which of several
> buttons was pressed, you can't use <button type="submit"/>
> 
> As Martin suggested, to get this to work with Ctrl+S instead of Alt+S,
> you'll need to use a JavaScript event handler.  I think you'll need to
> register the handler with the BODY element, though, not a BUTTON.  We
> do something like the following:
> 
> <script>
>   function init() {
>      body.onclick = doKey;
>   }
> 
>   function doKey() {
>    var keyCode = (document.all) ? event.keyCode : event.which;
>     if (window.event.ctrlKey) {
>       if (keyCode == 83) {
>         // Ctrl+S was pressed
>       } else if (keyCode == 84) {
>         // Ctrl +T was pressed
>       } // and so on for all of our key handlers
>     }
>   }
> </script>
> 
> On 7/18/05, Glen Mazza <gr...@verizon.net> wrote:
> 
>>Still, mnemonics are non-standard for web applications, no?  This
>>doesn't seem right.
>>
>>Glen
>>
>>Niall Pemberton escribió:
>>
>>>The short and not v.helpful response is you can't submit <html:form> - its
>>>just a JSP tag that renders a HTML <form> element and has nothing to do with
>>>the submit process.
>>>
>>>Some of the Struts tags have the "accesskey" attribute which defines a key
>>>that can be used with the accelerator key (usually ALT) to invoke a form
>>>control. So if you use the struts submit tag you could do something like...
>>>
>>>  <html:submit accesskey="S"/>
>>>
>>>Niall
>>>
>>>----- Original Message -----
>>>From: "Sergey Livanov" <se...@gmail.com>
>>>Sent: Monday, July 18, 2005 8:36 PM
>>>
>>>
>>>
>>>
>>>>How can I submit html:form by pressing CTRL+S ?
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


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


Re: submit form

Posted by Jeff Beal <jb...@gmail.com>.
Mnemonics are onlly non-standard because most people don't use them! 
Our application uses them all over the place, and our users love us
for it.  W3C accessibility guidelines strongly recommend heavy usage
of mnemonics, also.

That said, the standard modifier key for mnemonics is Alt, not Ctrl,
and usually the mnemonic just puts focus on the element with the
accessKey, it doesn't fire it.  I am also not sure what the accessKey
on a form would do; it might just focus the first control in that form
-- I doubt it would submit the form.  For a non-javascript approach,
put the accessKey of 's' on your submit button:
  <input type="submit" value="Submit" accessKey="s"/>

Of course, this highlights a weakness of the <input type="submit"/> --
there's no way to mark the 'S' as a mnemonic, because it's an
attribute instead of element content.  If you only have one button in
your form, you can try the following:

  <button type="submit" accessKey="s"><u>S</u>ubmit</button>

However, Internet Explorer's handling of the <BUTTON> element is
broken; so if you want to perform any logic based on which of several
buttons was pressed, you can't use <button type="submit"/>

As Martin suggested, to get this to work with Ctrl+S instead of Alt+S,
you'll need to use a JavaScript event handler.  I think you'll need to
register the handler with the BODY element, though, not a BUTTON.  We
do something like the following:

<script>
  function init() {
     body.onclick = doKey;
  }

  function doKey() {
   var keyCode = (document.all) ? event.keyCode : event.which;
    if (window.event.ctrlKey) {
      if (keyCode == 83) {
        // Ctrl+S was pressed
      } else if (keyCode == 84) {
        // Ctrl +T was pressed
      } // and so on for all of our key handlers
    }
  }
</script>

On 7/18/05, Glen Mazza <gr...@verizon.net> wrote:
> Still, mnemonics are non-standard for web applications, no?  This
> doesn't seem right.
> 
> Glen
> 
> Niall Pemberton escribió:
> > The short and not v.helpful response is you can't submit <html:form> - its
> > just a JSP tag that renders a HTML <form> element and has nothing to do with
> > the submit process.
> >
> > Some of the Struts tags have the "accesskey" attribute which defines a key
> > that can be used with the accelerator key (usually ALT) to invoke a form
> > control. So if you use the struts submit tag you could do something like...
> >
> >   <html:submit accesskey="S"/>
> >
> > Niall
> >
> > ----- Original Message -----
> > From: "Sergey Livanov" <se...@gmail.com>
> > Sent: Monday, July 18, 2005 8:36 PM
> >
> >
> >
> >>How can I submit html:form by pressing CTRL+S ?
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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


Re: submit form

Posted by Glen Mazza <gr...@verizon.net>.
Still, mnemonics are non-standard for web applications, no?  This 
doesn't seem right.

Glen

Niall Pemberton escribió:
> The short and not v.helpful response is you can't submit <html:form> - its
> just a JSP tag that renders a HTML <form> element and has nothing to do with
> the submit process.
> 
> Some of the Struts tags have the "accesskey" attribute which defines a key
> that can be used with the accelerator key (usually ALT) to invoke a form
> control. So if you use the struts submit tag you could do something like...
> 
>   <html:submit accesskey="S"/>
> 
> Niall
> 
> ----- Original Message ----- 
> From: "Sergey Livanov" <se...@gmail.com>
> Sent: Monday, July 18, 2005 8:36 PM
> 
> 
> 
>>How can I submit html:form by pressing CTRL+S ?
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


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


Re: submit form

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
The short and not v.helpful response is you can't submit <html:form> - its
just a JSP tag that renders a HTML <form> element and has nothing to do with
the submit process.

Some of the Struts tags have the "accesskey" attribute which defines a key
that can be used with the accelerator key (usually ALT) to invoke a form
control. So if you use the struts submit tag you could do something like...

  <html:submit accesskey="S"/>

Niall

----- Original Message ----- 
From: "Sergey Livanov" <se...@gmail.com>
Sent: Monday, July 18, 2005 8:36 PM


> How can I submit html:form by pressing CTRL+S ?



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


Re: submit form

Posted by Martin Gainty <mg...@hotmail.com>.
Sergey try
<html:button property="submit" text="submit" value="submit" onkeydown = 
"javascript:testKeyCode(evt)" onclick = "javascript:testKeyCode(evt)" />

<head>
<script language="javascript">
testKeyCode(evt)
{
evt.charCode ? evt.charCode : evt.which;
if (evt.charCode=='S')
{
if (evt.ctrlKey)
{
document.formName.action="FullyQualifiedLocationOfPlaceToHandleQueryString";
document.formName.submit();
}
}
}

Martin-
----- Original Message ----- 
From: "Sergey Livanov" <se...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Monday, July 18, 2005 3:36 PM
Subject: submit form


>
> How can I submit html:form by pressing CTRL+S ?
>
>
> -- 
> regards,
> Sergey                          mailto:sergey.livanov@gmail.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 

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