[SalesForce] Apex:param not sending parameter in actionFunction

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

Best Answer

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