• vcass
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 12
    Replies

How can I add a stylesheet using visualforce in a apex page? I tried adding stylesheet through $Resource...But I'm not able to add the stylesheet to the apex page.Please help.

Hi all,

 

I am using Developer Edition. In i am not getting any <apex:chart> tags?

 

Can you please help me any one

 

Thanks for u r help.....

How can I add a stylesheet using visualforce in a apex page? I tried adding stylesheet through $Resource...But I'm not able to add the stylesheet to the apex page.Please help.

Hello -

 

I have developed a vf page for our sales team that shows a formatted Forecast for the opportunity. This page is embedded directly on the opportunity object in a colapsable page section called 'Forecast'. There are two buttons on the Forecast page (at the top)- one to preview the forecast in PDF form (a second vf page) and another to "Generate Forecast". This second button takes the user to a screen with a list of potential people to whom they can send the forecast (listed as checkboxes). Once the user selects the people to whom they want to send the Forecast and hit the send button, the Forecast is sent as a PDF attachment on an email to whomever they have selected. As well, the PDF is saved as an attachment on the opportunity.

 

 My issue is that while my initial tests allowed me to open and view the attachment, I now get an error when I try to open either attachment (from the email, or from the Notes & Attachments area on the opportunity). I know I must have tweaked something that is causing this error but I do not know what? The error is "File does not begin with '%PDF-'"

 

Any help would be appreciated - this is my first time working with controllers, so it might be something obvious that I am missing. I have attached the code for the page that triggers the creation of the PDF's & email, and the controller associated with it.

 

Page Code:

 

<apex:page standardController="Opportunity" Extensions="emailForecast" showHeader="false" sideBar="false">
<apex:form >
<apex:pageBlock >
<apex:pageblockSection >
<apex:outputText value="Please select the people to whom you would like to email your forecast:"/><br/><br/>
<apex:pageblockSectionItem >
<apex:selectCheckboxes value="{!Addresses}" layout="pageDirection" style="text-align:left;">
<apex:selectOptions value="{!items}"/>
</apex:selectCheckboxes>
</apex:pageblockSectionItem><br/>
<apex:commandButton value="Send" action="{!emailPeople}" status="status" />
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 Controller:

 

public class emailForecast {
ApexPages.StandardController controller;
public Opportunity q {get;set;}
public Opportunity opportunityNo {get;set;}
String op = ApexPages.currentPage().getParameters().get('id');

public emailForecast(ApexPages.StandardController c) {
controller = c;
q = (Opportunity) c.getRecord();}

public PageReference emailPeople() {
String thisOpp = ApexPages.currentPage().getParameters().get('Id');
opportunityNo = [select Opportunity_No__c, NAME,Id,OwnerId,Account.Id from Opportunity where Id = :thisOpp];

//Attach the Forecast to the Notes & Attachments Area
/* Get the page definition */
PageReference ForecastPdfPage = Page.forecast;
/* set the id on the page definition */
ForecastPdfPage.getParameters().put('Id',q.Id);
/* generate the pdf blob */
Blob ForecastPdfBlob = ForecastPdfPage.getContent();
/* create the attachment against the Opportunity */
Attachment a = new Attachment(parentId = q.id, name=opportunityNo.NAME + '-'+ opportunityNo.Opportunity_No__c+'-'+'Forecast.pdf', body = ForecastPdfBlob);
/* insert the attachment */
insert a;

// Create an email
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage ();
email.setSaveAsActivity(true);
// NEED TO FIGURE OUT HOW TO ADD TARGET ID SO WE CAN SAVE TO HISTORY - email.setTargetObjectId(opportunityNo.OwnerId);
email.setToAddresses(addresses);
email.setSenderDisplayName('New Order');
email.setSubject('New Order Created for Opportunity # ' + opportunityNo.Opportunity_No__c);
email.setPlainTextBody('A new order has been created for ' + opportunityNo.Name +' , '+ opportunityNo.Opportunity_No__c+'. The ERF and SO Approval are attached.');
email.setHtmlBody('A new order has been created for' + '&nbsp;'+'<b>'+ opportunityNo.Name +'&nbsp;'+'</b>'+ opportunityNo.Opportunity_No__c+'. The ERF and SO Approval are attached.'+
' To view this Opportunity <a href=https://na1.salesforce.com/'+ q.Id +'><b>click here</b></a>');

// Create an email attachment
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
// Set name of PDF
efa.setFileName(opportunityNo.Opportunity_No__c+'forecast.pdf');
// Set body of PDF
efa.setBody(ForecastPdfBlob);
// Attach the PDF to your email
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});

// Send email & return to Opportunity
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});


/* send the user back to the opportunity detail page */
return controller.view();


}

String[] addresses = new String[]{};

public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('email1@company.com','Person1'));
options.add(new SelectOption('email2@company.com','Person2'));
options.add(new SelectOption('email3@company.com','Person3'));
...(and so on)

return options;
}
public String[] getAddresses() {
return addresses;
}
public void setAddresses(String[] addresses) {
this.addresses = addresses;
}



}

 

 

 

Thanks

Shannon

 

 

Message Edited by Slangan on 06-10-2009 10:15 AM
Message Edited by Slangan on 06-10-2009 10:29 AM
Message Edited by Slangan on 06-10-2009 02:18 PM

I have the following trigger that simply calls a function in a class that gets a pdf blob.

 

 

trigger updOpportSendEmail on Opportunity (after insert, before update) { EditOpp.saveoppnew(trigger.new[0].ID); }

 

 

@future public static void SaveOppNew(String ID){ Opportunity OppObj = [select ID,StageName,AccountID from Opportunity where ID=:ID limit 1]; system.debug('*****'+OppObj.ID);

PageReference pdf = Page.Invoice_Email; pdf.getParameters().put('id',OppObj.ID); system.debug('*****before blob'); Blob pdfBlob = pdf.getContent(); system.debug('*****after blob');

}

 

The Id is getting pulled correctly and if I manually go the the Invoice_Email page for that opportunity everything works fine. Does anyone have any idea why pdf.getContent() is giving me the following exception?

 

 

System.VisualforceException: java.lang.NullPointerException

 

 

--Greg

 

Hello,

 

i have used following simple code for testing ExtJS Grid in VF  page.

The code is alright i think, as i have taken it from ExtJs Book.

Please let me know how will it work.

Code is below..

 

 

<script type="text/javascript">

Ext.onReady(function()

{// add your data store here

var grid = new Ext.grid.GridPanel({

renderTo: document.body,

frame:true,

title: 'Movie Database',

height:200,

width:500,

store: store,columns: [

{header: "Title", dataIndex: 'title'},

{header: "Director", dataIndex: 'director'},

{header: "Released", dataIndex: 'released',

renderer: Ext.util.Format.dateRenderer('m/d/Y')},

{header: "Genre", dataIndex: 'genre'},

{header: "Tagline", dataIndex: 'tagline'}

]

});

});

</script>

 

 

 

Message Edited by 1986anuj on 02-20-2009 07:45 AM

Hi,

 

I was trying the example provided in the visualforce pdf, about creating a tab view for the Account page. It worked fine when I just used the same but when trying to reference it with custom objects created it does not work.

The example provided in the pdf

<apex:page standardController="Account" showHeader="true" tabStyle="account" > <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} </style> <apex:tabPanel switchType="client" selectedTab="tabdetails" id="AccountTabPanel" tabClass='activeTab' inactiveTabClass='inactiveTab'> <apex:tab label="Details" name="AccDetails" id="tabdetails"> <apex:detail relatedList="false" title="true"/> </apex:tab> <apex:tab label="Contacts" name="Contacts" id="tabContact"> <apex:relatedList subject="{!account}" list="contacts" /> </apex:tab> <apex:tab label="Opportunities" name="Opportunities" id="tabOpp"> <apex:relatedList subject="{!account}" list="opportunities" /> </apex:tab> <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct"> <apex:relatedList subject="{!account}" list="OpenActivities" /> </apex:tab> <apex:tab label="Notes and Attachments" name="NotesAndAttachments" id="tabNoteAtt"> <apex:relatedList subject="{!account}" list="NotesAndAttachments" /> </apex:tab> </apex:tabPanel> </apex:page>

I am trying to do the same for some custom object. I have a Customer object called Position, there are 2 objects in the related list Job Application and Employment Website.

when I try to execute my code I get message that they are not child object for the entity.

My code is

 

<apex:page standardController="Position__c" showHeader="true"> <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} </style> <apex:tabPanel switchType="client" selectedTab="tabdetails" id="PositionTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Details" name="positionDetails" id="tabdetails"> <apex:detail relatedList="false" title="true"/> </apex:tab> <apex:tab label="Job Application" name="Job Application" id="tabjobapp"> <apex:relatedList subject="{!Position__c}" list="" /> </apex:tab> <apex:tab label="Employment Websites" name="employment websites" id="tabempweb"> <apex:relatedList subject="{!Position__c}" list="" /> </apex:tab> </apex:tabPanel> </apex:pag

  • February 20, 2009
  • Like
  • 0

 

1. How can i implement a sortable grid in VF page?

   (ie a table with sort buttons in the header)

 

 

Hi,

 

I want to pass opportunity sobject from javascript method to component class. I am able to pass string value but  not able to pass object.

 

Please help.