• laxman raj
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
trigger insertrecord on x__c (before insert) {
list<x__c> cu=trigger.new;
for(x__c xg:trigger.new)
{
xg.name='hjh';
insert xg;
}
}
<apex:page controller="AccWithAllContactsClass" >
<apex:form >
  <apex:inputField value="{!acc.Name}"/>
   <apex:commandButton value="ShowContacts" action="{!showcontacts}" reRender="out" status="mystatus"/>
   <apex:actionStatus startText="please wait it is loading contacts.......">
   <apex:facet name="stop">
    <apex:outputPanel id="out">
    <apex:pageBlock >
     <apex:pageBlockSection >
      <apex:pageBlockTable value="{!conRecords}" var="c" >
       <apex:column headerValue="Contacts">
        {!c.name}
       </apex:column>
      </apex:pageBlockTable>
     </apex:pageBlockSection>
    </apex:pageBlock>
   </apex:outputPanel>
  </apex:facet>
</apex:actionStatus>
</apex:form>
</apex:page>
=====================================
public with sharing class AccWithAllContactsClass {

    List<Account> lstaccount = new List<Account>();
    List<contact> lstcontacts = new List<contact>();
    public List<contact> getConRecords()
{
       lstcontacts.clear();
       accIds.clear();
       lstaccount.clear();
       system.debug('****AccNameTextValue is *****'+accName);
       lstaccount=[select id,name from Account where name=:accName];
       for(Integer i=0;i<lstaccount.size();i++)
       {
           accIds.add(lstaccount[i].Id);
       }
      
        lstcontacts =[select id,name,accountId from contact where accountid in : accIds];
        system.debug('**** List of Contacts for Test is ***'+lstcontacts);
        return lstcontacts;
    }
    set<string> accIds = new set<string>();
    public pagereference showContacts() {
       return null;
       
    }
    public Account accName { get; set; }
   
    Public AccWithAllContactsClass()
    {
       
    }
}
trigger insertrecord on x__c (before insert) {
list<x__c> cu=trigger.new;
for(x__c xg:trigger.new)
{
xg.name='hjh';
insert xg;
}
}