You need to sign in to do that
Don't have an account?
Elsa 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 ?
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 ?
Please let us know if this will help you.
Thanks
Amit Chaudhary
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/>.