Please describe how I can return the boolean value from the js function below to the caller in the onclick event handler. It's not working this way.
related thread: https://community.jboss.org/message/555465#555465
<script type="text/javascript">
function showWarning() {
var myVar;
var callback = function(result) {
if (result == null || result == '') {
myVar = confirm('No interchange programs were assigned to rate category. Are you sure you want to proceed with saving?');
alert('myVar = '+myVar);
//return myVar; <-- is it legal to return from here and will it get back to the caller in the onclick handler?
}
else {
myVar = true;
}
};
Seam.Remoting.getContext().setConversationId( #{conversation.id} );
Seam.Component.getInstance("merchantBillingGroupEditorUI").getSelectedRateCategory(callback);
alert('myVar 2nd time = '+myVar);
return myVar;
/*var result = Seam.Component.getInstance("merchantBillingGroupEditorUI").getSelectedRateCategory();
alert('result = '+result);
if (result == null || result == '') {
return confirm('No interchange programs were assigned to rate category. Are you sure you want to proceed with saving?');
}*/
}<a4j:commandLink styleClass="widget_button"
rendered="#{pageaction != 'view'}"
style="float:right"
action="#{merchantBillingGroupEditorUI.submit}"
onclick="if (!showWarning()) return false;">
<span><h:outputText value="Finish" /></span>
<j4j:idProxy id="nextButton" />
</a4j:commandLink>