• Tarique Shamim
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

 

I dont know whether it is possible or not.

 

I have two components and a page.

 

I am using components in a page and rendering the second component.

 

But the second component is not rendering properly.

 

Any Idea!

 

VF Page Code:

 
<apex:page >
  <apex:form >
          <apex:outputpanel id="op1">
               <c:VCContacts ></c:VCContacts>
          </apex:outputpanel>
          
          
          <apex:outputpanel id="op2">
              <apex:actionstatus id="mystatus" startText="loading....">
                  <apex:facet name="stop" >
                      <c:VCConSelect ></c:VCConSelect>
                  </apex:facet>
              </apex:actionstatus>
          </apex:outputpanel>
 
   </apex:form>
</apex:page>
 
 
 
 
********************************
Component1 (VCContacts):
 
 
 
Code:
 
<apex:component controller="ContactsDisplayClass">
  <apex:pageBlock >
      <apex:pageBlockTable value="{!lstWC}" var="wc">
        <apex:column headerValue="Action">
            <apex:inputcheckbox value="{!wc.ischecked}"/>
        </apex:column>
        <apex:column headerValue="Name" value="{!wc.objC.name}"/>
      </apex:pageBlockTable>
      <apex:commandButton value="ShowSelected" action="{!doShow}" reRender="op2" status="mystatus"/>
  </apex:pageBlock>
</apex:component>
 
 
 
*******************************
Component2 (VCConSelect)
 
Code:
 
<apex:component controller="ContactsDisplayClass">
            <apex:pageBlock >
                  <apex:pageBlockTable value="{!selContacts}" var="sc">
                          <apex:column headerValue="Name" value="{!sc.Name}"/>
                  </apex:pageBlockTable>
              </apex:pageBlock>
</apex:component>
 
 
*******************
Common Controller for both Components:
 
 
Controller code:
 
public with sharing class ContactsDisplayClass {
    public List<String> conIds = new List<String>();
    public void doShow() {
        for(wrapContactcs objWC : lstWC){
            if(objWC.ischecked == true){
                conIds.add(objWC.objC.Id);
            }
        }
        selContacts = new List<contact>();
        selContacts = [select id,name from Contact where ID IN : conIds];
        system.debug('--selContacts are -->'+selContacts);
    }
 
    public List<Contact> selContacts{get;set;}
    public List<Contact> lstC{get;set;}
    public List<wrapContactcs> lstWC{get;set;}
 
    public ContactsDisplayClass(){
        lstC = new List<Contact>();
        lstC = [select id,name,AccountId from Contact where AccountId =: apexPages.currentpage().getParameters().get('id')];
        lstWC = new List<wrapContactcs>();
        
        for(Contact objC : lstC){
            wrapContactcs objWC = new wrapContactcs();
            objWC.objC = objC;
            lstWC.add(objWC);
        }
    }
    
    public class wrapContactcs{
        public boolean ischecked{get;set;}
        public Contact objC{get;set;}
    }
}