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

Passing Parameters to Apex Method from Visualforce Page to update records
Dear Expert,
I am trying to Pass parameter to Apex method from VF page.It work for remove But i am not able to get the parameter value for update.
<apex:repeat value="{!lstAuthContacts}" var="AC"> <apex:form > <apex:commandLink value="Remove" action="{!removeContact}"> <apex:param name="delContact" value="{!AC.Id}" assignTo="{!cParam}"></apex:param> </apex:commandLink>
<label>First name*</label>
<apex:inputField value="{!AC.FirstName}" styleClass="form-text" id="form-text-contact-first-name"/>
<label>Last name*</label>
<apex:inputField value="{!AC.LastName}" styleClass="form-text" id="form-text-contact-last-name"/>
<label>Phone*</label>
<apex:inputField value="{!AC.Phone}" styleClass="form-text" id="form-text-contact-phone"/>
<label>Email address*</label>
<apex:inputField value="{!AC.Email}" styleClass="form-text" id="form-text-contact-email"/>
<apex:commandButton action="{!updateAuthContact}" value="Save updates" id="theButton"> <apex:param name="updateContact" value="{!AC.Id}" assignTo="{!cParam}"></apex:param> </apex:commandButton>
</apex:form>
</apex:repeat>
public with sharing class AccountProfileController { public Id aid {get;set;}
public string cParam{get;set;} public list<Contact> lstAuthContacts{get;set;} public AccountProfileController(){ getlstAuthContacts(); } private void getlstAuthContacts(){ aid = Apexpages.currentPage().getParameters().get('id'); if(aid != ''){ lstAuthContacts = [Select Contact.Id, Contact.Name, Contact.Contact_Type__c, Contact.FirstName, Contact.LastName, Contact.Phone, Contact.Email, Contact.MailingStreet, Contact.MailingCity, Contact.MailingState, Contact.MailingPostalCode, Contact.MailingCountry, Contact.Living_Will__c From Contact Where Contact.AccountId = :aid And Contact.Contact_Type__c = 'Authorized Contact']; } }
public PageReference removeContact(){
if(cParam != ''){
Contact toDel=new Contact(id=cParam);
delete todel;
getlstAuthContacts
}
returm null;
}
public PageReference updateAuthContact() {
if(cParam != ''){
Contact toUpdate=new Contact(id=cParam);
update toUpdate;
getlstAuthContacts();
}
return null;
}
}
I've found that parameters don't get passed unless the commandbutton has a rerender attribute - I've always assumed this means it needs to be an Ajax request to send the parameters.
If I don't have anything to sensibly rerender, I just put an outputpanel around the entire content and rerender that.
I have do like this it's still not working
Hi Gsajeesh
Thank you for your help, I have tried it's not work.
Hello apple_sae,
Try this in your "updateAuthContact()" controller method:
If it works, you can delete the "assignTo" attribute.
Regards,
JVN
U also have to define proper getters and setters for this in your controller
Thanks!
Try rerendering something that is within your <apex:form> tags