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
TehNrdTehNrd 

Apex Param not being passed to controller, simple example

Not a great way to start off a Monday morning. I have a very simple piece of code that should pass a param to the page controller but it is not working at all. I have tried using assignTo as well as ApexPages.currentPage().getParameters() but neither approach has worked. Below is a simple page and controller to reproduce.

Page:
<apex:page controller="param" >
<apex:form>
<apex:commandButton value="Proceed to Upload" action="{!proceedToUpload}" id="uploadButton">
<apex:param name="uploadType" assignTo="{!uploadType}" value="org" id="param"/>
</apex:commandButton>
</apex:form>
</apex:page>


Controller:
public class param {

public String uploadType {get; set;}

public pageReference proceedToUpload(){
system.debug(uploadType);
system.debug(ApexPages.currentPage().getParameters().get('uploadType'));
system.debug(ApexPages.currentPage().getParameters());
return null;
}
}

 

Please tell me I am blind and this is a simple typo I have overlooked. If you don't mind could you try to reproduce this in your org.

Thanks,
Jason

Message Edited by TehNrd on 11-16-2009 11:43 AM
TehNrdTehNrd

Jeez, I just realized this is the known bug with params not working with command buttons. What is up salesforce? This bug has been around for what seems like forever and it is something that many users have come across. Is a fix close?

If a fix isn't reasonable how about preventing saves if a commandButton has params as children?

Message Edited by TehNrd on 11-16-2009 12:12 PM
mcrosbymcrosby
I was just going to say to use the commandLink with styleClass set to "btn". That's the way I had to get around this issue. I agree--seems like this should have been fixed by now.
TehNrdTehNrd
And...... params do not work with actionSupport unless it has a rerender attribute. If you are trying to perform a page redirect it won't work.
aperezSFDCaperezSFDC

This is how it should be written....

 

Page:

<apex:page controller="param" >
    <apex:form>
        <apex:commandButton value="Proceed to Upload" action="{!proceedToUpload}" id="uploadButton">
            <apex:param name="uploadType" value="{!uploadType}" />
        </apex:commandButton>
    </apex:form>
</apex:page>

 

Controller:

public class param {
    public pageReference proceedToUpload(){
        system.debug(ApexPages.currentPage().getParameters().get('uploadType'));
        return null;
    }
}

 

I just re-posted this because I noticed the code had been removed ;-)

gv007gv007

After summer 2010 upgrade still this bug exist am facing similar issue.

stunaitestunaite

Use this instead:

 

Page:
<apex:page controller="param" >
    <apex:form>
        <apex:commandlink value="Proceed to Upload" action="{!proceedToUpload}" id="uploadButton" styleclasse="btn" style="text-decoration:none">
            <apex:param name="uploadType" value="org" id="param"/>
        </apex:commandlink>
    </apex:form>
</apex:page>


Controller:
public class param {

    public String uploadType {get; set;}
         
    public pageReference proceedToUpload(){
        system.debug(uploadType);
        system.debug(ApexPages.currentPage().getParameters().get('uploadType'));
        system.debug(ApexPages.currentPage().getParameters());
        return null;
    }
}

 

MudasirMudasir

try this

  <apex:column >
                  <apex:outputlink value="/apex/updateEmployee" style="color:black;">
                
                         <apex:param name="id" value="{! employee.employeeId__c}"/>
                 </apex:outputLink>
          </apex:column>

 

 

In the value field of outlink you must provide your page name as i have provided updateEmployee.

sampath kumar 3sampath kumar 3
Hi everyone, 

I faced the same issue if I use commandbutton the apex:param is getting as null in the controller getting exception as you suggested in the above  I have replaced with commandbutton with apex:commandLink its working fine. Here I got a requirement need to use the commandbutton instead of commandlink so how can i overcome this issue kindly suggest
Monika KiranMonika Kiran
Hi Sampath 
<apex:commandbutton> tag cannot be parent to <apex:param> Tag so this wont work.
This is a bug in VF page.

Thanks
sampath kumar 3sampath kumar 3
Thanks Monika Kiran .