• Ravish
  • 0 Points
  • Member since 2009

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1
I was experimenting this morning with trying to return Visualforce markup from a call in the controller.  It almost worked, but it appears that the variable returning the Visualforce markup was resolved after the rest of the APEX was resolved for rendering, so it didn't process the Visualforce. 
The purpose of my experimenting is to dynamically build a panelGrid with a differing number of columns (The columns including inputfields) based on prevously selected information on a previous screen of a wizard.
A snippet of the Page Code (in this case building the column heading row for a couple of fields):
<apex:outputLabel value="Shipping Plant" for="Shipping_Plant__c"/>
    <apex:outputLabel value="Potential Annual Volume" for="Potential_Annual_Volume__c"/>
    <apex:outputLabel value="UOM" for="Potential_Annual_Volume_UOM__c"/>
<apex:outputLabel value="AD Compound—" for="AD_Compound__c"/>
<apex:outputLabel value="OEM" for="OEM__c"/>

For testing, in my Controller, I put the following:
public String getTectylLabel() {
    return '<apex:outputLabel value="Tectyl Product—" for="Tectyl_Product__c"/>';

The resulting page ran correctly, but did not rendor the code above, but when I look at the source for that area of the page I see:
<TD><LABEL for=j_id0:j_id3:j_id4:j_id10:Potential_Annual_Volume__c>Potential 
Annual Volume</LABEL><LABEL 
for=j_id0:j_id3:j_id4:j_id10:Potential_Annual_Volume_UOM__c> UOM</LABEL></TD>

<TD><APEX:OUTPUTLABEL for="Tectyl_Product__c" value="Tectyl Product—" /></TD>

<TD><LABEL for=j_id0:j_id3:j_id4:j_id10:AD_Compound__c>AD Compound–</LABEL></TD>

What's interesting is that it did wrap the returned string in a <TD></TD>, but it just treated it as a string. 
There may be a way to do this that I'm missing.  I think being able to actually return Visualforce code from an APEX call would be an extremely powerful feature that would increase the ability to dynamically generate the interface.  I'm sure I'll find a way to do what I'm trying to do without this kind of functionality but I figured it would be good to post my findings in case someone else is trying this and has succeeded, or as an idea for future functionality.
Jon Keener