You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Vivian, Nigel (N.)" <nv...@ford.com> on 2003/05/28 11:08:35 UTC

cancel button problem

Hi all

I've got a webapp working with struts 1.0.2 and tiles, but there is now a requirement to make the enter button on the keyboard work.

My problem is that my pages have the following code on them which creates two submit button objects.  The user types an entry into some text fields on the form and then presses enter.  The behaviour at the moment is that either nothing happens or the first button defined on the form in this case the cancel button is activated.

My question is how can I make the Enter button be the default on an enter keyboard press?  So far I have tried adding tabindex="0" to the code for the cancel button with no success.

    <tr> 
      <td colspan="3" width="41%" align="right"><html:cancel styleClass="formButton" value="Cancel" tabindex="0"/>&nbsp;<html:submit styleClass="formButton" property="submit" value="Enter" /></td>
      <td width="41%">&nbsp;</td>
      <td width="3">&nbsp;</td>
    </tr>

which generates the following HTML in the browser

    <tr> 
      <td colspan="3" width="41%" align="right"><input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" class="formButton">&nbsp;<input type="submit" name="submit" value="Enter" class="formButton"></td>
      <td width="41%">&nbsp;</td>
	<td width="3">&nbsp;</td>
    </tr>

Thanks

Nigel Vivian

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


RE: cancel button problem

Posted by Steve Raeburn <st...@ninsky.com>.
And if you're not using javascript?

Steve

> -----Original Message-----
> From: Tin Pham [mailto:ttpham3@learn.senecac.on.ca]
> Sent: May 29, 2003 7:36 PM
> To: struts-user@jakarta.apache.org
> Subject: Re: cancel button problem
> 
> 
> Why make the cancel a submit button?
> 
> If you are not collecting the data, then use javascript to send 
> the user to the previous page or your cancel action.


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


Re: cancel button problem

Posted by Tin Pham <tt...@learn.senecac.on.ca>.
Why make the cancel a submit button?

If you are not collecting the data, then use javascript to send the user to
the previous page or your cancel action.



"Vivian, Nigel (N.)" <nv...@ford.com> wrote in message
news:37CBEDEFB4B2D51189EA0002B362AF6E05B5CC7B@war00309.warley.ford.com...
> Hi all
>
> I've got a webapp working with struts 1.0.2 and tiles, but there is now a
requirement to make the enter button on the keyboard work.
>
> My problem is that my pages have the following code on them which creates
two submit button objects.  The user types an entry into some text fields on
the form and then presses enter.  The behaviour at the moment is that either
nothing happens or the first button defined on the form in this case the
cancel button is activated.
>
> My question is how can I make the Enter button be the default on an enter
keyboard press?  So far I have tried adding tabindex="0" to the code for the
cancel button with no success.
>
>     <tr>
>       <td colspan="3" width="41%" align="right"><html:cancel
styleClass="formButton" value="Cancel" tabindex="0"/>&nbsp;<html:submit
styleClass="formButton" property="submit" value="Enter" /></td>
>       <td width="41%">&nbsp;</td>
>       <td width="3">&nbsp;</td>
>     </tr>
>
> which generates the following HTML in the browser
>
>     <tr>
>       <td colspan="3" width="41%" align="right"><input type="submit"
name="org.apache.struts.taglib.html.CANCEL" value="Cancel"
class="formButton">&nbsp;<input type="submit" name="submit" value="Enter"
class="formButton"></td>
>       <td width="41%">&nbsp;</td>
> <td width="3">&nbsp;</td>
>     </tr>
>
> Thanks
>
> Nigel Vivian




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


Re: cancel button problem

Posted by Affan Qureshi <qu...@etilize.com>.
I have seen this one before as well. But I dont think it is possible in
plain HTML. So the best you could do in HTML is to place the default button
as the first Submit button on the form.
Or if you want ot use JavaScript then u might want to make use of new
key-capture events of JS. But i think you will then have to make all your
submissions thru links.

Affan

----- Original Message -----
From: "Vivian, Nigel (N.)" <nv...@ford.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, May 28, 2003 2:08 PM
Subject: cancel button problem


> Hi all
>
> I've got a webapp working with struts 1.0.2 and tiles, but there is now a
requirement to make the enter button on the keyboard work.
>
> My problem is that my pages have the following code on them which creates
two submit button objects.  The user types an entry into some text fields on
the form and then presses enter.  The behaviour at the moment is that either
nothing happens or the first button defined on the form in this case the
cancel button is activated.
>
> My question is how can I make the Enter button be the default on an enter
keyboard press?  So far I have tried adding tabindex="0" to the code for the
cancel button with no success.
>
>     <tr>
>       <td colspan="3" width="41%" align="right"><html:cancel
styleClass="formButton" value="Cancel" tabindex="0"/>&nbsp;<html:submit
styleClass="formButton" property="submit" value="Enter" /></td>
>       <td width="41%">&nbsp;</td>
>       <td width="3">&nbsp;</td>
>     </tr>
>
> which generates the following HTML in the browser
>
>     <tr>
>       <td colspan="3" width="41%" align="right"><input type="submit"
name="org.apache.struts.taglib.html.CANCEL" value="Cancel"
class="formButton">&nbsp;<input type="submit" name="submit" value="Enter"
class="formButton"></td>
>       <td width="41%">&nbsp;</td>
> <td width="3">&nbsp;</td>
>     </tr>
>
> Thanks
>
> Nigel Vivian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


AW: cancel button problem

Posted by Roland Berger <ro...@aloba.ch>.
Is it an option to swap cancel and enter button? Then you would have the
behaviour you like.
Roland

-----Ursprüngliche Nachricht-----
Von: Vivian, Nigel (N.) [mailto:nvivian1@ford.com]
Gesendet: Mittwoch, 28. Mai 2003 11:09
An: 'struts-user@jakarta.apache.org'
Betreff: cancel button problem


Hi all

I've got a webapp working with struts 1.0.2 and tiles, but there is now a
requirement to make the enter button on the keyboard work.

My problem is that my pages have the following code on them which creates
two submit button objects.  The user types an entry into some text fields on
the form and then presses enter.  The behaviour at the moment is that either
nothing happens or the first button defined on the form in this case the
cancel button is activated.

My question is how can I make the Enter button be the default on an enter
keyboard press?  So far I have tried adding tabindex="0" to the code for the
cancel button with no success.

    <tr>
      <td colspan="3" width="41%" align="right"><html:cancel
styleClass="formButton" value="Cancel" tabindex="0"/>&nbsp;<html:submit
styleClass="formButton" property="submit" value="Enter" /></td>
      <td width="41%">&nbsp;</td>
      <td width="3">&nbsp;</td>
    </tr>

which generates the following HTML in the browser

    <tr>
      <td colspan="3" width="41%" align="right"><input type="submit"
name="org.apache.struts.taglib.html.CANCEL" value="Cancel"
class="formButton">&nbsp;<input type="submit" name="submit" value="Enter"
class="formButton"></td>
      <td width="41%">&nbsp;</td>
	<td width="3">&nbsp;</td>
    </tr>

Thanks

Nigel Vivian

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



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