+ Start a Discussion
SuriSuri 

Dynamic Rendering of Visualforce TAGS!!

Hi...

 

Here is what i need in brief...

 

I have a VF Page where the User chooses the different fields of an Object.

 

Now, in the next page, I want these fields as <apex:inputField > dynamically rendered on the page.

 

Is this possible?

 

 

Let me explain below how it works for HTML Tags.

 

 

For example, in my controller, if I construct a String dynamicstr = '<input type="text" value="TEST" size="20" />',

 

and render is on my VF Page like: <apex: outputText value="{!dynamicstr}" escape="false" />

 

I am able to see an input Text field on the page with value 'TEST'.

 

But the same doesn't work for VF tags like "<apex:inputField>".

 

 

Can anyone help me out on this?

 

Thanks.

 

Suri

 

 

 

Message Edited by Suri on 08-17-2009 11:26 AM
bob_buzzardbob_buzzard

I don't think this is possible.  When you dynamically render HTML, this is something that the browser can understand.  Apex components are expanded up server-side to produce the page.  Therefore, you would need some sort of two-pass system, where after the page is expanded up, the processing that expands Apex components runs again, and produces the appropriate HTML for your dynamically generated tags.

Richie DRichie D

Hi,

 

You could possibly do something like this in Javascript by setting the display to be none if necessary. e.g.

 

 

<apex:inputField value="{!myValue}" style="{!IF(showField,'','display:none;'}"/>

 

 If the field isn't required you may be able to set the field to be hidden clientside and not serverside.

 

R. 

 

rcravenrcraven
Also look at the force.com Developer Guide pg, 384 has a section called, "conditionally displaying fields".