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
Slava RamSlava Ram 

links became dead after page rerendering

Hello everybody!
Here my example:

public class DemoController {

public List<User> mRecords { get; set; }
private Integer mRecordsCount { get; set; }

public ADemoController() {
  mRecordsCount = 1;
  mRecords = [SELECT Id, FirstName FROM User LIMIT :mRecordsCount];
}

public void loadOneMoreRecord() {
  mRecords.clear();
  mRecordsCount++;
  mRecords = [SELECT Id, FirstName FROM User LIMIT :mRecordsCount];
}

}


<apex:page controller="DemoController" >

<apex:pageMessages />

<apex:form id="TheForm">
  <apex:pageBlock id="TheBlok">
   <apex:commandButton value="Load one more record" action="{!loadOneMoreRecord}" reRender="TheTable" />
   <apex:pageBlockTable value="{!mRecords}" var="record" id="TheTable">
    <apex:column headerValue="Records">
     <apex:outputLink value="/{!record.Id}"><apex:outputText value="{!record.FirstName}" /></apex:outputLink>
    </apex:column>
   </apex:pageBlockTable>
  </apex:pageBlock>
</apex:form>
 
</apex:page>

After first page loading the link is work fine, but after loading more records in table, links became dead (works only through rmc).
The question is how can I prevent this?

Sorry for my english.
Best Answer chosen by Slava Ram
Pavan Kumar KajaPavan Kumar Kaja
Hi Slava,

Use below code  and let me know.

<apex:page controller="DemoController" >

<apex:pageMessages />

<apex:form id="TheForm">
  <apex:pageBlock id="TheBlok">
   <apex:commandButton value="Load one more record" action="{!loadOneMoreRecord}" reRender="TheTable" />
   <apex:pageBlockTable value="{!mRecords}" var="record" id="TheTable">
    <apex:column headerValue="Records">
     <apex:outputLink value="/{!record.Id}"  target="_parent"><apex:outputText value="{!record.FirstName}" /></apex:outputLink>
    </apex:column>
   </apex:pageBlockTable>
  </apex:pageBlock>
</apex:form>
 
</apex:page>

 Ihave added target attribute if u want open in same page use above one , else for  new tab use target="_blank"



All Answers

James LoghryJames Loghry
Slava,

My guess is you're pulling your clicking on a link for an inactive user, which would appear "dead".

Try filtering out the inactive users in your query, e.g:

public void loadOneMoreRecord() {
  mRecords = [SELECT Id, FirstName FROM User Where IsActive=true LIMIT :mRecordsCount];
}



Pavan Kumar KajaPavan Kumar Kaja
Hi Slava,

Use below code  and let me know.

<apex:page controller="DemoController" >

<apex:pageMessages />

<apex:form id="TheForm">
  <apex:pageBlock id="TheBlok">
   <apex:commandButton value="Load one more record" action="{!loadOneMoreRecord}" reRender="TheTable" />
   <apex:pageBlockTable value="{!mRecords}" var="record" id="TheTable">
    <apex:column headerValue="Records">
     <apex:outputLink value="/{!record.Id}"  target="_parent"><apex:outputText value="{!record.FirstName}" /></apex:outputLink>
    </apex:column>
   </apex:pageBlockTable>
  </apex:pageBlock>
</apex:form>
 
</apex:page>

 Ihave added target attribute if u want open in same page use above one , else for  new tab use target="_blank"



This was selected as the best answer
Slava RamSlava Ram
Hi James, thanks for answer, but your advice dont work when record links on active user, and link still dead.

Ola Ashi! It works! Thanks so much!