need a public API to get the CSS style properties  on the server in our 
renderers.
----------------------------------------------------------------------------------

                 Key: TRINIDAD-1453
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1453
             Project: MyFaces Trinidad
          Issue Type: New Feature
            Reporter: Jeanne Waldman
            Assignee: Jeanne Waldman


This information was discussed in email thread [TRINIDAD] [API] Styles.java and 
getSelectorStyleMap()

*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<Selector, Style> getSelectorStyleMap()

List<String> getSelectorsForSimpleSelector(String selector) uses resolved 
styles from StyleProvider.

String getNativeSelectorString(Selector selector) converts the selector into a 
string that is valid for the browser.

*Selector*
A new class that encapsulates the selector string into a selector object to 
make the getSelectorStyleMap API clearer and to have a place to add features to 
the Selector if it is needed.
static createSelector
private constructor

*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<Selector, Style> selectorStyleMap = styles.getSelectorStyleMap();
Style style = selectorStyleMap.get(Selector.createSelector("af|graph"));
String color = style.getProperties("color");

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

Reply via email to