Igor,

Thanks for the solution!  I'll go that route for now.

However, I'm not convinced that supporting alternate stylesheets is
outside the scope of wicket core.  Mozilla browsers support switching
to alternate stylesheets from a menu option:
http://www.w3.org/Style/Examples/007/alternatives.html

That alone is probably not a good enough incentive to include it in
core.  But my use case is to improve accessibility.  The site I'm
making is for senior citizens, so I'm providing them with a way to
easily scale the size of the font displayed on the site by clicking
font size icons on the page.  This technique is explained here:
http://alistapart.com/stories/alternate/

This solution uses javascript to activate and deactivate the alternate
stylesheets.  I prefer to utilize javascript for quick stylesheet
changes rather than a round-trip to the server.  I realize I could
accomplish the same thing with server round-trips and not need any
custom HeaderContributor.

Lastly, it is possible to group stylesheets together and activate or
deactivate them all at once if they have the same title.  Adding that
attribute would make it more robust.

Regardless, as you have shown, it isn't hard to implement my own
IHeaderContributor.  I just wasn't sure how to go about it, and now I
am.  So perhaps you are right in that it is best left out of core.

Thanks again!
Tauren



On 6/24/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> On 6/23/07, Tauren Mills <[EMAIL PROTECTED]> wrote:
> > I am creating an application that utilizes alternate stylesheets.  A
> > javascript library also needs each stylesheet to have a title.  The
> > output format should be something like this:
> >
> > <link rel="alternate stylesheet" type="text/css" href=" large.css"
> > title="large" />
> >
> > Using HeaderContributor, I can get this output:
> >
> > <link
> href="/db/app/resources/mypackage.MyPanel/large.css"
> > type="text/css" rel="stylesheet">
> >
> > Note that I need to add "alternate" to the "rel" attribute and add a
> > "title" attribute to the HeaderContributor output.
> >
> > I was hoping to alter this <link> tag using an AttributeModifier, but
> > there doesn't seem to be a way to do this since HeaderContributor is
> > not a Component.
> >
> > Here is code:
> >
> > private static final CompressedResourceReference CSS_LARGE =
> >         new CompressedResourceReference( MyPanel.class, "large.css");
> >
> > public MyPanel(String id) {
> >         super(id);
> >         HeaderContributor large = HeaderContributor.forCss(SS_CSS_LARGE);
> > }
> >
> > I thought I could create my own version of
> > HeaderContributor.CSSReferenceHeaderContributor, but I
> can't override
> > forCss(ResourceReference) because it is final.
> >
> > Is there some other way to alter a tag?  Otherwise, how would I accomplish
> this?
> >
> > Thanks,
> > Tauren
> >
> >
>
> tbh, these reqs sound a little too exotic to be supported by the core
> framework. that said, it is trivial to create your own css contributor.
>
> class mycontributor extends abstractbehavior implements iheadercontributor {
>   private ResourceReference ref;
>   private String title;
>   public mycontributor(ref,title) {...}
>
>   renderHead(final IHeaderResponse response) {
>     response.renderString("<style all your attributes
> href=\""+requestcycle.get().urlfor(ref)+"\"/>");
>   }
> }
>
> done
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to