Question: How do you use composition and define tags in templates?
Answer:
Composition tag used to embed template in our visual force page. Means we can create visual force having only form and page, controller tag and just used insert tag in this page. Another (where this is going to invoke the first template) visual force page defining this inserts tag by using composition tag.
<apex: composition> tag must contains at least one or more <apex: define> tag. We can write in define output label, text fields etc. For example:
<apex:page controller="CompositionController">
<apex:composition template="{!myTemplate}">
<apex:define name="First Name">
<apex:outputLabel value="First Name"/>
<apex:inputText id="fname" value="{!fname}"/>
</apex:define>
</apex:composition>
</apex:page>
Another page:
<apex:page controller="CompositionController">
<apex:form >
<apex:insert name="First Name"></apex:insert>
<br/><br/>
</apex:form>
</apex:page>
Above example calls dynamic template name through getter define in controller.
No comments:
Post a Comment