3

Here's a solution using javascript. I'm also using jquery but you could modify it to select the apex:inputfile by its full ID and use vanilla javascript. It's using 500k as an arbitrary limit, but you can set it to whatever you want. The 'attachmentID' is the ID set on the apex:inputfile : if ($("[id$='attachmentID']")[0].files.length > 0) { //...


3

You can do this by handling the onchange event for the apex:inputFile element. Update your apex:inputFile to add the handler and add a container to hold the size: <apex:inputFile id="inputfile" value="{!newAtt.body}" filename="{!newAtt.name}" onchange="handleFileChange(this)/> Size: <span id="size"></span> And then add a script to handle ...


3

FWIW, this is a CSV parser with testmethods that I located from a blog post (which no longer exists) - There could easily be better ways of doing this but it handles embedded commas and double quotes. Code is ca. 2011. I've used this before public without sharing class CsvReader { // Csv Reader -- courtesy of http://blog.nicocrm.com/2011/03/06/parse-...


3

First you have to add <apex:pageMessages /> Tag after <apex:pageBlock > and then in your Apex code add this code: if(myFile == null) { ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please upload your file')); return ApexPages.CurrentPage(); } else { String theFile = myFile.toString(); // here i process the ...


3

if you don't want to use js, then you need to use two VF tags. Assuming, you want the user to enter value and setting editFlagset to true. And when you don't want the user to enter value, setting editFlagset to false. You can try the below logic <apex:inputField value="{!ObjA.inputPicklist1__c}" rendered="{!editFlag}"/> <apex:outputField value="{...


2

Better to show and hide the apex:inputField based on rendered attribute. So, when editFlag = true, you will display: <apex:inputField value="{!ObjA.inputPicklist1__c}" html-disabled="true" rendered="{!editFlag}"/> when editFlag = false, you will display: <apex:inputField value="{!ObjA.inputPicklist1__c}" rendered="{!!editFlag}"/>


2

No. This is a security feature of the browser. The user must select/input the file name, and it is read-only from JavaScript's perspective.


2

Following page utilizes Exchangeable Image File library and apex:inputfile example. Exif.getData function reads GPS data from image and stores it as description in document record. VF: <apex:page standardController="Document" extensions="documentExt" > <apex:includeScript value="{!$Resource.exif}"/> <script> function getGPSdata(e) { ...


2

The CSV file would be wiped out on reRender anyways, so you need to store the data elsewhere between actions on the page. To get the desired effect, render the spinner using client-side code, and leave the page as-is. <apex:page ...> <div id="spinner" class="slds-spinner_container slds-hidden"> <!-- rest of spinner here --> </...


1

This is a very common mistake (as I've done it myself) Your controller declares a variable public List<wrapAsset> wrapAssets{get; set;} But your action method redeclares it! public void importCSVFile(){ List<wrapAsset> wrapAssets = new List<wrapAsset>(); ... So, you are adding to a locally scoped collection and not the collection ...


1

To get the location info of the image you have to read EXIF info of the image. I do not know whether Apex has out of the box methods to do it. Any body can let me know if it is there. But you can do this with jQuery with jQuery fileEXIF plugin. Here are some tutorials links. How to get EXIF data from images using jQuery - http://rrike.sh/jquery/how-to-get-...


1

I know this is not an exact answer to your question but I think that, in consideration for heap size, you may want to change your code so the "Attach New File" button actually uploads the first attachment and then re-initializes the variable so a new file can be uploaded, instead of allowing X files to be uploaded at the same time. That way you avoid the ...


1

This is the rather classic mistake of mixing normal id values and apex id values. Apex ID values, which I like to call "managed IDs", which are prefixed and suffixed in a variety of ways depending on your code's design in order to make them globally unique, which is needed for rendering purposes (e.g. reRender, actionRegion, etc). You should use apex:...


1

Visualforce action methods can't have parameters so to avoid the error your report in your question the signature must be: public Blob contentFile {get;set;} public Contact currentRecord {get; set;} public void readFile() { // You can reference the contentFile and currentRecord fields in here ... } In your test you can set the fields before you ...


1

I suspect that at the root of your issue is that both of the below need to use the transient keyword. When you do a rerender, the view state is saved and you'll exceed it's capacity if these aren't declared as transient. You don't have the memory available to maintain their view state. public test_Object2__c testobj2{get;set;} public blob attc{get;set;}


1

So you need a getter and a setter in the controller: public String contentType { get; set; } And a matching attribute in the inputFile: <apex:inputFile id="postFileId" fileName="{!fileName}" fileSize="{!fileSize}" value="{!fileBlob}" contentType="{!contentType}" /> Ta da.


1

The reason this is happening is because of how you've structured your controller. You didn't declare your public variables along with their Apex Properties (getters and setters) before your constructor. Consequently, your constructor has to fire every time you addMore(). Try reordering your controller code to something that looks more like this: public ...


1

Here is a example on how to do form validation with Javascript in visualforce. Hope this will help. <apex:page controller="clssfpoc"> <apex:pageBlock > <apex:form > <p> <apex:outputLabel value="Father"/> </p> <apex:inputText value="{!Father}" id="fName" /> <p> <...


1

You need to remove rerender from your commandbutton tag. It will solve your problem.


1

I have got it done ! In my case putting the apex: actionfunction in another form tag outside resolved the issue. --> <apex:param id="key" name="keyValue" assignTo="{!keyValue}" value=""/> </apex:actionFunction> </apex:form> <apex:form > <apex:pageBlock id="container"> <...


1

Use below instead, rendered="{!AND(Counting != 0,Inquiry=='Inquiry')}" Update property as below, public String Inquiry { get; set { Inquiry = ApexPages.currentPage().getParameters().get('Inquiry'); System.debug('Inquiry : '+Inquiry); } }


1

Set Inquiry value outside of the setter method. Maybe in a constructor of the controller.


Only top voted, non community-wiki answers of a minimum length are eligible