You need to sign in to do that
Don't have an account?
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!
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
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>
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>
<apex:outputLabel value="{!blnDoAttachment}"> </apex:outputLabel> </apex:pageBlock> </apex:form> </apex:page>
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/
Awesome guys thanks for the quick response, that was perfection!
I don't think Jeff highlights this, but you need to include the name element.
name = "randomNickName"
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:
(modified version of the final example from Jeff's blog post)