October 23, 2014

How to uploading a file as an attachment using Visual force Page and Custom Controller

Steps to Upload a File:

Step 1 : Creating a Custom object Employee.



Step 2 : Create the custom fields which required in Employee Object.



Step 3 : Create Visual force Page on Employee Object

https://c.ap1.visual.force.com/apex/UploadFileEx

Visual force Page Name: UploadFileEx



Step 4 : Write Controller for VF Page

Controller Name : UploadFileController



Step 5 : Output



Step 6 : Enter the  Details in fields



Step 7 : Records saved in Employee Object






Step 8 : Test Class for the Apex Class(UploadFileController)




Step 9 : Run the Test Class and check code coverage.

Org Name->Developer Console->Test->New Run-->Success

Code Coverage:100%



Interview Questions:

  • What is the difference between <apex:inputtext> and <apex:inputfield> ?
  • Which tag is used to upload a file in Visual force page?
  • Which annotation is used to write test class?
  • What is the syntax to write test class?
  • What is the total code coverage should be there to deploy code from Sandbox to Production?
  • What is the minimum code coverage should be there for Test Class and Trigger to do Deployment?
  • What are the attributes present in <apex:inputtext>and <apex:inputfield>?
  • What is <apex:outputpanel> and what are its attributes ?
  • What is Constructor?

No comments:

Post a Comment