function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ran67ran67 

problem with apex:actionfunction

Hai all.

 

    i have small problem with apex:actionfunction . i have a requirement to upload a file to amozon server using visualforce page and also creates a record in accountdocument  

Controller:

public class abc

{

 public AccountDocuments queryvalues{get;set;}

 public  void page2onLoad() {

                      insert createid; // it creates id in amozon 

}

 

 public PageReference updatingFiledetails() 
    { 

 queryvalues=[select id,Name,Size,Type from AccountDocuments where id=:createid];

queryvalues.Name= Apexpages.currentPage().getParameters().get('one');

queryvalues.Type= same way gets file type from page using javascript to update 

queryvalues.Size=same way gets file size from page using javascript to update

update  queryvalues;

return null;

 

     }

}

}

 

Visualforce page:

<apex:page>

<input id="fileid" name="file" type="file" onchange="finalfun();"/>

<apex:actionFunction name="page2load1" action="{!page2onLoad}"/>

 

<apex:actionFunction name="hitMe" action="{!updatingFiledetails}">

<apex:param name="one" value=""/>

</apex:actionFunction>

 

<script>

function finalfun()

{

//calling the function to create id

page2load1();

..................

.................

.................

get file details using input file type

.................

................

................

//callling the function to update the record using the id

hitMe(value1,value2,value3)   // values to pass the controller to update

}

</script>

</apex:page>

 

 

it is working fine in chromo browser but it is not working some times in firefox which i want it is creating a record in accountdocument  with out updating the filename,size and type in the fields . 

the function in script hitMe() is some times calling and some times it is not calling 

i am unable to find the error in that  will you please help me in this solve i am trying this from soo many days 

Avidev9Avidev9

Had a look at your code.

Some observations

Action function seems to be accepting only one parameter

 

<apex:actionFunction name="hitMe" action="{!updatingFiledetails}">
    <apex:param name="one" value=""/>
</apex:actionFunction>

 But your code sends 3 params to the function

 

hitMe(value1,value2,value3) 

 can you correct this one ?

ran67ran67

Hai Avidev

 

  action functiom also accepting three parameters i just not worte in the code which i shown you but i have passed in my real code like

 

<apex:actionFunction name="hitMe" action="{!updatingFiledetails}">
    <apex:param name="one" value=""/>
    <apex:param name="two" value=""/>
    <apex:param name="three" value=""/>
</apex:actionFunction>

hitMe(value1,value2,value3)

 

 

 

 

 

 

Yoganand GadekarYoganand Gadekar

If you need any help on how actionfunctionworks or how to pass parameters have a look at this example

http://cloudforce4u.blogspot.in/2013/06/actionfunction-in-apex.html

 

thanks,

Avidev9Avidev9

How about using assign to with apexActionFunction

 

<apex:actionFunction name="hitMe" action="{!updatingFiledetails}" rerender="x">
    <apex:param name="one" value="" assignTo="{!variable1}"/>
    <apex:param name="two" value="" assignTo="{!variable2}"/>
    <apex:param name="three" value="" assignTo="{!variable3}"/>
</apex:actionFunction>

replace the variable names with your variable name 

 

Make sure you add a rerender attribute to actionFunction that is really important to pass the params