Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

i created a visualforce page in which actionfunction definition is

<apex:actionFunction name="setAttachment" action="{!setAttachment}" >
<apex:param name="attachmentBody" value=""/>
</apex:actionFunction>

and in my javascript code at end i am calling

      setAttachment(attachmentBody);

and setAttachment method in apex controller is

public void setAttachment()
{System.debug('coming here');
    String attachmentBody = ApexPages.currentPage().getParameters().get('attachmentBody');
    System.debug('attachment body is'+attachmentBody);
if(attachment == null)
System.debug('coming here');
attachment.Body = EncodingUtil.base64decode(attachmentBody);

}   

in logs its giving attachment body is null.but i am passing a big string in javascript code function.can anyone please tell why instead of passing string its passing null as parameter in apex controller ??

share|improve this question

1 Answer 1

up vote 2 down vote accepted

When we need to send parameter with action function then we have to use rerender attribute in otherwise we always get null value in controller.

   <apex:actionFunction name="setAttachment" action="{!setAttachment}" rerender="none" >
    <apex:param name="attachmentBody" value=""/>
    </apex:actionFunction>
share|improve this answer
    
thanks a lot :) –  user133421 Jul 7 '14 at 13:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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