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
Elsa RousselElsa Roussel 

apex:commandButton OR apex:commandLink not calling the controller method

Hello,
I try to use a button or link to call an specific method in my controller but i can't seem to make it work...
This is the methode : 
public with sharing class newAssetssss_CONTROLLER {
/* the all controller code */
/* blablablabla */
public PageReference miseAJourAsset(){
System.debug('IS THERE ANYONE HERE ??????');
PageReference pageRedirect = new PageReference('http://www.google.com'); return pageRedirect; }
// OR :
// public PageReference miseAJourAsset(){
// System.debug('IS THERE ANYONE HERE ??????');
// return null;
// } }

and then the Visualforces : 

<!-- 1st try -->
<apex:page controller="newAssetssss_CONTROLLER">
<apex:form > <apex:pageMessages />
<apex:sectionHeader ><h1> THE HEADER ! </h1></apex:sectionHeader>
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandbutton value="my button" action="{!miseAJourAsset}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!thelist}" var="listUpdatable">
<!-- the all table -->
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

<!-- Other try -->
<apex:page controller="newAssetssss_CONTROLLER">
<apex:form > <apex:pageMessages />
<apex:actionFunction name="miseAJourAsset" action="{!miseAJourAsset}" rerender="refresh"/>
<apex:sectionHeader ><h1> THE HEADER ! </h1></apex:sectionHeader>
<apex:pageBlock >
<apex:pageBlockButtons >
<input type="button" value="my button" onclick="miseAJourAsset();" />
<!-- <apex:commandbutton value="my button" onclick="miseAJourAsset();"/> -->
</apex:pageBlockButtons> <apex:pageBlockTable value="{!thelist}" var="listUpdatable">
<!-- the all table -->
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

In the debug consol i don't have the "System.debug('IS THERE ANYONE HERE ??????')" message, and when i click on the button (or link, because i tried with apex:commandLink too) the page is just refresh (no redirection, no change, nothing)...
What did I miss ?
 
KaranrajKaranraj
Elsa - I don't see any issue in the code.Same code is working fine in my org. Check this link for the screen recording - https://drive.google.com/file/d/0B4FQ3TUGOZrcQmM4ZG5IWUhqdVk/view?usp=sharing

 
Amit Chaudhary 8Amit Chaudhary 8
Please try below code. I hope that will help you.
 
public with sharing class newAssetssss_CONTROLLER {
/* the all controller code */
/* blablablabla */
	public PageReference miseAJourAsset()
	{
		//System.debug('IS THERE ANYONE HERE ??????');
		//PageReference pageRedirect = new PageReference('http://www.google.com'); return pageRedirect; 
	 return new PageReference('http://www.google.com');
	}
}

Please let us know if this will help you.

Thanks
Amit Chaudhary
Elsa RousselElsa Roussel
Thanks Karanraj,
I finally find an exception message and there was a problem with the selectOption part. Nothing due to the "action".
Why didn't i had the message before, i don't know but it was finally display by the <apex:message/>.