+ Start a Discussion
Shephali SwarnkarShephali Swarnkar 

apex:detail

Hi All,
    Below is my code which i have written to display the records.i have multiple tables(showing one at time as per choice given). and in table one field i made it a link so that i can get details of that records. In this code there is no error, when i am clicking any of the link first time which are populated it displays the details of that records but when i click second time to any other link it is not showing anything. why i can't get.

------------------VF code--------------------------
    <apex:pageBlockTable value="{!num_con}" style="" var="cn" rendered="{!If(showTable == 'donotcall',true,false)}">
<apex:column headerValue="Name">
<apex:commandLink value="{!cn.Name}" reRender="block1">
<apex:param name="p1" value="{!cn.id}"/>
</apex:commandLink> 
</apex:column>
<apex:column value="{!cn.Account.Name}"/>
<apex:column value="{!cn.DoNotCall}"/>
<apex:column value="{!cn.mobilephone}"/>
<apex:column value="{!cn.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
    <apex:pageBlock id="block1">
      <apex:detail subject="{!$CurrentPage.parameters.p1}" relatedList="false"/>
    </apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock> 
---------------------------------------Controller Code---------------------------
public void reject()
 {
   showTable = 'donotcall';
 num_con=[select Name, Email, MobilePhone, Account.Name, Phone, LeadSource,DoNotCall from Contact where rejectcontact__c='yes' and owner.alias=: Alias];     
 }

showing the records for shubham jain because its clicked first but when clicking on "Ashley James" it wont show any records
Akhil AnilAkhil Anil
Hi Shephali,

Please try the below snippet.

 
<apex:pageBlockTable value="{!num_con}" style="" var="cn" rendered="{!If(showTable == 'donotcall',true,false)}">
<apex:column headerValue="Name">
<apex:commandLink value="{!cn.Name}" reRender="block1">
<apex:param name="p1" value="{!cn.id}"/>
</apex:commandLink> 
</apex:column>
<apex:column value="{!cn.Account.Name}"/>
<apex:column value="{!cn.DoNotCall}"/>
<apex:column value="{!cn.mobilephone}"/>
<apex:column value="{!cn.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
  <apex:outputPanel id="block1">
    <apex:pageBlock>
      <apex:detail subject="{!$CurrentPage.parameters.p1}" relatedList="false"/>
    </apex:pageBlock>
  </apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>

Kindly mark it as a solution if that works.
 
Shephali SwarnkarShephali Swarnkar
Hi Akhil Anil,
    Thanks for reply but its not working the problem is same its showing detail records of the very first selected record link.
Akhil AnilAkhil Anil
Hi Shephali,

I have modified the below snippet and tested it out. I have done a couple of changes in the pageblock tags. Ensure that you include the same in your code. 
 
<apex:page StandardController="Account">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!Account.Contacts}" var="cn">
<apex:column headerValue="Name">
<apex:commandLink value="{!cn.Name}" reRender="block1">
<apex:param name="p1" value="{!cn.id}"/>
</apex:commandLink> 
</apex:column>
<apex:column value="{!cn.Name}"/>
<apex:column value="{!cn.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<apex:pageBlock >
 <apex:pageBlockSection >
  <apex:outputPanel id="block1">
    <apex:pageBlock >
      <apex:detail subject="{!$CurrentPage.parameters.p1}" relatedList="false"/>
    </apex:pageBlock>
  </apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>


 
Shephali SwarnkarShephali Swarnkar
Hi Akhil Anil,
       The problem with rendered="{!If(showTable == 'donotcall',true,false)}" in <apex:pageBlockTable> if i remove the code works properly. but after removing this attribute it will show the table structure initially with blank data which i need to ignore. in that case how to achieve both the things like ignoring the structure of table as well as shwing records for each link.

Thanks
Shephali