You need to sign in to do that
Don't have an account?
thecoldfusion
using multiple instances of same component
Hello,
I like the concept of using custom component to encapsulate generalized UI and being able to use in more than one visual force page with different sets of data.
However, I have a situation where I use apex components, within a custom component, with id attributes. This is creating a problem when multiple instances of the custom component is used in same visual force page.
Is this a serious limitation? Something like 'prependId' attribute, of an <apex:form> tag, could help - so that unique child client-ids could be generated for all tags/components inside a custom component and provide some mechanism to refer it in attributes like 'rerender', 'status' etc (just like using {!$Component} object in a javascript DOM to access HTML objects).
My situation:
The controller class IPIBAs guarantees different sets of data with different parameters. The controller used in the page has multiple references to instances of IPIBAs created with different parameters.
Whenever I try to include two or more of this component, I get
How could visualforce ensure unique 'clientid's would be generated for child components of a custom component?
Any suggessions?
Thanks,
TheColdFusion
I like the concept of using custom component to encapsulate generalized UI and being able to use in more than one visual force page with different sets of data.
However, I have a situation where I use apex components, within a custom component, with id attributes. This is creating a problem when multiple instances of the custom component is used in same visual force page.
Is this a serious limitation? Something like 'prependId' attribute, of an <apex:form> tag, could help - so that unique child client-ids could be generated for all tags/components inside a custom component and provide some mechanism to refer it in attributes like 'rerender', 'status' etc (just like using {!$Component} object in a javascript DOM to access HTML objects).
My situation:
The controller class IPIBAs guarantees different sets of data with different parameters. The controller used in the page has multiple references to instances of IPIBAs created with different parameters.
Component Code:
<apex:component> <apex:attribute required="true" name="ipIBAs" type="IPIBAs" description="" /> <apex:outputPanel style="height:15px;" layout="block"> <apex:actionStatus startText="loading..." stopText="" id="panelIPIBAsStatusLoading" /> <apex:actionStatus startText="saving..." stopText="" id="panelIPIBAsStatusSaving" /> <apex:actionStatus startText="cancelling..." stopText="" id="panelIPIBAsStatusCancelling" /> <apex:actionStatus startText="deleting..." stopText="" id="panelIPIBAsStatusDeleting" /> </apex:outputPanel> <apex:outputPanel id="panelIPIBAs" layout="block"> <apex:form rendered="{!(ipIBAs.viewMode == 1)}"> <apex:pageBlock title="Activities :: Listings"> <apex:pageBlockButtons> <apex:commandButton value="Edit" rerender="panelIPIBAs" rendered="{!(ipIBAs.ipIBAsCount > 0)}" status="panelIPIBAsStatusLoading"> <apex:param value="2" assignTo="{!ipIBAs.viewMode}" /> </apex:commandButton> </apex:pageBlockButtons>
<!-- other fields here -->
</apex:pageBlock> </apex:form> <apex:form rendered="{!(ipIBAs.viewMode == 2)}"> <apex:pageBlock title="Activities :: Edit"> <apex:pageBlockButtons> <apex:commandButton value="Save" rerender="panelIPIBAs" action="{!ipIBAs.save}" status="panelIPIBAsStatusSaving" /> <apex:commandButton value="Cancel" rerender="panelIPIBAs" action="{!ipIBAs.cancel}" status="panelIPIBAsStatusCancelling" /> </apex:pageBlockButtons>
<!-- other fields here -->
</apex:pageBlock>
</apex:form>
<apex:form rendered="{!(ipIBAs.viewMode == 3)}">
<apex:pageBlock title="Activities :: New">
<apex:pageBlockButtons>
<apex:commandButton value="Save" rerender="panelIPIBAs" action="{!ipIBAs.saveNewRecord}" status="panelIPIBAsStatusSaving" />
<apex:commandButton value="Cancel" rerender="panelIPIBAs" action="{!ipIBAs.cancelNewRecord}" status="panelIPIBAsStatusCancelling" />
</apex:pageBlockButtons>
<!-- other fields here -->
</apex:pageBlock>
</apex:form>
<apex:form rendered="{!(ipIBAs.viewMode == 4)}">
<apex:pageBlock title="Activities :: Confirm Delete">
<apex:pageBlockButtons>
<apex:commandButton value="Yes" rerender="panelIPIBAs" action="{!ipIBAs.deleteSelected}" status="panelIPIBAsStatusDeleting" />
<apex:commandButton value="No" rerender="panelIPIBAs" action="{!ipIBAs.cancelDelete}" status="panelIPIBAsStatusCancelling" />
</apex:pageBlockButtons>
<!-- other fields here -->
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
</apex:component>
Error: Duplicate ids have been detected: 'panelIPIBAsStatusLoading'
How could visualforce ensure unique 'clientid's would be generated for child components of a custom component?
Any suggessions?
Thanks,
TheColdFusion
However that bug slipped to the bottom of the pile because we had not really seen a case yet where it couldn't be worked around. I'll look into getting it fixed but can't promise a timeframe. Any chance you can do without the actionStatus components for a bit?
I really hope this would be solved very soon. My clients like the status display during partial page updates and would like to retain the feature.
Thanks for the reply,
TheColdFusion.
Looks like this is still an issue.
Is the workaround of choice to roll your own status funtionality with javascript onclick and oncomplete events?
-Jason
I am a ratard. (Reference to the Hangover move, no disrecpt to individuals with learning disabilities ;-).
I was passing in an image URL to multiple components on a page for the status icon image but...... I wasn't passing in the url for some of them. Still might be an issue with components in repeat tags, not sure.
Hi,
There is a solution in below post of how to use multiple instances of component on VF page :
http://boards.developerforce.com/t5/Visualforce-Development/Using-same-Visualforce-components-twice/td-p/440877
please verify