function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aneesh AllumallaAneesh Allumalla 

viewing records as hyperlinks which redirect to detailed page

Hi,
I want my records to be clickable in the pagebocktable that redirect to detailed page.
My class:
public class Dev6 {
    Public List<Account> accList{set;get;}
    Public String city{get;set;}
    Public boolean show{get;set;}
    Public Dev6(){
        show=false;
    }
    public void showList(){
        show=true;
        acclist=[select Name,ID from Account where BillingCity=:city];        
    }     
}
Vf Page:
<apex:page controller="Dev6">
    <apex:form >
    <apex:pageblock>
        <apex:pageBlockSection columns="1" >
        <apex:inputtext label="Billing City" value="{!city}" />
            <apex:commandButton title="A" value="Show" action ="{!showList}"/>
                   </apex:pageBlockSection>
        <apex:outputPanel id="a">
        <apex:pageBlockSection >
        <apex:pageBlockTable value="{!acclist}" var="s" rendered="{!show}">
            <apex:outputLink value="/{!s.ID}"  >
            </apex:outputLink>
            <apex:column value="{!s.Name}" title="NAME" />
            </apex:pageBlockTable>
        </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
</apex:page>

Please suggest a way without using java script
Maharajan CMaharajan C
Hi Aneesh,

Change your VF Page like below:

<apex:page controller="Dev6">
    <apex:form >
    <apex:pageblock >
        <apex:pageBlockSection columns="1" >
        <apex:inputtext label="Billing City" value="{!city}" />
            <apex:commandButton title="A" value="Show" action="{!showList}"/>
                   </apex:pageBlockSection>
        <apex:outputPanel id="a">
        <apex:pageBlockSection >
        <apex:pageBlockTable value="{!acclist}" var="s" rendered="{!show}">
            <apex:column >
                <apex:facet name="header">NAME</apex:facet>
                <apex:outputLink value="/{!URLFOR(s.Id)}">{!s.Name}</apex:outputLink>
            </apex:column>

            </apex:pageBlockTable>
        </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
</apex:page>

Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Maharajan.C