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
RickoT1031RickoT1031 

RE: apex:param not working?

So I am trying to assign a value to a property in my controller and it just is not working, the value always ends up as null... am I doing somethign wrong?

 

In My Controller

public Boolean blnDoAttachment{get; set;}

 

 <<Some Code>>

 

 if (blnDoAttachment == True){

return new PageReference('p/attach/NoteAttach?pid=/' + c.id + 'retURL=' + c.id); 

 

}

if (blnDoAttachment == False){

return new PageReference('/'+ c.id);

}

return null;

 

On My VisualForce Page

<apex:commandButton action="{!save}" value="Submit"><apex:param value="False" assignto="{!blnDoAttachment}"/></apex:commandButton> <apex:commandButton action="{!save}" value="Submit and Attach"><apex:param value="True" assignto="{!blnDoAttachment}"/></apex:commandButton>

Any assistance would be greatly appreciated.  I am pretty sure its just something totally stupid on my part

 

Thanks!

 

Message Edited by RickoT1031 on 03-09-2010 04:27 PM
visualforce_devvisualforce_dev

Hi,

 

Even I faced the same issue. Param is working fine for commandlink not well for button.. afterall i put commandlink and using style i displayed it as button 

NZ_XueNZ_Xue

try this way and then let me konw if it works:

 

 

<apex:commandButton action="{!save}" value="Submit" rerender="hidden"><apex:param value="False" assignto="{!blnDoAttachment}"/></apex:commandButton> <apex:commandButton action="{!save}" value="Submit and Attach" rerender="hidden"><apex:param value="True" assignto="{!blnDoAttachment}"/></apex:commandButton> <apex:pageBlock id="hidden" rendered="false"></apex:pageBlock>

 

 

 

 

NZ_XueNZ_Xue

i just put your code into a pageBlock and set rerender="block" for CommandButton and then it works.

 

i can get parameter in APEX code. but i do not find a way without add a pageBlock tag.

 

 

<apex:page standardController="Contact" extensions="CommandButtonParamController"> <apex:form > <apex:pageBlock mode="edit" id="block" > <apex:commandButton action="{!save}" value="Submit" rerender="block" ><apex:param value="False" assignto="{!blnDoAttachment}"/></apex:commandButton> <apex:commandButton action="{!save}" value="Submit and Attach" rerender="block"><apex:param value="True" assignto="{!blnDoAttachment}"/></apex:commandButton>

<!-- i can see the value in a outputLabel changed between True and False when i click the buttons.get set methods are work -->

<apex:outputLabel value="{!blnDoAttachment}"> </apex:outputLabel> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

 

 

 

 

 

Rajesh ShahRajesh Shah

There is some problem with the param tag and command button. Check the below link for details and the solution:

http://blog.jeffdouglas.com/2010/03/04/passing-parameters-with-a-commandbutton/

RickoT1031RickoT1031

Awesome guys thanks for the quick response, that was perfection!

d3developerd3developer

I don't think Jeff highlights this, but you need to include the name element.

 

name = "randomNickName"

Brendan Walton 9Brendan Walton 9

I would like to add, In Jeff's post he says you must use a hidden pageBlock which is not true. You can add an ID to the form element and re-render that instead. It's a bit cleaner in my opinion:

<apex:page standardController="Contact" extensions="CommandButtonParamController">  
    <apex:form id="theForm">

        <apex:commandButton value="Process Nickname" action="{!processButtonClick}" rerender="theForm">
            <apex:param name="nickName"
                value="{!contact.firstname}"
                assignTo="{!nickName}"/>
        </apex:commandButton>
    </apex:form>
</apex:page>
(modified version of the final example from Jeff's blog post)
Swapnadip123Swapnadip123
For apex:param to work with assignTo, always use reRender in the command button. reRender the enclosing DOM (form or pageblock).