0

I cannot find the reason of this situation. Please help experts.

I have several actionfunction and all of them are using for saving value to Controller variables.

I this situation, one of them doesn't work even if I tried so many modification..

Code is here

<apex:form>
            <apex:commandLink action="{!passParam2}" value="Submit" 
                target="_blank" 
                styleClass="btn btn-primary" 
                style="padding: 4px; text-decoration: none;" 
                reRender="resultPanel" 
                status="myStatus">
                <apex:param name="firstparam" assignTo="{!bookingid}" value="{!$CurrentPage.parameters.bookingid}"/>

            </apex:commandLink>
        </apex:form>

Controller code

public PageReference passParam2(){
    bookingid = ApexPages.currentPage().getParameters().get('bookingid');
    PageReference pg = Page.page1;
    pg.setRedirect(true);
    return pg;
}

Edited 1 time!

If you have any clue for resolving the issue, please help.

Thanks in advance.

2
  • I'm not surprised it doesn't work... but what are you actually attempting to do?
    – sfdcfox
    Nov 29, 2018 at 7:53
  • just want to save value from parameter to controller variable. Is there any way to do it easily? Nov 29, 2018 at 7:56

1 Answer 1

0

You can try a efficient approach with the use of apex:commandLink. No need to use actionFunction

As per your code, you want to display a Submit button and onclicking you will assign value to bookingid, as well as calling controller method passParam and navigate to visualforce page.

  • button class with help you to display as button.
  • apex:param will pass value to controller
  • action will call controller method.

Visualforce

<apex:commandLink action="{!passParam}" 
    value="Submit" 
    target="_blank" 
    styleClass="btn" 
    style="padding: 4px; text-decoration: none;" 
    reRender="resultPanel" 
    status="myStatus">
        <apex:param name="firstparam" 
           assignTo="{!bookingid}" value="{!$CurrentPage.parameters.bookingid}"/>
</apex:commandLink>

Controller

public String bookingid {get; set;}

public PageReference passParam(){

    //navigate to visualforce page. 
    PageReference pg = Page.page1;
    pg.setRedirect(true);
    return pg;
}
6
  • Thank you Santanu. In your code, I cannot find assigning part {!$CurrentPage.parameters.bookingid}. How can I set {!$CurrentPage.parameters.bookingid} as the source for your code? Nov 29, 2018 at 8:01
  • you can get that parameter in controller itself. using ApexPages.currentPage().getParameters().get('bookingid'); Nov 29, 2018 at 8:07
  • Thank you for help but.... I adjusted what you guide me. and still value show me 'NaN' when I pop it with alert.. Nov 29, 2018 at 8:11
  • Can you pass value as my updated code Nov 29, 2018 at 8:14
  • Doesn't work.. sorry. It's really wired. I cannot understand T_T Nov 29, 2018 at 8:22

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.