0

I want to pass encodeURIComponent("{!Account.Name}"); to some apex variable. How can I achieve this?

I will be using ecnocded value in my page.

4
  • use apex:param to pass parameter in apex controller. Commented Jan 17, 2017 at 5:32
  • I need to set the value to encodeURIComponent("{!Account.Name}") before passing it to controller
    – Abi
    Commented Jan 17, 2017 at 6:11
  • why you need to pass this value to controller {!Account.Name} you can directly get this value from standard controller in apex..
    – Ratan Paul
    Commented Jan 17, 2017 at 7:37
  • I want the encoded {Account.Name} value to the controller
    – Abi
    Commented Jan 17, 2017 at 8:17

1 Answer 1

1

Through the use of actionFunction with <apex:param/> you can pass value to the controler:

You can pass value as "{!Account.Name}" in the javascript method.

<script type="text/javascript">
      function displayFunc(value)
      {
           passValueToController(encodeURIComponent(value));
      }        
</script>
<apex:actionFunction name="passValueToController" action="{!passValue}" immediate="true" reRender="form1">
     <apex:param id="selectedValue" name="selectedValue" value=""/> 
</apex:actionFunction>

public void passValue()
{
      fieldValue = ApexPages.currentPage().getParameters().get('selectedValue');
      System.debug('fieldValue=' + fieldValue);     
}
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .