he action parameter will call the method you want as soon as the page loads. It is a dangerous attribute, one that will be pointed out to you if you'll go through Salesforce's security review process. The called action can manipulate database values for example (whereas the OrderPadController constructor can't) and the philosophy is that act of visiting a page shouldn't have any side effect.
In your specific scenario you can do it even without any Apex code at all:
<apex:page standardController="Account" extensions="OrderPadController">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
window.$j = jQuery.noConflict();
$j( document ).ready(function() {
OrderPadController.openPage(function(result, event){
console.log(result);
window.open(result,"_self");
});
});
</script>
</apex:page>
public class OrderPadController {
//
@remoteAction
public PageReference openPage() {
PageReference newpage = NEW Pagereference('/apex' + '/pagetoopen' + '?aid=' + a.id);
openorderpadembed.setRedirect(false);
return openorderpadembed;
}
}
Want to become a Salesforce Expert? join Salesforce certification now!