+ Start a Discussion
Tizian KirchmannTizian Kirchmann 

connect apex and visualforce

Hi guys,

I have a visualforce page looking like this:
<apex:page standardController="Rapport__c" renderAs="pdf" docType="html-5.0" showHeader="false" applyHtmlTag="false">
    <apex:form >
       <apex:pageBlock >
        <apex:stylesheet value="{!$Resource.pdfStyle2}"/>



Now I want to write some code in apex and connect it to my visualforce page.
How can you do this?

And second, I want to create a function, that activates a checkbox if the user who created the pdf clicks on the custom button to show the visualforce page because clicking the button and opening the visualforce page always means that the user is going to print the page. The boolean function for that should be something like 'vfPageIsPrinted'.

So, quick sum up:

Custom button 'Create_Rapport' clicked by user after creating a record -> checkbox 'IsPrinted?' = true

Custom button 'Create_Rapport_ NOT clicked by user after creating a record -> checkbox 'IsPrinted?' = false

Any ideas how to achieve that? 

Thanks :-)
Hi Tizian,

Use Extensions property in <apex:page> and give the class name where you want to write your apex code.

You can write an action in <apex:page> which will be a method of your class where you can update the "IsPrinted" to true and update the SObject.

Tizian KirchmannTizian Kirchmann
Hi Nimit, 

thanks for your answer. I was hoping to get a code snippet, because Im actually not able to create that code myself.

Would be highly appreciated.