You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Matthias Wessendorf <ma...@apache.org> on 2009/03/31 19:59:10 UTC

Re: [TRINIDAD] [API] Styles.java and getSelectorStyleMap()

This all looks good, IMO

-M

On Tue, Mar 31, 2009 at 6:41 PM, Jeanne Waldman
<je...@oracle.com> wrote:
> I'm thinking about adding another new API.
>
> Instead of a String to hold the selector, I'll have a Selector object.
> This way we can call getCSS2Selector (or something like this) which will
> return .af_inputText instead of af|inputText.
>
> So Map<String, Style> getSelectorStyleMap()
> will be
> Map<Selector, Style> getSelectorStyleMap()
>
> Jeanne
>
> Jeanne Waldman wrote, On 3/27/2009 4:36 PM PT:
>
> adding TRINIDAD to the subject.
>
> Jeanne Waldman wrote, On 3/27/2009 4:36 PM PT:
>
> Hi everyone,
> I want to propose some new public apis for Trinidad.
>
> *Overview*
>
> We need a public API to get the CSS style properties (e.g., color: red) on
> the server in our renderers. We work around the lack of apis by using
> skinning custom style properties instead (e.g., -tr-color: red) because
> skinning style properties are stored on the server as an attribute of a Skin
> Object. This is definitely a kludgy workaround and makes it harder for a
> user to skin.
>
> We will also need the APIs for an emailable page mode we are implementing
> soon so that we can limit the css that we write in the page to only the css
> needed by the components on the page. Email cannot handle external css
> files.
>
> In summary, the APIS we need will do this:
>
> 1) For a given selector, return its style definition
> 2) For a given simple (no compound selectors) selector like "af|inputText",
> return all of the style definitions that it is used in like "af|foo
> af|inputText", "af|inputText::content", etc.
>
> *API Proposal*
>
> We will assume the style map we get from the RenderingContext will contain
> only the styles for the StyleContext, that is, the styles have already been
> 'resolved'. Therefore there will be no need to pass in the StyleContext
> parameter when we get styles from the style map.
>
> *Public APIs*
>
> *Style*
> This class exists, but will need to be made public and only the public parts
> of it moved to the public api, and the rest stay with the private
> implementation.
>
> public Map<String, String> getProperties();
> public String toInlineString();
>
> *Styles*
> A new  class that wraps 2 methods. This class is similar to the current
> StyleMap private class which isn't a Map at all. I plan to delete StyleMap
> and use Styles instead.
>
> Map<String, Style> getSelectorStyleMap()
>
> List<String> getSelectorsForSimpleSelector(String selector) uses resolved
> styles from StyleProvider.
>
>
> *RenderingContext*
> already exists
> add
> public Styles getStyles();
>
> *Private APIs*
>
> *CoreRenderingContext*
> already exists
> Implements the new method on RenderingContext
>
> *StyleContext*
> This class already exists and is private.
>
> public Styles getStyles();
>
> *StyleContextImpl*
> already exists
> add
> getStyles() calls getStyleProvider().getStyles(this);
>
> *StyleProvider*
> already exists
> add
> public Styles getStyles(StyleContext context); // resolves the styles first
>
> *FileSystemStyleCache* extends StyleProvider
> already exists
> add
> public Styles getStyles(StyleContext)
> static inner class StylesImpl which takes a resolved styles in its
> constructor.
> this is where the work is done to create the selectorStyleMap.
>
> *StyleMap*
> remove. It's not a map for one thing and it is such old code and it isn't
> being used at all so it is cluttering the api.
>
> *API Usage:*
>
> Styles styles = renderingContext.getStyles();   // renderingContext contains
> a styleContext
> Map<String, Style> selectorStyleMap = styles.getSelectorStyleMap();
> Style style = selectorStyleMap.get("af|graph");
> String color = style.getProperties("color");
>
> I coded this up in my branch
> https://svn.apache.org/repos/asf/myfaces/trinidad/branches/jwaldman_StyleMap
> (not cleaned up yet)
> I still need to create a JIRA issue.
> Let me know if you have any comments.
>
> Thanks!
>
> Jeanne
>



-- 
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf