function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Generic Fields and Objects in visualforce <apex:inputText>

Hi All,

I saw a lot of posts here regards the <apex:inputField> binding to sObject, unfortunately I couldn't understand if it's possible or not to do the following - 


Declare in the controller on the following two String parameters - 

String objName = 'Account' ; // Or another custom or standard object

String fieldName = 'Industry' ; // Or another custom or standard field


And the output in the visualforce page suppose to show this field by <apex:inputField value="{!objName.fieldName}" />


I tried to use sObject, ObjectType all the describe methods for object and fields without any success to do it.


Any help will highly appriciated,

Thanks in advance,








I dont think it is possible.


Alternative is, you can make use of field set. In Field Set, you can display fields of relative objects. You can render the same using input text in VF page.




Use this approach:

//Apex code
public Account accountInstance{get;set;}

//VF page
<apex:inputField value="{!accountInstance.Industry}"/>

Similarly, you can write for all standard and custom objects.