+ Start a Discussion
JskinJskin 

Passing parameters into visualforce components and conditional display

Hi,

We have a number of VF pages in our system which have a hardcoded reference to an address.   The address should be displayed differently dependant on region.   If there is an update to the address, we need to updat all the VF pages so I wanted to move the addresses into a component and reference the component from the VF pages.

To avoid using a controller, I am trying to set the logic in the VF page so that an attribute for the component is set to the correct region if the conditions are met:

----page----
<apex:outputpanel rendered="{!IF((Enrollment__c.Translation_Formula__c = 'China (Chinese)')&&(CONTAINS(Enrollment__c.Training_Event__r.China_Region__c, 'SW')),true,false)}">
        <c:ChinaContactsText region="SW"/>
</apex:outputpanel>
<apex:outputpanel rendered="{!IF((Enrollment__c.Translation_Formula__c = 'China (Chinese)')&&(Enrollment__c.Training_Event__r.China_Region__c = "SC:SZ"),true,false)}">
        <c:ChinaContactsText region="SC:SZ"/>
    </apex:outputpanel>

----component----
<apex:component access="global">

<apex:attribute name="region" type="string" description="regional contact" />
  
  <apex:outputText rendered="{!IF(region='SW',true,false)">
        <br/>地区 : 重庆 SW
        <br/>联系人 : Blair Chat(陈鹏博)
        <br/>电话 : +96 (0)43 6338 1111  
  </apex:outputText>
  <apex:outputText rendered="{!IF(region='SW',false,true)"> 
      not SW 
  </apex:outputText>
</apex:component>
   
However nothing gets displayed.   Is what I am trying even possible?  If so, what is the correct markup to use/try for the component?  Or is there another way to do this?
Thanks!