You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2008/10/16 01:24:44 UTC

[jira] Commented: (TOMAHAWK-1264) URL Encoding missing

    [ https://issues.apache.org/jira/browse/TOMAHAWK-1264?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12640012#action_12640012 ] 

Leonardo Uribe commented on TOMAHAWK-1264:
------------------------------------------


ExternalContext.encodeResourceURL calls encodeURL on HttpServletResponse or PortletResponse, adding information to restore session when the url encoded is called later.

 There are two cases:

1. The resource are not filtered. In this case, there is a call like this:

stylesheetPath = context.getApplication().getViewHandler().getResourceURL(context, path);

there is no need to append session information to the resource url by the view handler, so the call to encodeResourceURL is not necessary.

2. The resource are filtered. The actual implementation of TextResourceFilter says this:

"...... The "filtering" process looks for any strings of form #{...} in the
 resource, and executes it as an EL expression. The original expression
 is then replaced with the return value of the expression.

 Note that evaluation of EL expressions happens <i>only once</i>, when
 the resource is loaded into the cache for the first time. And the EL
 expressions are evaluated using the context of whatever faces request
 happens to be active at the time. EL expressions in filtered resources
 should therefore not reference any request-scoped or session-scoped values
 as the cached result would be unpredictable......"

so, the code as is does not handle  session-scoped values, and again for this case encodeResourceURL is not necessary.

But, thinking this from another point of view, suppose this use case (it is just a hypotetical case, it has many solutions but I want to explore it to see if this issue is applicable or not): the user requires a customization of the look and feel per locale, so he/she start using a session bean to hold locale information, then use f:view to set it like this:

<f:view locale="#{sessionBean.locale}">

by some reason, the colors used by some locale is different than in other so he/she wants to configure it using a resource bundle and use a filtered t:stylesheet, so according to the locale one group of colors or other are used.

This use case is not possible in the actual implementation, because all text resources filtered using t:stylesheet are cached. It could be good to have a param like "cache" default true by backward compatibility, so the user can decide when he/she wants to cache it or not, or a property like "cacheMode" possible values "session" "application" "nocache" default "application" so the text resource is cached on application, session scope or no cached. If this param exists it has sense to use encodeResourceURL, but only on the cases where the session needs to be restored (the browser does not use cookies, so jsessionid param is added to the url).

The idea of have a boolean "cache" param seems to be the right solution, but first it needs some discussion on dev list.

> URL Encoding missing
> --------------------
>
>                 Key: TOMAHAWK-1264
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1264
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: Stylesheet
>            Reporter: Markus Wichelmann
>            Assignee: Hazem Saleh
>
> The URL of the stylesheet is not encoded with encodeResourceURL.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.