• YBeurier
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

I have a VF page that is being populated via a standard controller.

It works fine when all my child lines in the controller are specified.

If my controller does not return anything ( in the example - No contact role assigned to the opportunity object ) I have the 'PDF generation failed. Check the page markup is valid.' error.

 

From browsing the forum, I can see that I need to use the Rendering method, either in the <apex:repeat />  or <apex:outputField />, but i have not been able to find in which order nor which synthax.

 

Would you be able to get me an insight?

 

Below is the summarised version of my VF Page:

 

<apex:page standardController="Opportunity" showHeader="false" renderas="pdf" extensions="BSL_Layout_LinkOppLines" >
<apex:stylesheet value="{!$Resource.CSS_GeneratePDF}"/>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td  align="left"><font face="Arial" >
    <h2><b>{!Opportunity.Name}</b></h2></font>
    </td>
</tr>
</table>

<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Contact Roles / Value Chain Member</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Contact</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Account</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Phone</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Role</font></td> 
</tr>
<tr>
       <apex:repeat value="{!OpplineContactRole}" var="lineContact">
          <tr>
        <td><apex:outputField value="{!lineContact.ContactId}"/></td>
        <td><apex:outputField value="{!lineContact.Contact.AccountId}"/></td>
        <td><apex:outputField value="{!lineContact.Contact.Phone}"/></td>
        <td><apex:outputField value="{!lineContact.Role}"/></td>
          </tr>
       </apex:repeat>  
</tr>
</table>
</apex:page>

And here is my Extension Class:

 

public class BSL_Layout_LinkOppLines{

  public List<OpportunityContactRole> OpplineContactRole{get;set;}

 
  public BSL_Layout_LinkOppLines(ApexPages.StandardController controller){
                              
   OpplineContactRole=[select Id, OpportunityId, ContactId, Role, Contact.AccountId, Contact.Phone
                              from OpportunityContactRole
                              where OpportunityId =:(ApexPages.CurrentPage().getParameters().get('id'))];         
   }
       
}

 

 Thanks

 

Hi,

 

I've got a question relating to a controller extension i made for a visualforce page.

The goal is to supply the list of related object columns for generating a PDF layout using both the Opportunity fields and related object fields.

This works great, but I am now wondering how to write test classes for controller classes?

 

This is the summarised code for the controller extension.

 

public class Layout_LinkOppLines{

   public List<Tender__c> OpplineTender{get;set;}

   public Layout_LinkOppLines(ApexPages.StandardController controller){

      OpplineTender=[select Id, Linked_Project__c, Comments__c, Role__c, Tender_Win_Loss__c, Linked_Account__c 
       from Tender__C 
       where Linked_Project__c =:(ApexPages.CurrentPage().getParameters().get('id'))];
   }
}

How do I structure the Test Class to allow a good code coverage.

I have done a few test class for triggers, but none of Controller classes.

Looking at the developper help file did not bring me anywhere.

 

Thanks

I have a VF page that is being populated via a standard controller.

It works fine when all my child lines in the controller are specified.

If my controller does not return anything ( in the example - No contact role assigned to the opportunity object ) I have the 'PDF generation failed. Check the page markup is valid.' error.

 

From browsing the forum, I can see that I need to use the Rendering method, either in the <apex:repeat />  or <apex:outputField />, but i have not been able to find in which order nor which synthax.

 

Would you be able to get me an insight?

 

Below is the summarised version of my VF Page:

 

<apex:page standardController="Opportunity" showHeader="false" renderas="pdf" extensions="BSL_Layout_LinkOppLines" >
<apex:stylesheet value="{!$Resource.CSS_GeneratePDF}"/>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td  align="left"><font face="Arial" >
    <h2><b>{!Opportunity.Name}</b></h2></font>
    </td>
</tr>
</table>

<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Contact Roles / Value Chain Member</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Contact</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Account</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Phone</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Role</font></td> 
</tr>
<tr>
       <apex:repeat value="{!OpplineContactRole}" var="lineContact">
          <tr>
        <td><apex:outputField value="{!lineContact.ContactId}"/></td>
        <td><apex:outputField value="{!lineContact.Contact.AccountId}"/></td>
        <td><apex:outputField value="{!lineContact.Contact.Phone}"/></td>
        <td><apex:outputField value="{!lineContact.Role}"/></td>
          </tr>
       </apex:repeat>  
</tr>
</table>
</apex:page>

And here is my Extension Class:

 

public class BSL_Layout_LinkOppLines{

  public List<OpportunityContactRole> OpplineContactRole{get;set;}

 
  public BSL_Layout_LinkOppLines(ApexPages.StandardController controller){
                              
   OpplineContactRole=[select Id, OpportunityId, ContactId, Role, Contact.AccountId, Contact.Phone
                              from OpportunityContactRole
                              where OpportunityId =:(ApexPages.CurrentPage().getParameters().get('id'))];         
   }
       
}

 

 Thanks

 

Hi,

 

I've got a question relating to a controller extension i made for a visualforce page.

The goal is to supply the list of related object columns for generating a PDF layout using both the Opportunity fields and related object fields.

This works great, but I am now wondering how to write test classes for controller classes?

 

This is the summarised code for the controller extension.

 

public class Layout_LinkOppLines{

   public List<Tender__c> OpplineTender{get;set;}

   public Layout_LinkOppLines(ApexPages.StandardController controller){

      OpplineTender=[select Id, Linked_Project__c, Comments__c, Role__c, Tender_Win_Loss__c, Linked_Account__c 
       from Tender__C 
       where Linked_Project__c =:(ApexPages.CurrentPage().getParameters().get('id'))];
   }
}

How do I structure the Test Class to allow a good code coverage.

I have done a few test class for triggers, but none of Controller classes.

Looking at the developper help file did not bring me anywhere.

 

Thanks