I'm building a Visualforce page that let's the user upload some images, they can add as many images as they want, when they click on the "add new" button, a new record is inserted and one of the record fields is the path where it'll be uploaded to.

Here's the button and the action related:

<apex:form >
        <apex:actionFunction action="{!createFile}" name="createRecord" reRender="none"/> 

<input class="btn" type="button" id="add-btn" value="{!$Label.Add_New}" onclick="createRecord()" />

and the createRecord method:

public String fileName {get;set;}

public void createFile(){
    String folder = ApexPages.currentPage().getParameters().get('orgId');
    try {
        Custom_Object__c file = new Custom_Object__c();
    //Some fields get assigned
        insert file;

        Transient Custom_Object__c tmpFile = [SELECT Path__c FROM Custom_Object__c WHERE Id = :file.Id limit 1];
        fileName = folder + tmpFile.Path__c + ‘.jpg’;
    } catch (DMLException e){
        System.debug('DML EXCEPTION: ' + e);
    } catch (QueryException e) {
        System.debug('Query EXCEPTION: ' + e);

Then I'm getting the fileNamevalue in order to upload the file.

    method="post" enctype="multipart/form-data" >
    <input type="hidden" name="key"  value="{!fileName}" /> 

    <input type="file" size="255" name="file" />
    <input class="btn" type="submit" value="{!$Label.Upload}"/>

The problem is that when I called the createRecordfunction with the reRender="none" to prevent it from refresh the entire page, the {!fileName} call doesn't get the just updated value. When I remove the reRender="none" it gets the new value just fine, I need it to get the new value without refreshing the entire page, how can I do this?

1 Answer 1


I think you are confused about what rerender does. It let's you specify what you want to rerender.

Give your form an Id and then do your rerender="formId". This will rerender that section of the page and so update the value.

<form action="https://someurl.com/" method="post" enctype="multipart/form-data" id="formId">


<apex:actionFunction action="{!createFile}" name="createRecord" reRender="formId" />
  • Just tried it and didn't work.
    – Jose
    Commented May 30, 2014 at 15:59
  • your answer didn't work, but gave me an idea, I placed the <form> tag inside an <apex:outputPanel>and called it in the <apex:actionFunction action="{!createFile}" name="createRecord" reRender="upload-panel" /> and it worked perfect. Thanks a lot.
    – Jose
    Commented May 30, 2014 at 16:21
  • Glad i could help!
    – dphil
    Commented May 30, 2014 at 17:05

You must log in to answer this question.

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