Skip to content

Instantly share code, notes, and snippets.

@joshbirk
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save joshbirk/9533557 to your computer and use it in GitHub Desktop.

Select an option

Save joshbirk/9533557 to your computer and use it in GitHub Desktop.
PageBlock Components Test
public with sharing class ListDetailController {
public List<Account> accounts {get; set;}
public Account account_detail {get; set;}
public Id account_id {get; set;}
public Boolean showBack {get; set;}
// The extension constructor initializes the private member
// variable mysObject by using the getRecord method from the standard
// controller.
public ListDetailController() {
// account = (Account)stdController.getRecord();
if(accounts == null) {
accounts = [SELECT Id, Name, Phone from ACCOUNT];
}
}
public PageReference save() {
showBack = true;
return null;
}
public PageReference goBack() {
return Page.VFTest1;
}
public PageReference showAccount() {
account_id = System.currentPagereference().getParameters().get('account_id');
account_detail = [SELECT Id, Name, Phone from ACCOUNT where ID = :account_id]; //wtf
System.debug('DEBUG THIS!!!!'+account_detail.Name);
return Page.VFTest2;
}
}
<apex:page showHeader="false" sidebar="false" Controller="ListDetailController">
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'icons.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'styles.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'OneStarter.css')}"/>
<!-- JavaScript files -->
<apex:includeScript value="{!URLFOR($Resource.jquery)}"/>
<apex:includeScript value="{!URLFOR($Resource.OneStarter,'jquery.onestarter.js')}"/>
<script>
$(document).ready(function() {
$('div[id*="form-panel"]').oneStarter('app');
})
</script>
<apex:outputPanel id="form-panel" layout="block">
<article class="padded"><H1>Accounts</H1></article>
<apex:form>
<apex:repeat var="a" value="{!accounts}">
<article class="padded">
<div class="icon icon-left icon--account"></div>
<apex:commandLink action="{!showAccount}" value="{!a.Name}" >
<apex:param value="{!a.Id}" name="account_id" assignTo="{!account_id}" />
</apex:commandLink>
</article>
</apex:repeat>
</apex:form>
</apex:outputPanel>
</apex:page>
<apex:page showHeader="false" sidebar="false" Controller="ListDetailController">
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'icons.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'styles.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'OneStarter.css')}"/>
<!-- JavaScript files -->
<apex:includeScript value="{!URLFOR($Resource.jquery)}"/>
<apex:includeScript value="{!URLFOR($Resource.OneStarter,'jquery.onestarter.js')}"/>
<script>
$(document).ready(function() {
$('div[id*="form-panel"]').oneStarter('app');
})
</script>
<apex:outputPanel id="form-panel" layout="block">
<article class="padded"><H1>Accounts</H1></article>
<apex:form>
<apex:pageBlock title="{!account_detail.name}" mode="edit">
<apex:pageBlockButtons>
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!goBack}" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="1">
<apex:inputField value="{!account_detail.phone}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:outputPanel rendered="{!showBack}">
<apex:commandButton value="Back" action="{!goBack}" />
</apex:outputPanel>
<apex:repeat var="a" value="{!accounts}">
<article class="padded">
<div class="icon icon-left icon--account"></div>
<apex:commandLink action="{!showAccount}" value="{!a.Name}" >
<apex:param value="{!a.Id}" name="account_id" assignTo="{!account_id}" />
</apex:commandLink>
</article>
</apex:repeat>
</apex:form>
</apex:outputPanel>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment