You need to sign in to do that
Don't have an account?
Create more than one objects in a custom component.
Hi,
I am new in Visualforce. So I don’t know whether my question is valid or not.
Is it is possible to use more than one objects in a custom component?
My requirement is I would like to create a custom component with more than one objects like this -
For e.g.
custom component- myCmp
<apex:component >
<apex:attribute name="otxt" id="otxt"
type="String" description="This is common section
template"/>
<apex:outputText value="{!otxt}" />
<apex:attribute
name="itxt" id="itxt" type="String"
description="This is common section template"/>
<apex:inputText value="{!itxt}" />
</apex:component>
VF Page
In first VF page (VFPage_1) I need to display Output text and In second VF page (VFPage_2) I need to display input text from the component.
I tried the following way but it is not working. Both the pages are displaying both the objects.
VFPage_1
<apex:page>
<c:myCmp otxt=“Test Output Text” />
</apex:page>
VFPage_2
<apex:page>
<c:myCmp itxt=“” />
</apex:page>
Could anybody help me solve this issue.
Why not use the rendered attribute on the input and output fields.
You could either drive the values programatically, or by adding attributes.
Here is a simple way that should work:
<apex:component >
description="Should I render the input?" /><apex:attribute name="otxt" id="otxt" type="String" description="This is common section template"/>
<apex:attribute name="itxt" id="itxt" type="String" description="This is common section template"/>
<apex:attribute name="renderout" type="string" default="false" description="Should I render the output?" />
<apex:attribute name="renderin" type="string" default="false"
<apex:inputText value="{!itxt}" rendered="{!renderin}"/>
<apex:outputText value="{!otxt}" rendered="{!renderout}"/>
</apex:component>
VFPage_1 <apex:page> <c:myCmp otxt="Test Output Text" renderout="true"/> </apex:page> VFPage_2 <apex:page> <c:myCmp itxt="" renderin="true"/> </apex:page>