Today I was looking at a code that was exiting in the org from a long time and I was surprised to find that the the value assigned in the assignTo attribute in the apex:param tag doesn't exit in the controller. But below is the description for the assignTo attribute:

A setter method that assigns the value of this param to a variable in the associated Visualforce controller. If this attribute is used, getter and setter methods, or a property with get and set values, must be defined.

As you can see from the below code, I have not used any controller / extensions in the page, but still I can still use a variable someVariable in the assignTo attribute. The page compiles and renders fine. Looks like a bug to me. Any idea?

        <apex:commandButton value="Do Something">
            <apex:param assignTo="{!someVariable}" value="clicked"/>
  • Can you mention someVariable? i mean is it like {!Account.Name} – snehakem Jan 16 '15 at 8:42
  • 1
    @snehakem: My intention was that the compiler should never have saved this page in the first place as the sameVariable doesn't exit. There's no standardController defined in the page, so it can't be {Account.Name} – Sam Jan 16 '15 at 8:52
  • Does it still compile if you have a name attribute? apex:param without a name doesn't do anything. – Dominic Jan 16 '15 at 9:00
  • Yes it does compile after adding the name attribute – Sam Jan 16 '15 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.