1

I have the following part in my visualforce page:

<apex:form>
    <apex:actionFunction name="interestInShowConfirmed" action="{!interestInShowConfirmed}" />
    <apex:actionFunction name="registerInterest" action="{!openInterestedInShowPopUp}" >
        <apex:param name="chosenId" value=""/>
    </apex:actionFunction>
</apex:form>

The way this code works, is that the "RegisterInterest" action function is called when a user clicks on a button (E.X. the button would execute: registerInterest('123213213'); ) - The register interest action function then generates a pop up to the user confirming their selection. Finally, when the user chooses the yes button on the pop up, the interestInShowConfirmed action function is called. I am running into a strange issue where I seemingly need to specify a re render target for these action functions or variable changes are not saved to the view state.

For example, this line of code

openPositionIdChosenForInterest = system.CurrentPageReference().getParameters().get('chosenId');

will return the correct passed Id if i specify a re render target for the "registerInterest" action function, but will return null if i do not. Also, if i specify a re render target only on "registerInterest" and not on "interestInShowConfirmed" - any global varriables set by the registerInterest action function will be null when "interestInShowConfirmed" tries to access them.

I'm guessing there is something I do not understand about re rendering and the view state - could someone fill me in?

Edit:

Here is how the registerInterest function is called. It is a button inside a custom component included in the visualforce page:

<apex:commandButton value="{!cell['buttonLabel']}" onClick="{!cell['javascriptToCallOnClick']}('{!cell['argToStoreOnClick']}');" reRender="None" />

Also, if i don't include a rerender in this button, my action function is not called

0

Not specifying reRender causes a POST request, while using reRender uses the AJAX library to perform the request. If you don't use a reRender, you must use the assignTo attribute of apex:param, as the parameters won't be posted (i.e. currentPage().getParameters() won't have any values).

The documentation is not particularly clear on this, but basically you need to either use assignTo or reRender; if you use neither, your parameters will be useless. This is true for other supported elements, like apex:actionSupport, when using parameters. You must use either attribute to have proper parameter support.

  • It appears that even with a assignTo property it does not work: Ex. <apex:actionFunction name="registerInterest" action="{!openInterestedInShowPopUp}" > <apex:param name="chosenId" value="" assignTo="{!openPositionIdChosenForInterest}"/> </apex:actionFunction> and the code behind: if(openPositionIdChosenForInterest == null) { webpageUtilities.addError('Open Position Id not retrieved successfully from pop up', MAIN_PAGE_MESSAGES_ID); return; } will unforuntately always trigger the message that the Id is null – Hans Donkersloot Mar 13 at 5:18
  • @HansDonkersloot Hmm... I don't think I have enough context then. Maybe you could add more code in your question for context? – sfdcfox Mar 13 at 5:24
  • Admittedly this is a really complex page, which is likely why there is an issue somewhere here - I added the code for how the action function is invoked, hopefully that might explain some things – Hans Donkersloot Mar 13 at 5:47
  • The documentation is not particularly clear on this - so true – cropredy Mar 13 at 17:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.