function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amahmamahm 

Apex Page Language attribute - Dynamic Assignment - Strange Beahviour

Following scenario: A custom label has to be displayed in a rendered PDF (display in a VF Iframe). Now - it should display the specific custom label translation language found in a controller function {!lang}. Like:
 
-1--works fine !-------------------------------------------
<apex:page controller="Account" extensions="AccExtens" Language="de" renderAs="pdf" >     
  Text: {!$LABEL.FreeTextLabel}     
</apex:page>

-2--works fine !-------------------------------------------
<apex:page controller="Account" extensions="AccExtens" Language="de" renderAs="{!renderas}" >     
  Text: {!$LABEL.FreeTextLabel}     
</apex:page>

-3--does not work!-------------------------------------------

<apex:page controller="Account" extensions="AccExtens" Language="{!lang}" renderAs="{!renderas}" >     
  Text: {!$LABEL.FreeTextLabel}     
</apex:page>

-------------------------------------------

public class AccExtens{

   public String getRenderas(){ 
      System.Debug('--renderas--');  
      return 'pdf';
   }  
   public String getLang(){ 
      System.Debug('--lang--');
      return 'de';
   }  
}

The strange part here is that code portions 1 and 2 work fine as far as the renderas call to controller is concerned. On page refesh the lang controller function gets also called as i see the debug of both lang and renderas.
I have a strange feeling that the language attribute and renderas attribute of apex:page are handled differently as far as the build up of the view state is concerned ! Can someone confirm that? And does somebody have a workaround?
amahmamahm
FYI -  i was able to solve the problem by upgrading the version number of the class and visualforce page to 41.0 -> https://salesforce.stackexchange.com/questions/205219/apex-page-language-attribute-dynamic-assignment-strange-beahviour