1

I have an actionfunction called from JavaScript

attach_file('remote_input');

I have the actionFunction tag:

         <apex:form id="content" >


              <apex:actionfunction name="attach_file" action="{!AttachFile}" reRender="">
                  <apex:param name="inputparam" value="" /> 
              </apex:actionfunction>

          </apex:form>

and in the controller i am waiting for the parameter, but i get 'null'

public pagereference AttachFile(){
        String input_param = Apexpages.currentPage().getParameters().get('inputparam');

        system.debug(input_param);

      return null;
 }

I have tried reRendering to none, # and it still does not work, I have tried displaying all the parameters received in the debug log and the 'inputparam' does not appear at all. I've tried setting the value to a global variable in the controller and it sets to null.

Any suggestions will be appreciated. Thank you

4

I have had mixed luck doing it like that (probably my own fault). However I know this works (string values):

public string paramValue {get;set;}

public pagereference AttachFile(){

        system.debug(paramValue);

      return null;
 }

and the page

<apex:actionfunction name="attach_file" action="{!AttachFile}" reRender="">
                  <apex:param name="inputparam" value="" assignTo="{!paramValue}"/> 
              </apex:actionfunction>

Update: Complete Example

Class

public class myExample{

    public string paramValue {get;set;}

    public void debugValue(){

        system.debug(paramValue);
    }


}

Page

<apex:page controller="myExample">

<script>

    function callmethod(){
        doit('test_value');
    }

</script>


    <apex:form >
        <apex:actionFunction name="doit" action="{!debugValue}" rerender="">
            <apex:param value="" name="exampleParam" assignTo="{!paramValue}"/>
        </apex:actionFunction>
        <button onclick="callmethod(); return false;">Click Me</button>
    </apex:form>

</apex:page>

Debug

13:27:43.0 (407024)|CODE_UNIT_STARTED|[EXTERNAL]|066290000008kMK|VF: /apex/myexample 13:27:43.0 (1192401)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066290000008kMK

13:27:43.0 (7590087)|VF_DESERIALIZE_VIEWSTATE_END

13:27:43.0 (8326868)|SYSTEM_MODE_ENTER|true

13:27:43.0 (9547780)|USER_DEBUG|[7]|DEBUG|test_value

So start from here and add your own code till it breaks. Then you will know what went wrong

  • I tried doing that and it still does not work =( – Lourdes Montero Sep 12 '16 at 17:23
  • 1
    @LourdesMontero - Updated with SSCCE (sscce.org) – Eric Sep 12 '16 at 17:30
  • I did what you said, and got the problem, i was using inputFile in the same form. – Lourdes Montero Sep 12 '16 at 18:17

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.