Components appear to use View State even if they are not rendered.
i.e. there is almost no difference in the View State size between the following two options:
<c:my_component rendered="true"/>
<c:my_component rendered="false"/>
I have a component that conceptually does the following:
<apex:component>
<apex:attribute name="viewType" description="The view type" type="String" required="true"/>
<c:my_sub_component_1 rendered="{!viewType='A'}"/>
<c:my_sub_component_2 rendered="{!viewType='A'||viewType='B'}"/>
<c:my_sub_component_3 rendered="{!viewType='A'||viewType='C'"/>
<c:my_sub_component_4 rendered="{!viewType='B'||viewType='c'"/>
....
</apex:component>
With the downside that the View State increases from ALL the components, not just the ones that are intended to be shown.
Besides creating a separate parent Component / Page for each of the many combinations, is there any way to completely exclude some sub-components based on the attribute, such that they don't affect the View State size?