+ Start a Discussion
Laxmi Pandey 20Laxmi Pandey 20 

Need help on selectoptions and vf page blocks

Hi I want to display contact and accounts in the same page, Account first with editable fields and a checkbox. once I click the checkbox it should display the related contact below it and allow me to edit it. Also, at  top there should be a industry listview to display accounts accordingly.. Below is the code and output screen which I am getting at the moment, please help

public class DiplayRelatedContacts {
   public List<Account> accList{get;set;}
   public list<Contact> conList{get;set;}
   public String accId{get;set;}
   public String str{get;set;}
     public DiplayRelatedContacts (){
     acclist=[SELECT Id,Name,AccountNumber, industry FROM Account Where industry=:str];
   public List<SelectOption> Accountlist
            Accountlist= new List<SelectOption>();
            for(Account acc: acclist)
             //string str = String.valueOf(acc.getRelationshipNaryme());
             string str=acc.industry;
            Accountlist.add(new SelectOption(str, str));
               // Accountlist.add(new SelectOption(acc.industry, acc.industry));
           return Accountlist;
    public PageReference dispalyContact() {
       if(accId != null)
       conList=[SELECT id,FirstName,LastName FROM Contact WHERE AccountId=:accId];
        return null;
    public PageReference SaveAccount(){
     if(acclist.size()> 0){
       Update acclist;
     return null;
   public PageReference SaveContact(){
       Update conlist;
       return null;


VF page
<apex:page controller="DiplayRelatedContacts" id="pg">
    <apex:form id="frm">
            <apex:commandButton value="Save Account" action="{!SaveAccount}"/>
<apex:commandButton value="Save Contact" action="{!SaveContact}"/>
        <apex:pageBlock id="pgblk" >
        <apex:selectList size="3">
          <apex:selectOptions value="{!Accountlist}"></apex:selectOptions>
            <apex:pageBlockTable value="{!acclist}" var="ac">
                <apex:column width="10px">
                    <input type="radio" name="group1" />
                    <apex:actionSupport event="onclick" action="{!dispalyContact}" ReRender="conpgblk" >
                        <apex:param assignTo="{!accId}" name="accname" value="{!ac.id}"/>
                <apex:column headervalue="Account Name">
                <apex:inputfield value="{!ac.Name}" />
                 <apex:column headervalue="Account Number">
                <apex:inputfield value="{!ac.AccountNumber}" />
                <apex:column headervalue="Account Industry">
                <apex:inputfield value="{!ac.industry}" />
        <apex:pageBlock id="conpgblk" >
            <apex:outputPanel rendered="{!conList.size == 0}">
                <b> NO RELATED CONTACTS FOR THIS ACCOUNT .</b>
            <apex:outputPanel rendered="{!conList.size != 0}">
                <apex:pageBlockTable value="{!conList}" var="con">
                    <apex:column headervalue="Firstname">
                    <apex:inputfield value="{!con.FirstName}"/>
                     <apex:column headervalue="Last Name">
                    <apex:inputfield value="{!con.LastName}"/>
the Output page
User-added image