You need to sign in to do that
Don't have an account?
mukesh gupta
File Uploading By Inline visualforce page
Hi Expert,
I have added a inline visualforce page on case page layout. Now i am able to upload files perfectlry, but now i want to add loader or spiner on file upload time. I add a spiner in visualforce page but when uploading compleatd. then this move on case Tab with files list not on same page.
when i add spinner or Loding then, this move to case tab with inline visualforce page.
Please suggest, what i am doing wrong
Regards
Mukesh
I have added a inline visualforce page on case page layout. Now i am able to upload files perfectlry, but now i want to add loader or spiner on file upload time. I add a spiner in visualforce page but when uploading compleatd. then this move on case Tab with files list not on same page.
<apex:page standardController="Case" extensions="UploadFileController" > <apex:form > <style type="text/css"> .bPageBlock .detailList .dataCol { width: 100%; } .bPageBlock .detailList .dataCol { width: 107%; } dataCol.first { text-align: center; } .detailList td.dataCol.first.last:nth-child(1) { text-align: right; width: 50%; } .inner-tab { padding: 20px 0px; } </style> <apex:pageMessages /> <apex:actionStatus id="pageStatus"> <apex:facet name="start"> <apex:outputPanel > <img src="/img/loading32.gif" width="50" height="50" /> <apex:outputLabel value="Loading..." /> </apex:outputPanel> </apex:facet> <apex:facet name="stop"> </apex:facet> </apex:actionStatus> <apex:pageBlock > <apex:pageBlockSection id="sec1" rendered="{!sec1}"> <apex:commandButton id="btnUpload" action="{!Upload}" value="Upload File" /> <br/> <br/> <apex:pageBlock title="File Links" id="rerenderId"> <apex:pageBlockTable value="{!listOfFiles}" var="fl" width="100%"> <apex:column headerValue="URL" width="50%"><apex:outputLink target="_blank" value="{!fl.URL__c}">{!fl.Url}</apex:outputLink></apex:column> <apex:column headerValue="Created Date" width="20%" value="{!fl.createdDate}"></apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:pageBlockSection> <div class="inner-tab"> <apex:pageBlockSection id="sec2" rendered="{!sec2}"> <apex:inputFile value="{!AttchBody}" fileName="{!AttchName}" fileSize="{!AttachSize}"/> <apex:commandButton id="btnSubmit" action="{!SubmitAttachment}" value="Submit Attachment"/> </apex:pageBlockSection> </div> </apex:pageBlock> </apex:form> </apex:page>
public with sharing class UploadFileController { Public Id RecordId {get;set;} public Blob AttchBody {get;set;} public String AttchDesc {get;set;} public String AttchName {get;set;} Public Integer AttachSize {get;set;} Public Attachment attch {get;set;} public boolean attachmentBtn {get; set;} public boolean sec1 {get;set;} public boolean sec2 {get;set;} public External_File_Relationship__c fileDB; public External_File__c ef; public List<String> fileList {get;set;} public String parentId; Public List<External_File__c>listOfFiles {get;set;} public UploadFileController(ApexPages.StandardController controller) { parentId = ((case)controller.getRecord()).id; sec1 = true; sec2 = false; RecordId = ApexPages.CurrentPage().getParameters().get('Id'); init(); } public PageReference SubmitAttachment(){ if(AttchName != '' && AttchBody != NUll ){ //file that is 25Mb or less if(AttachSize <= 25000000 ){ External__c extFile = new External__c(); extFile.Name = AttchName; extFile.CaseId__c = RecordId; Insert extFile ; attch = new Attachment(ParentId=extFile.id,Description=AttchDesc,Name=AttchName,Body=AttchBody); try{ insert attch; system.debug('attch '+attch); AttchBody = null; AttchDesc = null; AttchName = null; } catch(DMLException ex){ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment')); return null; } ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully')); string Attid= attch.id; string attachmentid=Attid.substring(0,15); String sfdcBaseURL = URL.getSalesforceBaseUrl().toExternalForm(); extFile.File_Public_URL__c = sfdcBaseURL+'/servlet/servlet.FileDownload?file='+attachmentid; update extFile; sec2 = false; sec1 = true; init(); } }else{ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, AttchName +' is too large - please choose a file that is 25Mb or less')); } return null; } public void init(){ List<External_File__c> lst = [Select URL__c, CreatedDate from External__c where CaseId__c =: RecordId]; listOfFiles = lst; } public PageReference Upload() { sec1 = false; sec2 = true; return null; } }
when i add spinner or Loding then, this move to case tab with inline visualforce page.
Please suggest, what i am doing wrong
Regards
Mukesh