What if one have Assets that need to be referenced in the css?
How is that solved?
On 8/25/05, Ron Piterman <[EMAIL PROTECTED]> wrote:
> What I do to resolve this is the following:
>
> Each component which wants to "contribute" a css, implements an
> Interface named IStyleable.
>
> The border goes through all components of the page and checks them.
> For each one which implements the IStyleable interface (which is only a
> marker, and has no methods to implement) it reaches for the "css" asset,
> and adds it to a set of assets. (see code at the end)
>
> This whole thing happens only once per page instance, so performance is
> not an issue.
>
> in the border I define
> <html jwcid="@Shell" stylesheets="ognl:stylesheets" ...>
>
> Thats it. Works very nice for me.
>
> Cheers,
> Ron
>
> ===================================
>
> public class Border extends BaseComponent implements IStyleable {
>
> private IAsset[] _stylesheets;
>
> public IAsset[] getStylesheets() {
> if (_stylesheets == null) {
> Set s = new HashSet();
> getStylesheets(getPage(),s);
> _stylesheets = new IAsset[s.size()];
> System.arraycopy(s.toArray(),0,_stylesheets,0,s.size());
> }
> return _stylesheets;
> }
>
> private void getStylesheets(IComponent c, Set s) {
> if (c instanceof IStyleable)
> addStylesheet(c,s);
> for (Object cc : c.getComponents().values())
> getStylesheets((IComponent)cc, s);
> }
>
> private void addStylesheet(IComponent s, Set set) {
> IAsset asset = s.getAsset("css");
> if (!set.contains(asset))
> set.add(asset);
> }
> }
>
>
> ציטוט Tomáš Drenčák:
> > Hi,
> > I'd like to ask how can I include a css file into a component or even
> > a page. I use own Border component with Shell. Stylesheets could be
> > imported there, but what if I want to include css specific to page or
> > component?
> >
> > thanks
> > tomas
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
/ted