public static Locale getLocale ( FaceletContext ctx , TagAttribute attr ) throws TagAttributeException { Object obj = attr . getObject ( ctx ) ; if ( obj instanceof Locale ) { return ( Locale ) obj ; } if ( obj instanceof String ) { String s = ( String ) obj ; if ( s . length ( ) == 2 ) { return new Locale ( s ) ; } if ( s . length ( ) == 5 ) { return new Locale ( s . substring ( 0 , 2 ) , s . substring ( 3 , 5 ) . toUpperCase ( ) ) ; } if ( s . length ( ) >= 7 ) { return new Locale ( s . substring ( 0 , 2 ) , s . substring ( 3 , 5 ) . toUpperCase ( ) , s . substring ( 6 , s . length ( ) ) ) ; } throw new TagAttributeException ( attr , "Invalid Locale Specified: " + s ) ; } else { throw new TagAttributeException ( attr , "Attribute did not evaluate to a String or Locale: " + obj ) ; } }
According to JSF 1 . 2 tag specs this helper method will use the TagAttribute passed in determining the Locale intended .