You need to sign in to do that
Don't have an account?
Dixit
Commandlink method (controller) in action not working
Hello,
I have this commandlink on a visualforce page:
which calls this method on my controller:
but is not doing anything when i press the button. Browser console is not showing any error, it's displaying correctly the console.log on it.
Log in developer console is not showing the debug, but it does a log when I click it....
What could be wrong?
I have this commandlink on a visualforce page:
<apex:commandlink action="{!saveProdChanges}" rerender="Messages" value="Save" immediate="true" styleclass="buttonprod" onclick="console.log('click save')"> <apex:param name="buttonsave" value="{!product.id}" id="saveParam" assignTo="{!saveProd}"/> </apex:commandlink>
which calls this method on my controller:
public string saveProd {get; set;} public pageReference saveProdChanges(){ producto_simulacion__c productoEdit = new producto_simulacion__c(); productoEdit = [SELECT Id, categoria__c, cantidad__c, importe__c, descripcion__c, costo_unitario__c FROM producto_simulacion__c WHERE id =: saveProd]; update productoEdit; }I edited so i can try the button, I also trying with just:
public pageReference saveProdChanges(){ system.debug('Hello, this is saveProdChanges method'); }
but is not doing anything when i press the button. Browser console is not showing any error, it's displaying correctly the console.log on it.
Log in developer console is not showing the debug, but it does a log when I click it....
What could be wrong?
VF page
======
<apex:page standardController="Contact" extensions="CommandLinkParamController">
<apex:form >
<apex:commandLink value="Process Nickname" action="{!processLinkClick}">
<apex:param name="nickName" value="{!contact.firstname}" assignTo="{!nickName}"/>
</apex:commandLink>
</apex:form>
</apex:page>
Controller:
========
public with sharing class CommandLinkParamController {
// an instance variable for the standard controller
private ApexPages.StandardController controller {get; set;}
// the object being referenced via url
private Contact contact {get;set;}
// the variable being set from the commandlink
public String nickName {get; set;}
// initialize the controller
public CommandLinkParamController(ApexPages.StandardController controller) {
//initialize the stanrdard controller
this.controller = controller;
// load the current record
this.contact = (Contact)controller.getRecord();
}
// handle the action of the commandlink
public PageReference processLinkClick() {
System.debug('nickName: '+nickName);
// now process the variable by doing something...
return null;
}
}
Please remove the immediate = ''True" from the Outputlink and try the Same code.
Thanks
Vinuthh S
I have tried with a void statement in the method declaration and "public pageReference" with return null and still not working.
<apex:commandLink value="{!emp.Employee_ID__c}" action="{!showEmpDetails}" styleClass="hyperlink-text" reRender="theForm" title="Employee Edit" status="splashStatus">
<apex:param name="empId" value="{!emp.Id}" assignTo="{!empId}"/>
</apex:commandLink>
public Id empId { get; set;}
public void showEmpDetails() {
<!----Your logic ---->
}
This is sample code,its working in my org, Check ir.
Thanks
Vinuthh S
Where " <!-- your logic -->" is i just have a "system.debug('hello');" and is not appearing in the log.
When i click the link it generates a log, but it doesn't have the debug of the method.