aspose file tools
The moose likes JSF and the fly likes How to specify default button in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "How to specify default button in JSF" Watch "How to specify default button in JSF" New topic
Author

How to specify default button in JSF

Zane Wlight
Greenhorn

Joined: Aug 07, 2008
Posts: 5
hi all,

The problem is I got two submit buttons in a page, one for saving form, one for searching. The save button at the top and search one at the bottom. You know, the default would be save button when I press "Enter" key. Now if I want to trigger search button after the event, What should I do?

Thank you in advance,
Zane
[ October 14, 2008: Message edited by: Zane ]

good is good
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

We faced similar problem in our project. We also had two buttons one for continue and other for 'Go BAck'. We wrote javascript to trap the pressing of enter key and submitted the form on the event.


My Blog SCJP 5 SCWCD 5
Zane Wlight
Greenhorn

Joined: Aug 07, 2008
Posts: 5
Originally posted by Himanshu Gupta:
We faced similar problem in our project. We also had two buttons one for continue and other for 'Go BAck'. We wrote javascript to trap the pressing of enter key and submitted the form on the event.


Thank you for your advice, Himanshu. But, You know, JS is not that graceful in JSF page. Any simple solution?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Zane",
Please check your private messages.
-DOM
Zane Wlight
Greenhorn

Joined: Aug 07, 2008
Posts: 5
Originally posted by David O'Meara:
"Zane",
Please check your private messages.
-DOM


Sorry about that. have corrected it.
Abdul Shams
Greenhorn

Joined: Oct 12, 2008
Posts: 6
Try putting each button in an h:form

put the button you want to be default in the same form as the fields you have and put the other button in another h:form.

Hope it helps
[ October 14, 2008: Message edited by: Abdul Shams ]
Zane Wlight
Greenhorn

Joined: Aug 07, 2008
Posts: 5
Originally posted by Abdul Shams:
Try putting each button in an h:form

put the button you want to be default in the same form as the fields you have and put the other button in another h:form.

Hope it helps

[ October 14, 2008: Message edited by: Abdul Shams ]


Thank you Abdul, but when I do it like this:

<h:form>
<h:form>
save button
</h:form>
<h:form>
search button
</h:form>
</h:form>

the save button wouldn't work. Any idea?
[ October 14, 2008: Message edited by: Zane Wlight ]
Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Check out

http://www.jsftutorials.net/defaultActionTag.html
Zane Wlight
Greenhorn

Joined: Aug 07, 2008
Posts: 5
Originally posted by Abiodun Adisa:
Check out

http://www.jsftutorials.net/defaultActionTag.html


Thank you very much Abiodun, it really helps
Srikanth Madasu
Ranch Hand

Joined: Sep 10, 2008
Posts: 48

I think I have a simplest solution.

Use <h:command button value="XXX" action="ssss" type="submit"/>

type=submit attribute will take care of it............

Hope this helps

-Srik


If it's easy.. then everybody would do it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to specify default button in JSF
 
Similar Threads
NX: Does this mean I MUST use multiple DB instances?
Insert VALUE from JTEXTFIELD to DATABASE
Post executed twice when user clicks button to submit details
GUI design in SCJD book
how to disable the "Save As" function