Created
February 6, 2014 12:44
-
-
Save tyoshikawa1106/8843469 to your computer and use it in GitHub Desktop.
@remoteactionとreRenderでエラーが発生する条件の検証
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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