1

I have an outputLink like this:

<apex:outputLink value="/apex/NewPage?id='xxxcccxxx'>
    <div class="link_class">
        <strong>Link</strong>
    </div>
</apex:outputLink> 

I want to pass an apex value through with this link to the next page, I'd like to pass it through s a hidden value if that's possible.

{!my_val}

And then catch it on the next page and throw it into a div.

I can't pass it in the URL as I need the URL to remain as it is.

Only using JS, html or APEX, is this possible?

2

If both pages use the same controller and extensions, you can actually pass the state of the page from the first to the second. You'd need to change the code from an apex:outputLink to a apex:commandLink to make this happen, though.

If you don't want to share the view state across pages (e.g. you need different controllers), you can also use localStorage or sessionStorage to store the variable in the browser's memory cache while you travel between pages. This will require cooperation on both pages, as the former will need to set the value (localStorage.setItem('somekey', 'value')), then retrieve it on NewPage (localStorage.getItem('somekey')). You can also use document.cookie for small values (less than about 4kb) for broader browser compatibility.

If you have no control over NewPage, then you're pretty much out of luck. You need a POST action for the variable to persist invisibly, which means the receiving page needs to be able to understand this POST request. Using apex:commandLink would be the easiest way to achieve your goal, especially if you can design both pages to use the same controller.

0

Here a small recipie of POC hope this may help you for the previous answer from different member. Page1

    function goTo1()
        //alert('HI');
        goTo2();            
    }
</script>
<apex:form >

    <apex:commandLink onclick="goTo1();">clickHere <br/>

        <apex:actionFunction action="{!goToVFPage2}" name="goTo2" reRender="content">
            <apex:param name="myParam" value=""/>
        </apex:actionFunction>
    </apex:commandLink>

PAGE2

capture the value you passed from the previous page

Controller

public class onePageToAnotherCarryId { public string myparam{get;set;}

public onePageToAnotherCarryId() {
    string passedParam1 = Apexpages.currentPage().getParameters().get('myParam');
    system.debug('************1 Here you are in goto'+passedParam1);

}


public onePageToAnotherCarryId(ApexPages.StandardController controller) {

}

public PageReference goToVFPage2(){


    PageReference pageref = new PageReference('/apex/vfPage2');
    system.debug('*********2 Here you are in goto');
    pageref.setRedirect(true);
    system.debug('*********3 Here you are in goto'+pageref);
    return pageref;        

}

}

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.