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

Render dynamic visualforce page

Hi what i am trying achieve is to render a visualforce page to show only certain type of inputFields is this even possible. For example i want to determine something like which fields are empty and show only these fields in my custom visualforce page, i wish there was a dynamic visualforce component .
That should just be a case of defining input fields for everything, but only rendering those that satisfy the condition NOT(ISBLANK(field_name)).

Hi this is a bit more complex, what i am trying to do is calling a webservice callout that returns a list of invalid fields for this particular object could be any object contact, account.


Then getting these error fields and render them as inputfields on my page, i don't want to manually do something like this

<apex:inputfield value="{!object.Phone}">


but like this:


<apex:repeat value="fieldList" var="field">

       <apex:inputfield value="{!field}">



what i tried to do is build a dynamic merge field list like this


public List<Object> fieldList { public get{ List<Object> fields = new List<Object>(); for(String a : fieldSchema.keySet()){ fields.add('{!scope.' + a + '}')); } return fields; } private set{ } } //This won't work :( <apex:repeat value="{!fieldList}" var="field"> <apex:inputField value="{!field}"/> </apex:repeat>


//This won't work :(
<apex:repeat value="{!fieldList}" var="field">
     <apex:inputField value="{!field}"/>


Yeah, I think inputfield requires the field to be part of an sobject - I guess it needs to get at the sobject describe type information to figure out the correct type of input to put out there.



any suggestions

Can you stand having all your fields appear as inputtext rather than inputfield components?  If that was acceptable you could just create a NameValuePair wrapper object that contained the field name and a string to capture the value.  You'd have to handle the string to field conversion yourself, but it might be a way forward.



I have tried using inputtext but it seems this won't work as the user needs to add dates from the calendar select from picklists etc.. it should be the same as inputfield :(