You need to sign in to do that
Don't have an account?
Alex Li 26
I not sure if that the right approach, but what I trying to do is to pass an identifier along with the body of the file that the user can upload so that I can get it back later (since I have several rows and one file can be uploaded for each row).
I'm guessing that apex:param does not work in this case because inputFile is refreshing the whole page
Any idea on what's happening exactly or how I can approach this task differently ?
PS : That's not the finish code since I'm not changing the param value yet (to have a unique identifier for each file)
Passing param to controller with actionsupport and inputfile tag
<apex:actionFunction name="saveJS" action="{!save}"> <apex:param value="test" name="test"/> </apex:actionFunction> <apex:dataTable value="{!list}" var="value"> <apex:column> <apex:inputfile value="{!body}" fileName="{!name}" onchange="saveJS()"/> </apex:column> </apex:dataTable>In my controller, I have a save() method that is debugging the param "test" that I'm getting with ApexPages.currentPage().getParameters().get('test') but I'm getting null.
I not sure if that the right approach, but what I trying to do is to pass an identifier along with the body of the file that the user can upload so that I can get it back later (since I have several rows and one file can be uploaded for each row).
I'm guessing that apex:param does not work in this case because inputFile is refreshing the whole page
Any idea on what's happening exactly or how I can approach this task differently ?
PS : That's not the finish code since I'm not changing the param value yet (to have a unique identifier for each file)
Use this line of code for Action Function:
<apex:actionFunction name="saveJS" action="{!save}" reRender="none">
<apex:param value="test" name="test"/>
</apex:actionFunction>
If this code does'nt work try to implement it using java script.
<script type="text/javascript">
function funJS()
{
var text=document.getElementById("{!$Component.dt.if}").value;
saveJS(text);
}
</script>
<apex:actionFunction name="saveJS" action="{!save}" reRender="none">
<apex:param value="test" name="test"/>
</apex:actionFunction>
<apex:dataTable value="{!list}" var="value" id="dt">
<apex:column>
<apex:inputfile value="{!body}" fileName="{!name}" onchange="funJS()" id="if"/>
</apex:column>
</apex:dataTable>
Hope this will help you. Please mark it as Best Answer if you find it helpful.
Thanks.
Ajay Dubedi
@Alex - Can you give us the controller code. I would like to see how you defined getter/setter scope of the variable test. And as mentioed limitations and bugs around Inputfile, reRender and param, it is hard to tell without your controller code.