+ Start a Discussion
VFVF 

Dynamic binding of Data

Hello,
Does any one have any idea on dynamic binding in Vfpage. 
 I want to dynamically bind salesforce component from the Apexcode into Vf page.Here is what i am working on:
VFpage:
<apex:form>
<apex:repeat value="{!strings}" var="string" id="theRepeat" >
        <apex:selectList value="{!countries}"   size="1">
            <apex:selectOptions value="{!items}"/>
        </apex:selectList><br/>
</apex:repeat><br/>
<apex:commandButton value="Add More" action="{!add}"/>
</apex:form>
class:
publi class myClass
{
 String[] countries = new String[]{};            
        public PageReference test() {
            return null;
        }            
        public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('US','US'));
            options.add(new SelectOption('CANADA','Canada'));
            options.add(new SelectOption('MEXICO','Mexico'));
            return options;
        }            
        public String[] getCountries() {
            return countries;
        }            
        public void setCountries(String[] countries) {
            this.countries = countries;
        }
}
Firstly i want to display 3 drop down lists with the same values inside in it on page load iam able to do it using repeater then i want a button in the apex VFpage such that when the button is clicked a new  drop down list is added dynamically to the vpage.
on the pageload the repeat control is filled with 3 drop downs but
here i want to add one or  more dropdowns dynamically when clicked on "Add More" command button . 
Your help is appreciated.  
Thanks,
shaan 
rcravenrcraven

Check out the force.com cookbook article on "Dynamically Updating a Page".

 

VFVF

Thanks for your reply , i went through cook book but wasnt satisfied can u help me with a solution for above mentionedissue.

 

Thanks,

shaan