function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DomeForceDomeForce 

Where do you add a page controller in code

Totally new to code, I am trying to integrate DYMO LabelWriter Printer into Salesforce.com

 

The direction say to paste the follow code into the page editior:

 

<apex:page id="printAddressPage" standardController="Contact" extensions="PrintAddressExtension">
    <apex:includeScript value="{!$Resource.DymoFramework}"/>

    <div style="padding-bottom:6px">
        <apex:outputLink value="{!URLFOR($Action.Contact.View, $CurrentPage.parameters.id)}">
            Back to {!paObject.Contact.FirstName} {!paObject.Contact.LastName} detail page
        </apex:outputLink>
    </div>

    <apex:form >
    </apex:form>

</apex:page>

 

The next intruction says to create a singleton: paObject, but were in the above code to paste the following:

 

 

public class PrintAddressExtension

{

public PrintAddressExtension(ApexPages.StandardController controller)

{

 }

public class PaObject

{

private Contact m_contact; public PaObject() { Id id = System.currentPageReference().getParameters().get('id'); m_contact = id == null ? new Contact() : [Select Id, FirstName, LastName, MailingStreet, MailingCity, MailingState, MailingCountry, MailingPostalCode FROM Contact WHERE Id = :id]; } public Contact getContact() { return m_contact; } // contact full name public String getContactFullName() { if (m_contact == null) { system.Debug(logginglevel.ERROR, 'PaObject.m_contact is null'); return ''; } return m_contact.LastName + ', ' + m_contact.FirstName; } } private paObject m_paObject; public PaObject getPaObject() { if (m_paObject == null) { m_paObject = new PaObject(); System.debug(logginglevel.INFO, 'singleton PaObject is created'); } return m_paObject; } }

 

 

 

loveLearningloveLearning

Go to setup and under setup develop -> apex classes

Create new class with name as PrintAddressExtension

 

And copy paste thefollowing code and save it.

 

public class PrintAddressExtension

{

public PrintAddressExtension(ApexPages.StandardController controller)

{

 }

public class PaObject

{

private Contact m_contact; public PaObject() { Id id = System.currentPageReference().getParameters().get('id'); m_contact = id == null ? new Contact() : [Select Id, FirstName, LastName, MailingStreet, MailingCity, MailingState, MailingCountry, MailingPostalCode FROM Contact WHERE Id = :id]; } public Contact getContact() { return m_contact; } // contact full name public String getContactFullName() { if (m_contact == null) { system.Debug(logginglevel.ERROR, 'PaObject.m_contact is null'); return ''; } return m_contact.LastName + ', ' + m_contact.FirstName; } } private paObject m_paObject; public PaObject getPaObject() { if (m_paObject == null) { m_paObject = new PaObject(); System.debug(logginglevel.INFO, 'singleton PaObject is created'); } return m_paObject; } }

 

 

 

then open the visual force page which u have used and save it 


<apex:page id="printAddressPage" standardController="Contact" extensions="PrintAddressExtension">
    <apex:includeScript value="{!$Resource.DymoFramework}"/>

    <div style="padding-bottom:6px">
        <apex:outputLink value="{!URLFOR($Action.Contact.View, $CurrentPage.parameters.id)}">
            Back to {!paObject.Contact.FirstName} {!paObject.Contact.LastName} detail page
        </apex:outputLink>
    </div>

    <apex:form >
    </apex:form>

</apex:page>