• wesley.nolte
  • 0 Points
  • Member since 2011

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2


Hello...I consolidated 6 plain text email templates into 1 using conditional mark up (CASE) thus rendering the appropriate phrasing for the particular instance of the email. This worked like a charm and enabled me to have one CommandButton on a related VisualForce page instead of the 6 I had previously had.
Unfortunately the client made a follow up request: consolidate two of them further into one email but with much less content. On the surface it didn’t sound like too much work until I realized the only way to still use the same template was to obscure whole sections of text for this final scenario.
Below is a snippet of what I’ve been testing in the plain text template:

{!CASE(Session__c.Email_Notification__c, "FIRST APPOINTMENT", “START OF TEST”, “START OF TEST”)}
{!CASE(Session__c.Email_Notification__c, "FIRST APPOINTMENT", “”, “Please pay special attention to instructions below.”)}

{!CASE(Session__c.Email_Notification__c, "FIRST APPOINTMENT", “”, “Instructions:”)}
{!CASE(Session__c.Email_Notification__c, "FIRST APPOINTMENT", “”, “In lieu of a tire blow out, keep your ipad strapped in with a seat belt. Rear seating is always preferable for an ipad. But enough about Pat Metheny.”)}
{!CASE(Session__c.Email_Notification__c, "FIRST APPOINTMENT", “END OF TEST”, “END OF TEST”)}


The above code renders great for records that are not flagged “FIRST APPOINTMENT” e.g

Please pay special attention to instructions below.

In lieu of a tire blow out, keep your ipad strapped in with a seat belt. Rear seating is always preferable for an ipad. But enough about Pat Metheny.

But it literally puts white spaces for records that are flagged "FIRST APPOINTMENT", so they render as:

I am looking for a way to completely collapse white space as 75% of the template ends up rendering as white space for the FIRST APPOINTMENT scenario.
I also tested the following:
{!IF(ISPICKVAL(Session__c.Email_Notification__c , "FIRST APPOINTMENT"), "random1", NULL)}
{!IF(ISPICKVAL(Session__c.Email_Notification__c , "FIRST APPOINTMENT"), NULL, "random2")}
{!IF(ISPICKVAL(Session__c.Email_Notification__c , "FIRST APPOINTMENT"), "random3", NULL)}

The code above renders as:

random 3

Suggestions greatly appreciated!


I'm struggling with the order-of-execution during a VisualForce AJAX postback request and the appropriate way to nest-components that might need to rerender each other.


The documentation (http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_postback_request.htm ) has 4 key steps:


  1. View Deserialization
  2. Evaluate expressions and all method calls including those on custom component controllers
  3. Evaluate the action that triggered the postback
  4. Render view -> HTML sent to browser


I'm getting frustrated by the second step, specifically all method calls.  From what it appears, any public methods (specifically a getter) that are used in a view are called before the action method gets call even if these methods are not binding anything in the View State.


The example below illustrates that getDisplayedList method gets called immediately after view state deserialization and then again during the rendering of the view.  In my toy example, I lazy-load a list of strings based on the iCount member variable.  In my real-world application I'm actually using a SOQL query to dynamically fetch a list of S-Objects to display to the user. 



<apex:page controller="LazyLoadController">

<apex:form id="theWrapper">
	<apex:repeat value="{!DisplayedList}" var="s">
	<apex:commandLink value="refresh" rerender="theWrapper" />
	iCount : <b>{!iCount}</b>


public with sharing class LazyLoadController {

	public LazyLoadController(){
		this.iCount = 5;

	public Integer iCount {get; set;}
	private Transient List<String> t_theList;
	// I want to be able to gurantee getDisplayedList() only gets executed during the rendering of the Component and not during "Postback" validation
	public List<String> getDisplayedList(){
		if(this.t_theList == null){
			// The real use case would Query the Database for the appropriate objects.
			this.t_theList = new List<String>();
			for(Integer i=0 ; i< this.iCount; i++){
				this.t_theList.add('[' + String.valueOf(i) + ']');
		return this.t_theList;
	public PageReference refresh(){
		// In theory I want to be able to execute code here that is guranteed to be executed before getDisplayedList
		return null;


Unfortuntaely, because getDisplayedList gets called before I execute any code in my post-back method, I do not have the opportunity to do any additional logic before the Transient list of strings ( t_theList) gets initalized.


One quick and obvious solution would be to set the Transient list to null in the postback method and force the list to be regenerated or remove the lazy-loading indirection and initalize the list directly.


I typically would do this except for the fact I want this controller to be a component-controller that can be easily dynamically rerendered.  I've outlined the at the high-level what I want to do below.



<apex:page controller="ParentController">
	<!-- Code that will create a new Task and 
		re-render the component that should display 
		a list containing the newly created task 
	<apex:commandLink value="addNewTaskAndRefreshList" rerender="componentWrapper" />
	<apex:outputPanel id="componentWrapper">


public with sharing class ParentController {
	public PageReference addNewTaskAndRefreshList(){
		Task t = new Task();
		insert t;
		return null;



Pretend for example, that my LazyLoadController is now displaying a list of tasks that are dynamically loaded from the database.  I'd like to be able to put this component onto my page and re-render it so that it dynamically refreshes the list of Tasks.  For example, in the ParentController I want to insert a new task, refresh the child-component and display the new task.  Currently, the Lazy-Loading happens in Step 2 (method calls) of the order of execution before Step 3 (Invoke PostBack method).


Does anyone have a suggestion for how I can re-design my code so that I can achieve the above behavior?