[[per-user-themes]]
= Per-user Themes

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


From link:http://causeway.markmail.org/thread/kb4442niwwbnghey[this thread] on the Apache Causeway users mailing list:

* _Is it possible to have each of our resellers (using our Apache Causeway application) use their own theme/branding with their own logo and colors?
Would this also be possible for the login page, possibly depending on the used host name?_


Yes, you can do this, by installing a custom implementation of the Wicket Bootstrap's `ActiveThemeProvider`.


[source,java]
.ActiveThemeProvider implementation
----
public class MyThemeProvider implements ActiveThemeProvider {
    // ...
    @Override
    public ITheme getActiveTheme() { ... }                      // <.>
    @Override
    public void setActiveTheme(final String themeName) { ... }  // <1>
}
----
<.> these methods won't necessarily be called within a regular Causeway "interaction", so you may need to use the xref:userguide:btb:headless-access.adoc[headless access] pattern if - for example - persisting to Causeway-managed entities.


To egister

[source,java]
.Using the ActiveThemeProvider
----
@Override
protected void init() {
    super.init();

    final IBootstrapSettings settings = Bootstrap.getSettings();
    settings.setThemeProvider(new BootswatchThemeProvider(BootswatchTheme.Flatly));

    settings.setActiveThemeProvider(new MyThemeProvider(settings));
}
----
