Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@remoteactionとreRenderでエラーが発生する条件の検証
<apex:page controller="RemoteActionReRenderController" showHeader="true" sidebar="false" >
<body>
<apex:form id="form">
<apex:commandButton value=" Go!! " action="{!doClick}" reRender="form"/>
<c:RemoteActionReRender rendered="{!isComponentView}"/>
</apex:form>
<script>
function getAccount() {
try {
{!$RemoteAction.RemoteActionReRenderController.getAccount}(function(results, event){
if(event.status) {
alert('★Page:OK★');
}
});
} catch (e) {
alert(e);
}
return false;
}
//getAccount();
</script>
</body>
</apex:page>
public class RemoteActionReRenderController {
public Boolean isComponentView {get; set;}
public RemoteActionReRenderController() {
this.isComponentView = false;
}
public void doClick() {
this.isComponentView = true;
}
@RemoteAction
public static List<Account> getAccount() {
return [SELECT Id,Name FROM Account ORDER BY Name ASC LIMIT 50];
}
}
<apex:component controller="RemoteActionReRenderComponentController">
<script>
function getAccountForComponent() {
try {
{!$RemoteAction.RemoteActionReRenderComponentController.getAccount}(function(results, event){
if(event.status) {
alert('★Component:OK★');
}
});
} catch (e) {
alert(e);
}
return false;
}
// getAccount();
getAccountForComponent();
</script>
</apex:component>
public class RemoteActionReRenderComponentController {
public RemoteActionReRenderComponentController() {
}
@RemoteAction
public static List<Account> getAccount() {
return [SELECT Id,Name FROM Account ORDER BY Name ASC LIMIT 50];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.