Skip to main content
Pratima Shrivastav (Slalom) 님이 #Visualforce에 질문했습니다
Hi folks...

  Here is my vf page code and controller code. But I am getting an error called Unknown property 'ContactgivenId.con. I have defined getter and setter in my controller. Any help will be appreciated.. Thanks in advance..

Vf page code_______________________

<apex:page id="pgId" controller="ContactgivenId">

    <Apex:form>

        <apex:pageBlock>

            <Apex:pageblockSection title="Accounts">

                <apex:pageBlockTable value="{!acct}" var="account">

                    <Apex:column headervalue="Account id">

                        <Apex:outputPanel >

                            <Apex:outputText value="Click" />

                            <apex:actionSupport event="onclick" action="{!getContact}" rerender="contactBlock" >

                                <Apex:param name="accountId" assignTo="{!acctId}" value="{!account.Id}"/>

                            </apex:actionSupport>

                                   

                        </apex:outputPanel >

                    </apex:column>

                    <Apex:column headervalue="Account name">

                        <Apex:outputField value="{!account.Name}" />

                    </apex:column>

                </apex:pageBlockTable>

            </Apex:pageblockSection>

        </apex:pageBlock>

       

        <apex:pageBlock id="contactBlock">

            <Apex:pageblockSection title="Contacts">

                <apex:pageBlockTable value="{!con}" var="contact">

                    <Apex:column headervalue="Contact id">

                        <Apex:outputField value="{!contact.Id}"/>

                    </apex:column>

                    <Apex:column headervalue="Contact name">

                        <Apex:outputField value="{!contact.firstName}" />

                    </apex:column>

                </apex:pageBlockTable>

            </Apex:pageblockSection>

        </apex:pageBlock>

    </apex:form>

</apex:page>

___________________________________________Controller________________________________

public class ContactgivenId {

    public List<Account> acct{get; set;}

    public List<Contact> cont{get; set;}

    public String acctid{get; set;}

    public ContactgivenId(){

        acct=new List<Account>();

        cont= new List<Contact>();

        acct=[select id,name from account LIMIT 10];

        

    }

    public void getContact(){

        cont=[select firstname, lastname, phone from contact where account.id= :acctid];

    }

}
답변 13개
  1. 2016년 4월 23일 오전 11:41
    Remove your existing code and paste following codes, it will definitely work:

    Apex

    public class ContactgivenId {

    public List<Account> acct{get; set;}

    public List<Contact> cont{get; set;}

    public String acctid{get; set;}

    public ContactgivenId(){

    acct=new List<Account>();

    cont= new List<Contact>();

    acct=[select id,name from account LIMIT 10];

    }

    public void getContact(){

    cont=[select id, firstname, lastname, phone from contact where account.id= :acctid];

    }

    }

    VF

    <apex:page id="pgId" controller="ContactgivenId">

    <Apex:form >

    <apex:pageBlock >

    <Apex:pageblockSection title="Accounts">

    <apex:pageBlockTable value="{!acct}" var="account">

    <Apex:column headervalue="Account id">

    <Apex:outputPanel >

    <Apex:outputText value="Click" />

    <apex:actionSupport event="onclick" action="{!getContact}" rerender="contactBlock" >

    <Apex:param name="accountId" assignTo="{!acctId}" value="{!account.Id}"/>

    </apex:actionSupport>

    </apex:outputPanel>

    </apex:column>

    <Apex:column headervalue="Account name">

    <Apex:outputField value="{!account.Name}" />

    </apex:column>

    </apex:pageBlockTable>

    </Apex:pageblockSection>

    </apex:pageBlock>

    <apex:pageBlock id="contactBlock">

    <Apex:pageblockSection title="Contacts">

    <apex:pageBlockTable value="{!cont}" var="c">

    <Apex:column headervalue="Contact id">

    <Apex:outputField value="{!c.Id}"/>

    </apex:column>

    <Apex:column headervalue="Contact name">

    <Apex:outputField value="{!c.firstName}" />

    </apex:column>

    </apex:pageBlockTable>

    </Apex:pageblockSection>

    </apex:pageBlock>

    </apex:form>

    </apex:page>

    Mark it as Solved, if it works.
0/9000