|
View:
New views
14 Messages
—
Rating Filter:
Alert me
|
|
|
Form Submit On EnterIf a text field has focus, the form will submit upon hitting the enter (or return) key. This does not seem to work in facelets. Is this a bug in Facelets and/or should we write some JS? dan storm ~ web developer ~ dstorm@... ~ w: 206.266.0292 ~ c: 425.503.9580 |
||||
|
|
Re: Form Submit On EnterWhen you submit without clicking a button, the form is sent to the server by the
browser but no HTTP parameter is passed to indicate what button was clicked (because none was) or it is passed with a blank value (I can't recall). Therefore, I suppose JSF/Facelets is unable to identify what button was activated and what action should be triggered. In practice, it would be nice if JSF/Facelets handled this behaviour properly and assumed that no HTTP param for the button means to behave as if the default button had been clicked. Quoting "Storm, Dan" <dstorm@...>: > If a text field has focus, the form will submit upon hitting the enter (or > return) key. This does not seem to work in facelets. Is this a bug in > Facelets and/or should we write some JS? > > dan storm ~ web developer ~ dstorm@... ~ w: 206.266.0292 ~ c: > 425.503.9580 > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
||||
|
|
Re: Form Submit On EnterYep, exactly - the form can't figure out what button was pressed.
There's no magic way for JSF to automatically know what is meant by the "default button". ADF adds a "defaultCommand" property to af:form, so you can have: <af:form defaultCommand="okButton"> ... <h:commandButton id="okButton" value="OK"/> ... </af:form> ... and it does the Javascript magic needed to map Enter to that button. -- Adam bruno@... wrote: > When you submit without clicking a button, the form is sent to the server by the > browser but no HTTP parameter is passed to indicate what button was clicked > (because none was) or it is passed with a blank value (I can't recall). > Therefore, I suppose JSF/Facelets is unable to identify what button was > activated and what action should be triggered. In practice, it would be nice if > JSF/Facelets handled this behaviour properly and assumed that no HTTP param for > the button means to behave as if the default button had been clicked. > > Quoting "Storm, Dan" <dstorm@...>: > >> If a text field has focus, the form will submit upon hitting the enter (or >> return) key. This does not seem to work in facelets. Is this a bug in >> Facelets and/or should we write some JS? >> >> dan storm ~ web developer ~ dstorm@... ~ w: 206.266.0292 ~ c: >> 425.503.9580 >> >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
||||
|
|
Re: Form Submit On EnterIn practice, you could consider that on a form that has only one button, this is
the default. Otherwise, yes, you would need to specify it. However, "Javascript magic" is not necessarilly the way to go. The reason for this is that JS is not accessibility friendly. Also, if you have a form with a lot of text fields (or fields that can have the focus), it means you have to assign a JS listener to all of them. This could get messy. We solved that problem in a previous job, in a home brewed UI framework, by having the equivalent of the ADF defaultCommand attribute on the form rendering tag and storing that value in the HTTPSession. When receiving the form back, the framework would attempt to identify the button clicked and if no value was available would get the default value out of HTTPSession. If you don't want to use HTTPSession, another JS-free solution is to add a hidden field with a well-known ID to your form when rendering it that contains the ID of the default button. I am new to JSF so I don't know what you would override to implement this behaviour but I suspect providing an alternate form rendering object would be a good start. I would be nice of JSF/Facelets provided that out of the box though :-) Bruno Quoting Adam Winer <adam.winer@...>: > Yep, exactly - the form can't figure out what button was pressed. > There's no magic way for JSF to automatically know what is meant > by the "default button". > > ADF adds a "defaultCommand" property to af:form, so you can have: > > > <af:form defaultCommand="okButton"> > ... > <h:commandButton id="okButton" value="OK"/> > ... > </af:form> > > ... and it does the Javascript magic needed to map Enter > to that button. > > -- Adam > > > bruno@... wrote: > > When you submit without clicking a button, the form is sent to the server > by the > > browser but no HTTP parameter is passed to indicate what button was clicked > > (because none was) or it is passed with a blank value (I can't recall). > > Therefore, I suppose JSF/Facelets is unable to identify what button was > > activated and what action should be triggered. In practice, it would be > nice if > > JSF/Facelets handled this behaviour properly and assumed that no HTTP param > for > > the button means to behave as if the default button had been clicked. > > > > Quoting "Storm, Dan" <dstorm@...>: > > > >> If a text field has focus, the form will submit upon hitting the enter (or > >> return) key. This does not seem to work in facelets. Is this a bug in > >> Facelets and/or should we write some JS? > >> > >> dan storm ~ web developer ~ dstorm@... ~ w: 206.266.0292 ~ c: > >> 425.503.9580 > >> > >> > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
||||
|
|
|
||||
| I can't think of anything Facelets related that would cause that-- usually that behavior only works if there's an input type of submit or image within the form. | |
|
If a text field has focus, the form will submit upon hitting the enter (or return) key. This does not seem to work in facelets. Is this a bug in Facelets and/or should we write some JS? dan storm ~ web developer ~ dstorm@... ~ w: 206.266.0292 ~ c: 425.503.9580 | |
| Free embeddable forum powered by Nabble | Forum Help |