File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes How to Call the Backing Bean Method from javascript in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to Call the Backing Bean Method from javascript in JSF" Watch "How to Call the Backing Bean Method from javascript in JSF" New topic
Author

How to Call the Backing Bean Method from javascript in JSF

Balaji Soundarajan
Ranch Hand

Joined: Jan 23, 2009
Posts: 59
I need to call the Backing bean method from javascript. I have a command button in .xhtml page from there i need to call the javascript method, in the javascript i need to validate the textfield which is in the same page. Depands on the validation result i have to call the backing bean method.

Thanks in Advance.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Assuming that you're calling Javascript during the onclick of the button or onsubmit of the form, just let the function return true or false depending on the validation outcome. If the onclick or onsubmit returns false, then the initiating click or submit will be blocked and the page will stay the same.
Balaji Soundarajan
Ranch Hand

Joined: Jan 23, 2009
Posts: 59
Thanks for the reply.
If i called the javascript function from the onclick or onsubmit method, from there how can i access the backing bean method. Please tell me.
suresh nerella
Greenhorn

Joined: May 08, 2009
Posts: 4
even javascript returns false, backing bean method is executing.... I have code something like below.....
even i am returning false.... after clicking on popup...... the control is still going for backing bean method and giving exception...

function check() {

if(previouslySelectedRow=='null'){

alert('Please Select a row from the table' );
return false;
}

}

<h:commandButton id="editGroup" value="Edit" type="submit" styleClass="submit-button" onclick="check()" action="#{mangUserBackBean.editGroup}"/>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Call the Backing Bean Method from javascript in JSF