Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Created February 6, 2014 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyoshikawa1106/8843469 to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/8843469 to your computer and use it in GitHub Desktop.
@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