dev@javaserverfaces.java.net

Re: web.xml parameter aliasing

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Wed, 19 Nov 2008 13:12:05 -0800

Ed Burns wrote:
> We'll need it because I want the param "facelets.LIBRARIES" to be an
> alias to "javax.faces.FACELETS_LIBRARIES".
>
> Here's a changebundle with one implementation. I've checked it in but
> it can certainly be changed.
>
> Issue: 274 Facelets
>
> I need this in preparation for more work I must do with ViewHandler to
> specify what happens with JSP vs. with Facelets.
>
> This change-bundle implements the aliasing for the param
> javax.faces.FACELETS_LIBRARIES (incorrectly typed as
> javax.faces.FACELET_LIBRARIES, I've fixed the frame doc) to the old value of
> facelets.LIBRARIES.
>
> All automated tests continue to run successfully.
>
>
> SECTION: Modified Files
> ----------------------------
> M jsf-ri/src/com/sun/faces/config/WebConfiguration.java
>
>
> SECTION: Diffs
> ----------------------------
> Index: jsf-ri/src/com/sun/faces/config/WebConfiguration.java
> ===================================================================
> --- jsf-ri/src/com/sun/faces/config/WebConfiguration.java (revision 5887)
> +++ jsf-ri/src/com/sun/faces/config/WebConfiguration.java (working copy)
> -195,8 +195,16 @@
> * @return the value of the specified parameter
> */
> public String getOptionValue(WebContextInitParameter param) {
> + String result = contextParameters.get(param);
> +
> + if (null == result) {
> + WebContextInitParameter alias = param.getAlias(param);
> + if (null != alias) {
> + result = contextParameters.get(alias);
> + }
> + }
>
> - return contextParameters.get(param);
> + return result;
>
> }
>
> -710,6 +718,10 @@
> ""
> ),
> FaceletsLibraries(
> + "javax.faces.FACELETS_LIBRARIES",
> + ""
> + ),
> + FaceletsLibrariesAlias(
> "facelets.LIBRARIES",
> ""
> ),
> -741,6 +753,16 @@
> return qualifiedName;
>
> }
> +
> + public WebContextInitParameter getAlias(WebContextInitParameter current) {
> + WebContextInitParameter result = null;
> +
> + if (current == WebContextInitParameter.FaceletsLibraries) {
> + result = WebContextInitParameter.FaceletsLibrariesAlias;
> + }
> +
> + return result;
> + }
>
I'd rather have the alias be passed to the constructor of the enum.

So get option value would look something like:

public String getOptionValue(WebContextInitParameter param) {

        String result = contextParameters.get(param);

        if (result == null) {
           if (param.hasAlias()) {
              result = contextParameters.get(param.getAlias());
           }
        }
        
        return result;
}
        
This would eliminate the need for a getAlias() method directly
on WebConfiguration and avoid, potentially, several if else checks.


>
>
> // ------------------------------------------------- Package Private Methods
>
>