• Post Reply Bookmark Topic Watch Topic
  • New Topic

Button in JSF

 
Carlos Mendoza
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Do you know if it is possible to don´t submit when i click on a JavaServerFaces component button?
thanks in advance.
 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. You can do this using javascript. Its same like a submit button.
For example:
If you want some confirm messgae on click of a button and if user clicks cancel you dont want to submit the page, then you can have something like :

<h:commandButton onclick="return finishAction()" value="Click Me" action="#{MyActionBean.actionMethod}" >
</h:commandButton>


and javascript function finishAction() will be something like below:

function finishAction(){
if (!confirm('Are you sure you want to submit page?'))
return false;
else
return true;
}


 
Carlos Mendoza
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Smitha!
Your information was so useful!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!