I am a newbie to salesforce coming from java world. I was working on a piece of functionality where user select search criteria, i build a dynamic soql based on that and display records on the same page, and each record is associated with an edit link.
The problem with the "EDIT Link" is that it only works without rerender attribute on the command button.
I don't want a complete complete page refresh, so i am using the rerender attribute on the command button to partially update the page block table.
But this is breaking the "EDIT" links and they become unresponsive. I have inspected the element itself and i can see that the href link seems to be just fine.
Can anyone help me understand what could be causing this peculiar behavior?
Below is the complete code for custom VF page and custom controller
CUSTOM VF PAGE
<apex:page controller="AccountList" tabStyle="Account">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Search By Name</apex:outputLabel>
<apex:inputText id="searchByName" value="{!searchByName}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Search By Rating</apex:outputLabel>
<apex:selectRadio value="{!searchByRating}">
<apex:selectOption itemLabel="Cold" itemValue="Cold"></apex:selectOption>
<apex:selectOption itemLabel="Hot" itemValue="Hot"></apex:selectOption>
<apex:selectOption itemLabel="Warm" itemValue="Warm"></apex:selectOption>
</apex:selectRadio>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<!-- Implement Web Service -->
<apex:outputLabel for="searchText">Search By State</apex:outputLabel>
<apex:selectList size="1" value="{!searchByState}">
<apex:selectOption itemLabel="" itemValue=""></apex:selectOption>
<apex:selectOption itemLabel="KS" itemValue="KS"></apex:selectOption>
<apex:selectOption itemLabel="CA" itemValue="CA"></apex:selectOption>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<!-- Implement Web Service -->
<apex:outputLabel for="searchText">Logical Operator</apex:outputLabel>
<apex:selectList size="1" value="{!searchCriteria}">
<apex:selectOption itemLabel="AND" itemValue="AND"></apex:selectOption>
<apex:selectOption itemLabel="OR" itemValue="OR"></apex:selectOption>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Search </apex:outputLabel>
<apex:commandButton value="Go1!" action="{!doSearch}" reRender="theBlock"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Results" columns="1">
<apex:actionRegion >
<apex:pageBlockTable value="{!accounts}" var="account" id="theBlock">
<apex:column headerValue="Action">
<apex:outputLink value="{!URLFOR($Action.Account.Edit, account.Id)}">Edit (Action)</apex:outputLink> -
<apex:outputLink value="/{!account.Id}/e?">Edit (URL)</apex:outputLink>
</apex:column>
<apex:column value="{!account.Name}" />
<apex:column value="{!account.Rating}" />
<apex:column value="{!account.BillingState}" />
</apex:pageBlockTable>
</apex:actionRegion>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
CUSTOM CONTROLLER
public class AccountList {
String searchTerms = '';
public String showGo { get; set; }
public String searchCriteria { get; set; }
public String searchByState { get; set; }
public String searchByRating { get; set; }
public String searchByName { get; set; }
public List<Account> accounts {
get;
private set;
}
public PageReference doSearch() {
searchTerms = 'select Name, Rating, BillingState from Account where';
if (!String.isEmpty(searchByName))
searchTerms += ' Name LIKE \''+String.escapeSingleQuotes(searchByName)+'%\'';
if (!String.isEmpty(searchByRating)){
if (!String.isEmpty(searchByName)){
searchTerms += ' '+searchCriteria+' Rating LIKE \''+String.escapeSingleQuotes(searchByRating)+'%\'';
//searchTerms += ' or Rating LIKE \''+String.escapeSingleQuotes(searchByRating)+'%\'';
} else {
searchTerms += ' Rating LIKE \''+String.escapeSingleQuotes(searchByRating)+'%\'';
}
}
if (!String.isEmpty(searchByState)){
if (!String.isEmpty(searchByName) || !String.isEmpty(searchByRating)){
searchTerms += ' '+searchCriteria+' BillingState LIKE \''+String.escapeSingleQuotes(searchByState)+'%\'';
//searchTerms += ' or BillingState LIKE \''+String.escapeSingleQuotes(searchByState)+'%\'';
} else {
searchTerms += ' BillingState LIKE \''+String.escapeSingleQuotes(searchByState)+'%\'';
}
}
if(!String.isEmpty(searchTerms)){
//results = (List<Account>)[FIND :searchTerms RETURNING Account(Name, Rating, BillingState)][0];
System.debug('searchTerms -'+searchTerms);
accounts = Database.query(searchTerms);
}
return null;
}
/*public AccountList() {
accounts = [select name, rating, billingstate from account];
}*/
}