Coverage Report - org.apache.myfaces.shared_impl.config.MyfacesConfig
 
Classes in this File Line Coverage Branch Coverage Complexity
MyfacesConfig
0%
0/132
0%
0/48
0
 
 1  
 /*
 2  
  *  Licensed to the Apache Software Foundation (ASF) under one
 3  
  *  or more contributor license agreements.  See the NOTICE file
 4  
  *  distributed with this work for additional information
 5  
  *  regarding copyright ownership.  The ASF licenses this file
 6  
  *  to you under the Apache License, Version 2.0 (the
 7  
  *  "License"); you may not use this file except in compliance
 8  
  *  with the License.  You may obtain a copy of the License at
 9  
  * 
 10  
  *  http://www.apache.org/licenses/LICENSE-2.0
 11  
  * 
 12  
  *  Unless required by applicable law or agreed to in writing,
 13  
  *  software distributed under the License is distributed on an
 14  
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  *  KIND, either express or implied.  See the License for the
 16  
  *  specific language governing permissions and limitations
 17  
  *  under the License.
 18  
  */
 19  
 package org.apache.myfaces.shared_impl.config;
 20  
 
 21  
 import org.apache.commons.logging.Log;
 22  
 import org.apache.commons.logging.LogFactory;
 23  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
 24  
 import org.apache.myfaces.shared_impl.util.ClassUtils;
 25  
 
 26  
 import javax.faces.context.ExternalContext;
 27  
 import javax.servlet.ServletContext;
 28  
 
 29  
 /**
 30  
  * Holds all configuration init parameters (from web.xml) that are independent
 31  
  * from the core implementation. The parameters in this class are available to
 32  
  * all shared, component and implementation classes.
 33  
  * See RuntimeConfig for configuration infos that come from the faces-config
 34  
  * files and are needed by the core implementation.
 35  
  *
 36  
  * MyfacesConfig is meant for components that implement some of the extended features
 37  
  * of MyFaces. Anyhow, using the MyFaces JSF implementation is no precondition for using
 38  
  * MyfacesConfig in custom components. Upon using another JSF implementation
 39  
  * (or omitting the extended init parameters) all config properties will simply have
 40  
  * their default values.
 41  
  *
 42  
  * @author Manfred Geiler (latest modification by $Author: lu4242 $)
 43  
  * @version $Revision: 941950 $ $Date: 2010-05-06 17:03:41 -0500 (Thu, 06 May 2010) $
 44  
  */
 45  0
 public class MyfacesConfig
 46  
 {
 47  0
     private static final Log log = LogFactory.getLog(MyfacesConfig.class);
 48  
 
 49  0
     private static final String APPLICATION_MAP_PARAM_NAME = MyfacesConfig.class.getName();
 50  
 
 51  
     public static final String  INIT_PARAM_RESOURCE_VIRTUAL_PATH = "org.apache.myfaces.RESOURCE_VIRTUAL_PATH";
 52  
     public static final String  INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT = "/faces/myFacesExtensionResource";
 53  
 
 54  
     /**
 55  
      * If true, rendered HTML code will be formatted, so that it is "human readable".
 56  
      * i.e. additional line separators and whitespace will be written, that do not
 57  
      * influence the HTML code. Default: "true"
 58  
      */
 59  
     @JSFWebConfigParam(defaultValue="true", expectedValues="true,false",since="1.1")
 60  
     private static final String  INIT_PARAM_PRETTY_HTML = "org.apache.myfaces.PRETTY_HTML";
 61  
     private static final boolean INIT_PARAM_PRETTY_HTML_DEFAULT = true;
 62  
 
 63  
     /**
 64  
      * This parameter tells MyFaces if javascript code should be allowed in the rendered HTML output.
 65  
      * If javascript is allowed, command_link anchors will have javascript code 
 66  
      * that submits the corresponding form.
 67  
      * If javascript is not allowed, the state saving info and nested parameters ill be 
 68  
      * added as url parameters.
 69  
      * Default: "true"
 70  
      */
 71  
     @JSFWebConfigParam(defaultValue="true", expectedValues="true,false",since="1.1")
 72  
     private static final String  INIT_PARAM_ALLOW_JAVASCRIPT = "org.apache.myfaces.ALLOW_JAVASCRIPT";
 73  
     private static final boolean INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT = true;
 74  
 
 75  
     /**
 76  
      * 
 77  
      */
 78  
     @JSFWebConfigParam(defaultValue="false", expectedValues="true,false",since="1.1")
 79  
     private static final String  INIT_PARAM_DETECT_JAVASCRIPT = "org.apache.myfaces.DETECT_JAVASCRIPT";
 80  
     private static final boolean INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT = false;
 81  
 
 82  
     /**
 83  
      * If true, a javascript function will be rendered that is able to restore the 
 84  
      * former vertical scroll on every request. Convenient feature if you have pages
 85  
      * with long lists and you do not want the browser page to always jump to the top
 86  
      * if you trigger a link or button action that stays on the same page.
 87  
      * Default: "false"
 88  
      */
 89  
     @JSFWebConfigParam(defaultValue="false", expectedValues="true,false",since="1.1")
 90  
     private static final String  INIT_PARAM_AUTO_SCROLL = "org.apache.myfaces.AUTO_SCROLL";
 91  
     private static final boolean INIT_PARAM_AUTO_SCROLL_DEFAULT = false;
 92  
 
 93  
     /**
 94  
      * Tomahawk specific: A class implementing the
 95  
      * org.apache.myfaces.shared_impl.renderkit.html.util.AddResource
 96  
      * interface. It is responsible to
 97  
      * place scripts and css on the right position in your HTML document.
 98  
      * Default: "org.apache.myfaces.shared_impl.renderkit.html.util.DefaultAddResource"
 99  
      * Follow the description on the MyFaces-Wiki-Performance page to enable
 100  
      * StreamingAddResource instead of DefaultAddResource if you want to
 101  
      * gain performance.
 102  
      */
 103  
     @JSFWebConfigParam(defaultValue="org.apache.myfaces.renderkit.html.util.DefaultAddResource",since="1.1")
 104  
     private static final String INIT_PARAM_ADD_RESOURCE_CLASS = "org.apache.myfaces.ADD_RESOURCE_CLASS";
 105  
     private static final String INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT = "org.apache.myfaces.renderkit.html.util.DefaultAddResource";
 106  
 
 107  
     /**
 108  
      * Tomahawk specific: A very common problem in configuring MyFaces-web-applications
 109  
      * is that the Extensions-Filter is not configured at all
 110  
      * or improperly configured. This parameter will check for a properly
 111  
      * configured Extensions-Filter if it is needed by the web-app.
 112  
      * In most cases this check will work just fine, there might be cases
 113  
      * where an internal forward will bypass the Extensions-Filter and the check
 114  
      * will not work. If this is the case, you can disable the check by setting
 115  
      * this parameter to false.
 116  
      */
 117  
     @JSFWebConfigParam(defaultValue="true", expectedValues="true,false",since="1.1")
 118  
     private static final String  INIT_CHECK_EXTENSIONS_FILTER = "org.apache.myfaces.CHECK_EXTENSIONS_FILTER";
 119  
     private static final boolean INIT_CHECK_EXTENSIONS_FILTER_DEFAULT = true;
 120  
 
 121  
     /**
 122  
      * 
 123  
      */
 124  
     @JSFWebConfigParam(defaultValue="true", expectedValues="true,false",since="1.1")
 125  
     private static final String INIT_READONLY_AS_DISABLED_FOR_SELECT = "org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS";
 126  
     private static final boolean INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT = true;
 127  
 
 128  
     /**
 129  
      * 
 130  
      */
 131  
     @JSFWebConfigParam(defaultValue="2",since="1.1")
 132  
     public static final String INIT_PARAM_CONFIG_REFRESH_PERIOD = "org.apache.myfaces.CONFIG_REFRESH_PERIOD";
 133  
     public static final long INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT = 2;
 134  
 
 135  
     /**
 136  
      * 
 137  
      */
 138  
     @JSFWebConfigParam(defaultValue="false", expectedValues="true,false",since="1.1")
 139  
     private static final String  INIT_PARAM_VIEWSTATE_JAVASCRIPT = "org.apache.myfaces.VIEWSTATE_JAVASCRIPT";
 140  
     private static final boolean INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT = false;
 141  
 
 142  
     /**
 143  
      * 
 144  
      */
 145  
     @JSFWebConfigParam(defaultValue="true", expectedValues="true,false",since="1.1")
 146  
     private static final String  INIT_PARAM_RENDER_VIEWSTATE_ID = "org.apache.myfaces.RENDER_VIEWSTATE_ID";
 147  
     private static final boolean INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT = true;
 148  
 
 149  
     /**
 150  
      * 
 151  
      */
 152  
     @JSFWebConfigParam(defaultValue="true", expectedValues="true,false",since="1.1")
 153  
     private static final String  INIT_PARAM_STRICT_XHTML_LINKS = "org.apache.myfaces.STRICT_XHTML_LINKS";
 154  
     private static final boolean INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT = true;
 155  
     
 156  
     /**
 157  
      * This param renders the clear javascript on button necessary only for
 158  
      * compatibility with hidden fields feature of myfaces. This is done 
 159  
      * because jsf ri does not render javascript on onclick method for button,
 160  
      * so myfaces should do this.
 161  
      */
 162  
     @JSFWebConfigParam(defaultValue="false", expectedValues="true,false",since="1.2.3")
 163  
     private static final String INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON = "org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON";
 164  
     private static final boolean INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT= false;
 165  
 
 166  
     /**
 167  
      * This param renders hidden fields at the end of h:form for link params when h:commandLink + f:param is used, instead
 168  
      * use javascript to create them. Set this param to true also enables org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON 
 169  
      * automatically to ensure consistency. This feature is required to support Windows Mobile 6, because in this environment,
 170  
      * document.createElement() and form.appendChild() javascript methods are not supported.
 171  
      */
 172  
     @JSFWebConfigParam(defaultValue="false", expectedValues="true,false",since="1.2.9")
 173  
     private static final String INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS = "org.apache.myfaces.RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS";
 174  
     private static final boolean INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT= false;
 175  
     
 176  
     /**
 177  
      * Add a code that save the form before submit using a
 178  
      * link (call to window.external.AutoCompleteSaveForm(form) ). It's a bug on IE.
 179  
      */
 180  
     @JSFWebConfigParam(defaultValue="false", expectedValues="true,false",since="1.1")
 181  
     private static final String INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE = "org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE";
 182  
     private static final boolean INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT = false;
 183  
     
 184  
     /**
 185  
      * 
 186  
      */
 187  
     @JSFWebConfigParam(since="1.2.7")
 188  
     private static final String INIT_PARAM_DELEGATE_FACES_SERVLET = "org.apache.myfaces.DELEGATE_FACES_SERVLET";
 189  
 
 190  
     private boolean _prettyHtml;
 191  
     private boolean _detectJavascript;
 192  
     private boolean _allowJavascript;
 193  
     private boolean _autoScroll;
 194  
     private String _addResourceClass;
 195  
     private String _resourceVirtualPath;
 196  
     private boolean _checkExtensionsFilter;
 197  
     private boolean _readonlyAsDisabledForSelect;
 198  
     private long _configRefreshPeriod;
 199  
     private boolean _viewStateJavascript;
 200  
     private boolean _renderViewStateId;
 201  
     private boolean _strictXhtmlLinks;
 202  
     private boolean _renderClearJavascriptOnButton;
 203  
     private boolean renderHiddenFieldsForLinkParams;
 204  
     private boolean _saveFormSubmitLinkIE;
 205  
     private String _delegateFacesServlet;
 206  
 
 207  
 
 208  
     private static final boolean TOMAHAWK_AVAILABLE;
 209  
     private static final boolean MYFACES_IMPL_AVAILABLE;
 210  
     private static final boolean RI_IMPL_AVAILABLE;
 211  
 
 212  
     static
 213  
     {
 214  
         boolean tomahawkAvailable;
 215  
         try
 216  
         {
 217  0
             ClassUtils.classForName("org.apache.myfaces.webapp.filter.ExtensionsFilter");
 218  0
             tomahawkAvailable = true;
 219  
         }
 220  0
         catch (ClassNotFoundException e)
 221  
         {
 222  0
             tomahawkAvailable = false;
 223  0
         }
 224  0
         TOMAHAWK_AVAILABLE = tomahawkAvailable;
 225  
     }
 226  
 
 227  
     static
 228  
     {
 229  
         boolean myfacesImplAvailable;
 230  
         try
 231  
         {
 232  0
             ClassUtils.classForName("org.apache.myfaces.application.ApplicationImpl");
 233  0
             myfacesImplAvailable = true;
 234  
         }
 235  0
         catch (ClassNotFoundException e)
 236  
         {
 237  0
             myfacesImplAvailable = false;
 238  0
         }
 239  0
         MYFACES_IMPL_AVAILABLE = myfacesImplAvailable;
 240  
     }
 241  
 
 242  
     static
 243  
     {
 244  
         boolean riImplAvailable;
 245  
         try
 246  
         {
 247  0
             ClassUtils.classForName("com.sun.faces.application.ApplicationImpl");
 248  0
             riImplAvailable = true;
 249  
         }
 250  0
         catch (ClassNotFoundException e)
 251  
         {
 252  0
             riImplAvailable = false;
 253  0
         }
 254  0
         RI_IMPL_AVAILABLE = riImplAvailable;
 255  0
     }
 256  
 
 257  
     public static MyfacesConfig getCurrentInstance(ExternalContext extCtx)
 258  
     {
 259  0
         MyfacesConfig myfacesConfig = (MyfacesConfig) extCtx
 260  
                 .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
 261  0
         if (myfacesConfig == null)
 262  
         {
 263  
 
 264  0
             myfacesConfig = createAndInitializeMyFacesConfig(extCtx);
 265  
 
 266  0
             extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, myfacesConfig);
 267  
 
 268  
         }
 269  
 
 270  0
         return myfacesConfig;
 271  
     }
 272  
 
 273  
     private static MyfacesConfig createAndInitializeMyFacesConfig(ExternalContext extCtx) {
 274  
         
 275  0
         MyfacesConfig myfacesConfig = new MyfacesConfig();
 276  
 
 277  0
         myfacesConfig.setPrettyHtml(getBooleanInitParameter(extCtx, INIT_PARAM_PRETTY_HTML,
 278  
                                                             INIT_PARAM_PRETTY_HTML_DEFAULT));
 279  0
         myfacesConfig.setAllowJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_ALLOW_JAVASCRIPT,
 280  
                                                                  INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT));
 281  
 
 282  0
         myfacesConfig.setRenderClearJavascriptOnButton(getBooleanInitParameter(extCtx, INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON,
 283  
                                                             INIT_PARAM_RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON_DEFAULT));
 284  
 
 285  0
         myfacesConfig.setRenderHiddenFieldsForLinkParams(getBooleanInitParameter(extCtx, INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS,
 286  
                 INIT_PARAM_RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS_DEFAULT));
 287  
 
 288  0
         myfacesConfig.setSaveFormSubmitLinkIE(getBooleanInitParameter(extCtx, INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE,
 289  
                                                             INIT_PARAM_SAVE_FORM_SUBMIT_LINK_IE_DEFAULT));
 290  
         
 291  0
         myfacesConfig.setReadonlyAsDisabledForSelect(getBooleanInitParameter(extCtx, INIT_READONLY_AS_DISABLED_FOR_SELECT,
 292  
                                                                  INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT));
 293  0
         myfacesConfig.setRenderViewStateId(getBooleanInitParameter(extCtx, INIT_PARAM_RENDER_VIEWSTATE_ID,
 294  
                                                                    INIT_PARAM_RENDER_VIEWSTATE_ID_DEFAULT));
 295  0
         myfacesConfig.setStrictXhtmlLinks(getBooleanInitParameter(extCtx, INIT_PARAM_STRICT_XHTML_LINKS,
 296  
                                                                   INIT_PARAM_STRICT_XHTML_LINKS_DEFAULT));
 297  
 
 298  0
         myfacesConfig.setConfigRefreshPeriod(getLongInitParameter(extCtx, INIT_PARAM_CONFIG_REFRESH_PERIOD,
 299  
                 INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT));
 300  
 
 301  0
         myfacesConfig.setViewStateJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_VIEWSTATE_JAVASCRIPT,
 302  
                 INIT_PARAM_VIEWSTATE_JAVASCRIPT_DEFAULT));
 303  
 
 304  0
         myfacesConfig.setDelegateFacesServlet(extCtx.getInitParameter(INIT_PARAM_DELEGATE_FACES_SERVLET));
 305  
 
 306  0
         if (TOMAHAWK_AVAILABLE)
 307  
         {
 308  0
             myfacesConfig.setDetectJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_DETECT_JAVASCRIPT,
 309  
                     INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT));
 310  0
             myfacesConfig.setAutoScroll(getBooleanInitParameter(extCtx, INIT_PARAM_AUTO_SCROLL,
 311  
                     INIT_PARAM_AUTO_SCROLL_DEFAULT));
 312  
                         
 313  0
             myfacesConfig.setAddResourceClass(getStringInitParameter(extCtx, INIT_PARAM_ADD_RESOURCE_CLASS,
 314  
                     INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT));
 315  0
             myfacesConfig.setResourceVirtualPath(getStringInitParameter(extCtx, INIT_PARAM_RESOURCE_VIRTUAL_PATH,
 316  
                     INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT));
 317  
 
 318  0
             myfacesConfig.setCheckExtensionsFilter(getBooleanInitParameter(extCtx, INIT_CHECK_EXTENSIONS_FILTER,
 319  
                     INIT_CHECK_EXTENSIONS_FILTER_DEFAULT));
 320  
         }
 321  
         else
 322  
         {
 323  0
             if (log.isInfoEnabled())
 324  
             {
 325  0
                 log.info("Tomahawk jar not available. Autoscrolling, DetectJavascript, AddResourceClass and CheckExtensionsFilter are disabled now.");
 326  
             }
 327  
         }
 328  
 
 329  0
         if(RI_IMPL_AVAILABLE)
 330  
         {
 331  0
             if(log.isInfoEnabled())
 332  
             {
 333  0
                 log.info("Starting up Tomahawk on the RI-JSF-Implementation.");
 334  
             }
 335  
         }
 336  
 
 337  0
         if(MYFACES_IMPL_AVAILABLE)
 338  
         {
 339  0
             if(log.isInfoEnabled())
 340  
             {
 341  0
                 log.info("Starting up Tomahawk on the MyFaces-JSF-Implementation");
 342  
             }
 343  
         }
 344  
 
 345  0
         if(RI_IMPL_AVAILABLE && MYFACES_IMPL_AVAILABLE)
 346  
         {
 347  0
             log.error("Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.");
 348  
         }
 349  0
         return myfacesConfig;
 350  
     }
 351  
 
 352  
     private static boolean getBooleanInitParameter(ExternalContext externalContext,
 353  
                                                    String paramName,
 354  
                                                    boolean defaultValue)
 355  
     {
 356  0
         String strValue = externalContext.getInitParameter(paramName);
 357  0
         if (strValue == null)
 358  
         {
 359  0
             if (log.isInfoEnabled()) log.info("No context init parameter '" + paramName + "' found, using default value " + defaultValue);
 360  0
             return defaultValue;
 361  
         }
 362  0
         else if (strValue.equalsIgnoreCase("true") || strValue.equalsIgnoreCase("on") || strValue.equalsIgnoreCase("yes"))
 363  
         {
 364  0
             return true;
 365  
         }
 366  0
         else if (strValue.equalsIgnoreCase("false") || strValue.equalsIgnoreCase("off") || strValue.equalsIgnoreCase("no"))
 367  
         {
 368  0
             return false;
 369  
         }
 370  
         else
 371  
         {
 372  0
             if (log.isWarnEnabled()) log.warn("Wrong context init parameter '" + paramName + "' (='" + strValue + "'), using default value " + defaultValue);
 373  0
             return defaultValue;
 374  
         }
 375  
     }
 376  
 
 377  
     private static String getStringInitParameter(ExternalContext externalContext,
 378  
                                                  String paramName,
 379  
                                                  String defaultValue)
 380  
     {
 381  0
         String strValue = externalContext.getInitParameter(paramName);
 382  0
         if (strValue == null)
 383  
         {
 384  0
             if (log.isInfoEnabled()) log.info("No context init parameter '" + paramName + "' found, using default value " + defaultValue); //defaultValue==null should not be a problem here
 385  0
             return defaultValue;
 386  
         }
 387  
         
 388  0
         return strValue;
 389  
     }
 390  
 
 391  
     private static long getLongInitParameter(ExternalContext externalContext,
 392  
                                                   String paramName,
 393  
                                                   long defaultValue) {
 394  0
        String strValue = externalContext.getInitParameter(paramName);
 395  0
        if (strValue == null)
 396  
        {
 397  0
            if (log.isInfoEnabled()) log.info("No context init parameter '" +paramName +"' found, using default value " +defaultValue);
 398  0
            return defaultValue;
 399  
        }
 400  
        else
 401  
        {
 402  
            try {
 403  0
                return Long.parseLong(strValue);
 404  0
            } catch (NumberFormatException e) {
 405  0
                if (log.isWarnEnabled()) log.warn("Wrong context init parameter '" + paramName + "' (='" + strValue + "'), using default value " + defaultValue);
 406  
            }
 407  0
            return defaultValue;
 408  
        }
 409  
     }
 410  
         
 411  
      private void setResourceVirtualPath( String resourceVirtualPath )
 412  
      {
 413  0
          this._resourceVirtualPath = resourceVirtualPath;
 414  0
     }
 415  
 
 416  
      public String getResourceVirtualPath()
 417  
      {
 418  0
          return this._resourceVirtualPath;
 419  
      }
 420  
 
 421  
     public boolean isPrettyHtml()
 422  
     {
 423  0
         return _prettyHtml;
 424  
     }
 425  
 
 426  
     private void setPrettyHtml(boolean prettyHtml)
 427  
     {
 428  0
         _prettyHtml = prettyHtml;
 429  0
     }
 430  
 
 431  
     public boolean isDetectJavascript()
 432  
     {
 433  0
         return _detectJavascript;
 434  
     }
 435  
 
 436  
     private void setDetectJavascript(boolean detectJavascript)
 437  
     {
 438  0
         _detectJavascript = detectJavascript;
 439  0
     }
 440  
 
 441  
     private void setReadonlyAsDisabledForSelect(boolean readonlyAsDisabledForSelect)
 442  
     {
 443  0
         _readonlyAsDisabledForSelect = readonlyAsDisabledForSelect;
 444  0
     }
 445  
 
 446  
     public boolean isReadonlyAsDisabledForSelect()
 447  
     {
 448  0
         return _readonlyAsDisabledForSelect;
 449  
     }
 450  
 
 451  
 
 452  
    public long getConfigRefreshPeriod()
 453  
    {
 454  0
        return _configRefreshPeriod;
 455  
    }
 456  
 
 457  
    public void setConfigRefreshPeriod(long configRefreshPeriod)
 458  
    {
 459  0
        _configRefreshPeriod = configRefreshPeriod;
 460  0
    }
 461  
 
 462  
     /**
 463  
      * JSF API 1.2 defines a "javax.faces.ViewState" client parameter, that must be rendered as both the "name"
 464  
      * and the "id" attribute of the hidden input that is rendered for the purpose of state saving
 465  
      * (see <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/faces/render/ResponseStateManager.html#VIEW_STATE_PARAM">API</a>).
 466  
      * Actually this causes duplicate id attributes and thus invalid XHTML pages when multiple forms are rendered on
 467  
      * one page. With the {@link #INIT_PARAM_RENDER_VIEWSTATE_ID} context parameter you can tune this behaviour.
 468  
      * <br/>Set it to
 469  
      * <ul><li>true - to render JSF 1.2 compliant id attributes (that might cause invalid XHTML), or</li>
 470  
      * <li>false - to omit rendering of the id attribute (which is only needed for very special AJAX/Javascript components)</li></ul>
 471  
      * Default value is: true (for backwards compatibility and JSF 1.2 compliancy) 
 472  
      * @return true, if the client state hidden input "javax.faces.ViewState" id attribute should be rendered
 473  
      */
 474  
     public boolean isRenderViewStateId() {
 475  0
         return _renderViewStateId;
 476  
     }
 477  
 
 478  
     public void setRenderViewStateId(boolean renderViewStateId) {
 479  0
         _renderViewStateId = renderViewStateId;
 480  0
     }
 481  
 
 482  
     /**
 483  
      * <p>W3C recommends to use the "&amp;amp;" entity instead of a plain "&amp;" character within HTML.
 484  
      * This also applies to attribute values and thus to the "href" attribute of &lt;a&gt; elements as well.
 485  
      * Even more, when XHTML is used as output the usage of plain "&amp;" characters is forbidden and would lead to
 486  
      * invalid XML code.
 487  
      * Therefore, since version 1.1.6 MyFaces renders the correct "&amp;amp;" entity for links.</p>
 488  
      * <p>The init parameter
 489  
      * {@link #INIT_PARAM_STRICT_XHTML_LINKS} makes it possible to restore the old behaviour and to make MyFaces
 490  
      * "bug compatible" to the Sun RI which renders plain "&amp;" chars in links as well.</p>
 491  
      * @see <a href="http://www.w3.org/TR/html401/charset.html#h-5.3.2">HTML 4.01 Specification</a>
 492  
      * @see <a href="http://issues.apache.org/jira/browse/MYFACES-1774">Jira: MYFACES-1774</a>
 493  
      * @return true if ampersand characters ("&amp;") should be correctly rendered as "&amp;amp;" entities within link urls (=default),
 494  
      *         false for old (XHTML incompatible) behaviour
 495  
      */
 496  
     public boolean isStrictXhtmlLinks() {
 497  0
         return _strictXhtmlLinks;
 498  
     }
 499  
 
 500  
     public void setStrictXhtmlLinks(boolean strictXhtmlLinks) {
 501  0
         _strictXhtmlLinks = strictXhtmlLinks;
 502  0
     }
 503  
 
 504  
     public boolean isTomahawkAvailable()
 505  
     {
 506  0
         return TOMAHAWK_AVAILABLE;
 507  
     }
 508  
 
 509  
     public boolean isMyfacesImplAvailable()
 510  
     {
 511  0
         return MYFACES_IMPL_AVAILABLE;
 512  
     }
 513  
 
 514  
     public boolean isRiImplAvailable()
 515  
     {
 516  0
         return RI_IMPL_AVAILABLE;
 517  
     }
 518  
 
 519  
     /**
 520  
      * Do not use this in renderers directly!
 521  
      * You should use {@link org.apache.myfaces.shared_impl.renderkit.html.util.JavascriptUtils#isJavascriptAllowed}
 522  
      * to determine if javascript is allowed or not.
 523  
      */
 524  
     public boolean isAllowJavascript()
 525  
     {
 526  0
         return _allowJavascript;
 527  
     }
 528  
 
 529  
     private void setAllowJavascript(boolean allowJavascript)
 530  
     {
 531  0
         _allowJavascript = allowJavascript;
 532  0
     }
 533  
 
 534  
     public boolean isAutoScroll()
 535  
     {
 536  0
         return _autoScroll;
 537  
     }
 538  
 
 539  
     private void setAutoScroll(boolean autoScroll)
 540  
     {
 541  0
         _autoScroll = autoScroll;
 542  0
     }
 543  
 
 544  
     private void setAddResourceClass(String addResourceClass)
 545  
     {
 546  0
         _addResourceClass = addResourceClass;
 547  0
     }
 548  
 
 549  
     public String getAddResourceClass()
 550  
     {
 551  0
         return _addResourceClass;
 552  
     }
 553  
 
 554  
     /**
 555  
      * ExtensionFilter needs access to AddResourceClass init param without having
 556  
      * an ExternalContext at hand.
 557  
      */
 558  
     public static String getAddResourceClassFromServletContext(ServletContext servletContext)
 559  
     {
 560  0
         String addResourceClass = servletContext.getInitParameter(INIT_PARAM_ADD_RESOURCE_CLASS);
 561  
 
 562  0
         return addResourceClass == null ? INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT : addResourceClass;
 563  
     }
 564  
 
 565  
     /**
 566  
      * Should the environment be checked so that the ExtensionsFilter will work properly. 
 567  
      */
 568  
     public boolean isCheckExtensionsFilter()
 569  
     {
 570  0
         return _checkExtensionsFilter;
 571  
     }
 572  
 
 573  
     public void setCheckExtensionsFilter(boolean extensionsFilter)
 574  
     {
 575  0
         _checkExtensionsFilter = extensionsFilter;
 576  0
     }
 577  
 
 578  
     /**
 579  
      * 
 580  
      */
 581  
     public boolean isViewStateJavascript()
 582  
     {
 583  0
         return _viewStateJavascript;
 584  
     }
 585  
 
 586  
     private void setViewStateJavascript(boolean viewStateJavascript)
 587  
     {
 588  0
         _viewStateJavascript = viewStateJavascript;
 589  0
     }
 590  
 
 591  
     public void setRenderClearJavascriptOnButton(
 592  
             boolean renderClearJavascriptOnButton)
 593  
     {
 594  0
         _renderClearJavascriptOnButton = renderClearJavascriptOnButton;
 595  0
     }
 596  
 
 597  
     /**
 598  
      * This param renders the clear javascript on button necessary only for
 599  
      * compatibility with hidden fields feature of myfaces. This is done 
 600  
      * because jsf ri does not render javascript on onclick method for button,
 601  
      * so myfaces should do this.
 602  
      * 
 603  
      * @return
 604  
      */
 605  
     public boolean isRenderClearJavascriptOnButton()
 606  
     {
 607  0
         return _renderClearJavascriptOnButton;
 608  
     }
 609  
 
 610  
     public boolean isRenderHiddenFieldsForLinkParams()
 611  
     {
 612  0
         return renderHiddenFieldsForLinkParams;
 613  
     }
 614  
 
 615  
     public void setRenderHiddenFieldsForLinkParams(
 616  
             boolean renderHiddenFieldsForLinkParams)
 617  
     {
 618  0
         this.renderHiddenFieldsForLinkParams = renderHiddenFieldsForLinkParams;
 619  0
     }
 620  
 
 621  
     public void setSaveFormSubmitLinkIE(boolean saveFormSubmitLinkIE)
 622  
     {
 623  0
         _saveFormSubmitLinkIE = saveFormSubmitLinkIE;
 624  0
     }
 625  
 
 626  
     /**
 627  
      * Add a code that save the form when submit a form using a
 628  
      * link. It's a bug on IE.
 629  
      * 
 630  
      * @return
 631  
      */
 632  
     public boolean isSaveFormSubmitLinkIE()
 633  
     {
 634  0
         return _saveFormSubmitLinkIE;
 635  
     }
 636  
     
 637  
     public String getDelegateFacesServlet()
 638  
     {
 639  0
         return _delegateFacesServlet;
 640  
     }
 641  
     
 642  
     public void setDelegateFacesServlet(String delegateFacesServlet)
 643  
     {
 644  0
         _delegateFacesServlet = delegateFacesServlet;
 645  0
     }
 646  
 }