You need to sign in to do that
Don't have an account?

VisualForcePage datatable with Command Link
Hi I am creating new Visual Force page that displays views of Contact.That view contains Contact Lastname & Contacts AccountName if Contact account name is there.
Its all ok.But i am used command link to that view. So If i click to contact Lastname that contact will be open & same for Account Name...
How to handle this one????
I am Hardcoded that value its working fine.But not hard coded itd not working...
My sample code is:
APEX CLASS::
public class dataTableCont
{
List<Contact> Con;
public List<Contact> getContacts()
{
Con = [select id,LastName, AccountId,contact.Account.Name from contact where contact.AccountId != NULL];
return Con;
}
public PageReference LinkContactName()
{
PageReference pdfPage =new PageReference('my org URL' + '/' + 'Contact.Id');
//If i am hardcoded the contact Id its working..
pdfpage.setRedirect(true);
return pdfPage;
}
public PageReference LinkAccountName()
{
PageReference pdfPage =new PageReference('my org URL' + '/' + Contact.AccountId);
pdfpage.setRedirect(true);
return pdfPage;
//return null;
}
My VisualForce Page::
<apexage controller="dataTableCont" id="thePage">
<apex:form >
<apexageBlock title="Contacts">
<apexageBlockTable value="{!Contacts}" var="ge">
<apex:column headervalue="Last Name" width="500">
<apex:commandLink action="{!LinkContactName}" value="{!ge.LastName}" >
<apexaram name="ConLastName" value="{!ge.Id}"/>
</apex:commandLink>
</apex:column>
<apex:column headervalue="Account Name" width="500">
<apex:commandLink action="{!LinkAccountName}" value="{!ge.Account.Name }" >
<apexaram name="ConAccName" value="{!ge.AccountId}"/>
</apex:commandLink>
</apex:column>
</apexageBlockTable>
</apexageBlock>
</apex:form>
</apexage>
If i click to contact Lastname that contact will be open & same for Account Name.
How to handle this one????
Thanks Ron Hess ,
Now its working Fine..
My sample code::
APEX CLASS::
public class dataTableCont
{
List<Contact> Con;
public List<Contact> getContacts()
{
Con = [select id,LastName, AccountId,contact.Account.Name from contact where contact.AccountId != NULL];
return Con;
}
}
VISUALFORCE PAGE::
<apex:page controller="dataTableCont" id="thePage">
<apex:form >
<apex:pageBlock title="Contacts">
<apex:pageBlockTable value="{!Contacts}" var="ge">
<apex:column headervalue="Last Name" width="500">
<a href="/{!ge.Id}">{!ge.LastName }</a>
</apex:column>
<apex:column headervalue="Account Name" width="500">
<a href="/{!ge.AccountId}">{!ge.Account.Name }</a>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks,
Krishna_.