As a learning exercise I wanted to build a visual force page to display a dynamic value. The dynamic value will have code around it in the class. Right now I just want to display it on the Page not as a field. While trying to display the value. Yes I know that i could easily display the name column on the page a different way but I know that i can display it like the below.... I am getting an error of "Could not resolve field 'strGetName' from value binding '{!objVF['strGetName']}' in page myvfpage "
Below is my code
Public with sharing Class MYClass {
public MYClass(ApexPages.StandardController controller) {
MyPagesObjects();
}
Public SObject objVF {get;private set;}
Public void MyPagesObjects()
{
//Gets the ID of the current Page
System.debug(LoggingLevel.ERROR, 'DEBUG ');
String MyObjectID = ApexPages.currentPage().getParameters().get('id');
System.debug(LoggingLevel.ERROR, 'DEBUG ' + MyObjectID);
String GetMyObjectsQuery = 'SELECT Name, Checkbox__c FROM Object_1__c where id = \'' + MyObjectID + '\'';
objVF = Database.query(GetMyObjectsQuery);
String strGetName = ''+ objVF.get('Name');
System.debug(LoggingLevel.ERROR, 'DEBUG ' + strGetName);
}
}//end class
VF
<apex:page standardcontroller="Object_1__c" extensions="MYClass" sidebar="false" docType="html-5.0" action="{!MyPagesObjects}">
<apex:form >
<apex:outputLabel >"MYValue"</apex:outputLabel>
<apex:pageblock mode="maindetail">
<apex:pageblocksection title="MY Visual Force Page" showheader="true" collapsible="true" columns="1">
<apex:pageblocksectionitem >
<apex:outputlabel value="Owner"/>
<apex:outputpanel >
<apex:outputfield value="{!objVF['strGetName']}"/>
</apex:outputpanel>
</apex:pageblocksectionitem>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>