Can we create a Visual force page programmatically.?

722 views Asked by At

I want to create a new Visual force page with visual force markup code

<apex:page >
<apex:iframe src="**ReportID**?isdtp=nv" scrolling="true" id="theIframe"/>
</apex:page>

Where the report will be already created programmatically and the report id from that URl is given as parameter.

Please post the details and snippets if possible, I am a very newbie to salesforce development.

Thanks In advance.

1

There are 1 answers

0
Kannan_SJD On BEST ANSWER

The following code can create a visual force page:

byte[] ContentBytes;
String Content = "<apex:page >//PageContent In Apex Code//</apex:page>";
ApexCode= Content.getBytes("UTF-8");
double version = 15.00;
com.sforce.soap.metadata.ApexPage pag = new com.sforce.soap.metadata.ApexPage();
pag.setFullName("Name");
pag.setDescription("Description");
pag.setLabel("Label");
pag.setAvailableInTouch(true);
pag.setApiVersion(version);
pag.setContent(ApexCode);
pag.setConfirmationTokenRequired(false);
Metadataconnection.create(new Apexpage[](pag);

And check the status by Checkstatus() method of metadata API.

Include the following jars wsc-XX.jar, metadata.jar, partner.jar, enterprise.jar from salesforce.