I have created a non-editable table for account object. After clicking the edit link I want to edit a particular record. how could I achieve this ?
controller:
public class account2task1
{
public string id;
public Boolean bool {get;set;}
public List<account> contt{get;set;}
public account2task1(ApexPages.StandardController controller) {
bool = true;
id=ApexPages.currentPage().getParameters().get('id');
contt=[select name,accountnumber,phone from account limit 5];
}
public void save() {
bool =false;}
}
VF page:
<apex:page standardController="account" extensions="account2task1" showHeader="false" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:dataTable value="{!contt}" var="a" cellpadding="4" border="1" width="100">
<apex:column headervalue="Action">
<apex:commandLink value="Edit" action="{!save}" />
</apex:column>
<apex:column headervalue="Account name" width="50" >
<apex:inputField value="{!a.name}" html-disabled="{!bool}" id="a1" />
<script>document.getElementById('{!$Component.a1}').disabled = {!bool}; </script> </apex:column>
<apex:column headervalue="Account number" width="50" >
<apex:inputField value="{!a.accountnumber}" html-disabled="{!bool}" id="a2" />
<script>document.getElementById('{!$Component.a2}').disabled = {!bool}; </script> </apex:column>
</apex:dataTable></apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>