You need to sign in to do that
Don't have an account?

Dynamically Adding Fields???
Because we don't always want to use <apex:detail> and yet still want our pages to respond to end user customisations of our objects. I’ve been looking at the <apex:repeat> tag to see what I can achieve as regards dynamically adding controls to a page. I’ve had partial success *, though I am binding to fields on Apex Classes again and not SObject fields ** so no <apex:inputField> benefits… L
* Can we nest <apex:repeat>’s as the drop down doesn’t appear to pick up the list items? L
** Would be could to have indirect bindings e.g. <apex:inputField … value=”{!{!field.binding}}”> if you see what I mean?
<apex:page controller="dynamiccontroller">
<table>
<apex:repeat value="{!fields}" var="field" rows="50">
<tr>
<td><apex:outputLabel value="{!field.label}"/></td>
<td>
<apex:inputText rendered="{!field.showText}" value="{!field.text}"/>
<apex:inputCheckbox rendered="{!field.showCheckbox}" value="{!field.boolean}"/>
<apex:selectOneListbox rendered="{!field.showValues}" value="{!field.text}" size="1">
<apex:repeat value="{!field.values}" var="fieldvalue" rows="50">
<apex:selectItem itemValue="{!fieldvalue.value}" itemLabel="{!fieldvalue.label}"/>
</apex:repeat>
</apex:selectOneListbox>
</td>
</tr>
</apex:repeat>
</table>
</apex:page>
public class DynamicController
{
DynamicFieldInfo[] fields;
public DynamicFieldInfo[] getFields()
{
if(fields==null)
{
fields = new DynamicFieldInfo[3];
// Edit
fields[0] = new DynamicFieldInfo();
fields[0].setLabel('Field A');
fields[0].setShowText(true);
fields[0].setText('Text');
// Checkbox
fields[1] = new DynamicFieldInfo();
fields[1].setLabel('Field B');
fields[1].setShowCheckbox(true);
fields[1].setBoolean(true);
// Dropdown
fields[2] = new DynamicFieldInfo();
fields[2].setLabel('Field C');
fields[2].setShowValues(true);
List<DynamicFieldInfoValue> values = new List<DynamicFieldInfoValue>();
DynamicFieldInfoValue red = new DynamicFieldInfoValue();
red.setValue('red');
red.setLabel('Red');
values.add(red);
DynamicFieldInfoValue yellow = new DynamicFieldInfoValue();
yellow.setValue('yellow');
yellow.setLabel('Yellow');
values.add(yellow);
fields[2].setValues(values);
}
return fields;
}
}
Never mind. I found the post here where you said it's not in summer 08. What's the road map for releasing this feature?
Message Edited by Dogen Zenji on 06-27-2008 01:33 PM