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
Kirill YunussovKirill Yunussov 

How to duplicate a block of VF code with a one liner?

is there a way to put an ID or someting on a block of code, say a couple of buttons, and then insert them again somewhere else in the page using just one line of code?  

 

something like this:

 

<apex:outputPanel id="buttons">
  <apex:commandButton value="Process" action="{!process}"/>
  <apex:commandButton value="Reverse" action="{!reverse}"/>
  <apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:outputPanel>

  ....

<apex:render value="buttons">  <!-- this here would display the buttons block again -->

 

Satish_SFDCSatish_SFDC
apex:component

This helps you to create your own reusable components, which you can reference anywhere in your code.

More Info:
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#CSHID=pages_compref_component.htm|StartTopic=Content%2Fpages_compref_component.htm|SkinName=webhelp

Regards,
Satish Kumar
Kirill YunussovKirill Yunussov

Thanks for the response.   From what I see, apex components have to be defined in a separate file.   Is there a way to define a component on the same page where it's used?

Satish_SFDCSatish_SFDC
Unfortunately, we cannot define and use a component in the same vf page.

Regards,
Satish Kumar