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
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">
   <body>
    <apex:form >
       <apex:pageBlock >
        <apex:stylesheet value="{!$Resource.pdfStyle2}"/>

             [...]

        </apex:pageBlock>
    </apex:form>             
   </body>
</apex:page>


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 :-)
NimitNimit
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.

Regards,
Nimit
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.

Tizian