[ 
https://issues.apache.org/jira/browse/TRINIDAD-1496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016643#comment-13016643
 ] 

Jeanne Waldman commented on TRINIDAD-1496:
------------------------------------------

This is not as simple as I first thought because the Icon object is built with 
pre-processed URIs ready to be output to the css or html. They do not have the 
raw uris, and the raw uris cannot be determined from the regular uris, since 
for css relative urls, we would need to know where the css file was.

We parse each css files in SkinStyleSheetParserUtils. here we configure the url.
Then in StyleSheetDocument, when we do all the property merging, we create the 
Icon objects. At this point the css file information is long gone. We do not 
even know all the skins that were merged together to form this one 
StyleSheetDocument.

I've attached a patch for an idea for a fix. That is to pass in a dummy 
property into the IconNodes ("raw-url"), then in StyleSheetDocument we can read 
this, and use it to create the Icon. The Icon constructors will have to change. 
Also note, that we will have to check the code carefully for right-to-left 
icons. I did not in this patch. It's simply an idea.

> Need org.apache.myfaces.trinidad.skin.Icon to expose the raw content value 
> instead of just getImageURI
> ------------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1496
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1496
>             Project: MyFaces Trinidad
>          Issue Type: New Feature
>          Components: Components
>    Affects Versions:  1.2.11-core
>            Reporter: Matt Cooper
>            Priority: Minor
>
> In skinning, you can define image icons in 4 different ways:
> 1.) Absolute URLs specify the complete URL to the resource, including the 
> protocol (e.g. http://). Example:
> content: url(http://incubator.apache.org/images/asf_logo_wide.gif);
> 2.) Relative URLs are used if the specified URL does not start with a slash 
> ("/") and if there's no protocol present. A relative URL is based on the 
> skin's CSS file location. For instance, if the CSS is located in 
> MyWebApp/skins/mySkin/ and the specified url is skinImages/myImage.gif, then 
> the final URL will be /MyWebApp/skins/mySkin/skinImages/myImage.gif. Example:
> content: url(skin_images/ObjectIconError.gif);
> 3.) Context relative URLs are resolved relatively to the context root of the 
> web application. To use them, you simply have to make it start with a single 
> slash ("/"). For instance, if the context root is /MyWebApp and the specified 
> URL is /images/myImage.jpeg, the resulting URL will be 
> /MyWebApp/images/myImage.jpeg. Example:
> content: url(/skins/mySkin/skin_images/ObjectIconError.gif);
> 4.) Server relative URLs are resolved relatively to the web server as opposed 
> to the context root. This allow to easily refer to resources located on 
> another application on the same server. To use this type of URL, the 
> specified URL must starts with two slashes ("//"). Example:
> content: url(//MyOtherWebApp/images/myCalendar.gif);
> The org.apache.myfaces.trinidad.skin.Icon class currently provides a 
> getImageURI() method.  This method returns a value that has the context path 
> built-in.  If a component exposes an icon attribute (there are a handful in 
> Apache MyFaces Trinidad and also in another framework that has components 
> built upon Trinidad), that icon String supports these same alternative 
> mechanisms for referring to the icon image.  Let's say you have a component 
> that you want to keep abstract but might want it to reuse existing components 
> (e.g. a rich text editor with a toolbar containing buttons that you want to 
> reuse an existing toolbar button component so you can have consistency in 
> button styling).  For that publicly-exposed component, you will want to allow 
> people to customize in skinning what the icons are for its toolbar.  These 
> icons must be defined in that publicly-exposed component but then converted 
> into a String that can be passed into the toolbar button component.  With the 
> current Icon.getImageURI(), if a user skinned the icon image using some of 
> the 4 above paths, either the icon would have 2 context paths added to it 
> (one from the skin framework and one from the toolbar button resource 
> encoding) or it would have a context path when it should not be including the 
> local context path (image definition option #4).  For the public component's 
> renderer to support all 4 of these image definition options, the 
> org.apache.myfaces.trinidad.skin.Icon needs to expose some mechanism to 
> either let it have access to the raw content value so that raw value can be 
> passed along to the button or at least some kind of mechanism to let the 
> public component's renderer know that it is not safe to let the button add 
> its own copy of the context path (e.g. add another leading "/" to the result).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to