You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Feng Gao <ga...@hotmail.com> on 2022/02/15 19:13:23 UTC

Tapestry default style sheet change doesn't seem to kick in

Hello!

I followed instructions on https://tapestry.apache.org/css.html to change Tapestry (v5.7.3) default stylesheet to use Bootstrap-4.6.1 stylesheet, instead of the default Bootstrap-4.3.1:

*        Tapestry 5.5.0 and later also allows you to have Tapestry not provide any CSS at all. To do that, just add @ImportModule(NoBootstrapModule.class) to your module class. In this case, you'll need to set the tapestry.default-stylesheet (SymbolConstants#DEFAULT_STYLESHEET) configuration symbol to tell Tapestry what's your main CSS file. Otherwise, an exception will be thrown and the webapp won't start.

Here's what I ended up with in AppModule.java
@ImportModule(NoBootstrapModule.class)
public class AppModule
{
...........
    @ApplicationDefaults
    @Contribute(SymbolProvider.class)
    public static void setupEnvironment(final MappedConfiguration<String, String> configuration)
    {
        ..............
       configuration.add(SymbolConstants.DEFAULT_STYLESHEET, "context:css/bootstrap-4.6.1-dist/css/bootstrap.css");
    }
}

css/bootstrap-4.6.1-dist/css/bootstrap.css is included in the webapp folder. When the application runs after the above changes, it still shows the default Bootstrap css (v4.3.1).
<link type="text/css" rel="stylesheet" href="/MyApp/assets/meta/zae851f6d/tapestry5/bootstrap4/css/bootstrap.css">
/*!
*        Bootstrap v4.3.1 (https://getbootstrap.com/)
*        Copyright 2011-2019 The Bootstrap Authors
*        Copyright 2011-2019 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
Do you see what might be missing or mistaken? Please advise.

Thank you!
Feng Gao

Re: Tapestry default style sheet change doesn't seem to kick in

Posted by Bob Harner <bo...@gmail.com>.
I'll take a crack at this.

In your application module class (normally AppModule.java), set the Symbol
constants.BOOTSTRAP_ROOT symbol to where your replacement bootstrap files
are installed (the parent of the bootstrap css and js subfolders). As far
as I understand, there are no other changes needed to have Tapestry use
your version of Bootstrap. See the "Overriding Bootstrap (Tapestry 5.4 and
later)" section of https://tapestry.apache.org/css.html

On Tue, Feb 15, 2022, 2:13 PM Feng Gao <ga...@hotmail.com> wrote:

> Hello!
>
> I followed instructions on https://tapestry.apache.org/css.html to change
> Tapestry (v5.7.3) default stylesheet to use Bootstrap-4.6.1 stylesheet,
> instead of the default Bootstrap-4.3.1:
>
> *        Tapestry 5.5.0 and later also allows you to have Tapestry not
> provide any CSS at all. To do that, just add
> @ImportModule(NoBootstrapModule.class) to your module class. In this case,
> you'll need to set the tapestry.default-stylesheet
> (SymbolConstants#DEFAULT_STYLESHEET) configuration symbol to tell Tapestry
> what's your main CSS file. Otherwise, an exception will be thrown and the
> webapp won't start.
>
> Here's what I ended up with in AppModule.java
> @ImportModule(NoBootstrapModule.class)
> public class AppModule
> {
> ...........
>     @ApplicationDefaults
>     @Contribute(SymbolProvider.class)
>     public static void setupEnvironment(final MappedConfiguration<String,
> String> configuration)
>     {
>         ..............
>        configuration.add(SymbolConstants.DEFAULT_STYLESHEET,
> "context:css/bootstrap-4.6.1-dist/css/bootstrap.css");
>     }
> }
>
> css/bootstrap-4.6.1-dist/css/bootstrap.css is included in the webapp
> folder. When the application runs after the above changes, it still shows
> the default Bootstrap css (v4.3.1).
> <link type="text/css" rel="stylesheet"
> href="/MyApp/assets/meta/zae851f6d/tapestry5/bootstrap4/css/bootstrap.css">
> /*!
> *        Bootstrap v4.3.1 (https://getbootstrap.com/)
> *        Copyright 2011-2019 The Bootstrap Authors
> *        Copyright 2011-2019 Twitter, Inc. * Licensed under MIT (
> https://github.com/twbs/bootstrap/blob/master/LICENSE)
> */
> Do you see what might be missing or mistaken? Please advise.
>
> Thank you!
> Feng Gao
>

Re: Tapestry default style sheet change doesn't seem to kick in

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, Feb 15, 2022 at 4:13 PM Feng Gao <ga...@hotmail.com> wrote:

> Hello!
>

Hello!


> I followed instructions on https://tapestry.apache.org/css.html to change
> Tapestry (v5.7.3) default stylesheet to use Bootstrap-4.6.1 stylesheet,
> instead of the default Bootstrap-4.3.1:
>
> Here's what I ended up with in AppModule.java
> @ImportModule(NoBootstrapModule.class)
> public class AppModule
> {
> ...........
>     @ApplicationDefaults
>     @Contribute(SymbolProvider.class)
>     public static void setupEnvironment(final MappedConfiguration<String,
> String> configuration)
>     {
>         ..............
>        configuration.add(SymbolConstants.DEFAULT_STYLESHEET,
> "context:css/bootstrap-4.6.1-dist/css/bootstrap.css");
>     }
> }
>

I believe you're making a contribution to the wrong service: it should be
to ApplicationDefaults directly, not to SymbolProvider.

I suggest you try this:

    public static void contributeApplicationDefaults(final
> MappedConfiguration<String, String> configuration)
>     {
>         ..............
>        configuration.add(SymbolConstants.DEFAULT_STYLESHEET,
> "context:css/bootstrap-4.6.1-dist/css/bootstrap.css");
>     }
> }
>

Please let us know if it works.

Also, I believe the approach suggested by Bob is the most recommended one,
since you're just replacing the Bootstrap version. Using NoBootstrapModule
is intended for when you're not using Bootstrap at all.

--
Thiago