Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to specify default button in JSF

 
Zane Wlight
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Zane Wlight
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Abdul Shams
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 495
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out

http://www.jsftutorials.net/defaultActionTag.html
 
Zane Wlight
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
Eclipse IDE Hibernate Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Enthu Tarun Singh
Greenhorn
Posts: 2
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assign id to your submit button and use java script method focus() which will be called at the time of page load. When you are pressing enter key then send that focus to search button. Thats all you have done..
Please let me know if you have done with your requirement..
Thanks
 
Parvathi Raju
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 solutions.

1)you can use 2 separate forms for button

2)Use command button for which action you want to fire when pressing enter key ,and use command link for another action.by default comman button action is fired when you are pressing enter key
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic