Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6652305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:07:15+00:00 2026-05-26T01:07:15+00:00

Does anyone know how to use a custom ThemeSource in spring? I have seen

  • 0

Does anyone know how to use a custom ThemeSource in spring? I have seen many examples on how to use themes with property files using ResourceBundleThemeSource. Yet I have seen nothing on how to use hibernate to store vairous properties (such as a single css property) , read the properties with a custom ThemeSource and still be able to use the spring theme tags in the jsp.

I know I can create a controller and fetch these properties from the database with hibernate but I am more interested on knowing how to do this with Spring’s ThemeSource implementation.

If anyone has any ideas or examples I’d appreciate it.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:07:15+00:00Added an answer on May 26, 2026 at 1:07 am

    To use themes in your web application, you must set up an implementation of the org.springframework.ui.context.ThemeSource interface. To use a custom ThemeSource implementation you can register a bean in the application context with the reserved name themeSource. The web application context automatically detects a bean with that name and uses it.

    Here is the ThemeSource interface:

    package org.springframework.ui.context;
    
    public interface ThemeSource {
        Theme getTheme(String themeName);
    }
    

    The only dark horse here is a Theme type, which in fact is nothing more than:

    package org.springframework.ui.context;
    
    public interface Theme {
        String getName();
        MessageSource getMessageSource();
    }
    

    And in fact there is already a convenience implementation of Theme type from Spring => SimpleTheme

    Notice that ThemeSource expects a Spring’s MessageSource, which means that theme attributes that are stored in a database, in your case, would need to be “converted” to be used with a MessageSource interface.

    You can either write your own DatabaseDrivenMessageSource, or just take it from here

    Now, having all these variables in place, here is a custom DatabaseThemeSource ( that will become a themeSource bean ):

    public class DatabaseThemeSource implements ThemeSource {
    
        private YourThemeDao themeDao;
    
        public Theme getTheme( String themeName ) {
    
            if (themeName == null) { return null; }
    
            MessageSource messageSource = new DatabaseDrivenMessageSource( themeDao );
    
            theme = new SimpleTheme( themeName, messageSource );
    
            return theme;
        }
    
        // init your themeDao
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of an easy way to use a custom cursor? I have
Does anyone know if there's a way to use a custom LIKE button and
Does anyone know how to use the credential cache or network credential to get
Does anyone know how to use CruiseControl.Net to publish to an FTP server?
Does anyone know how to use the Raw Input facility on Windows from a
Does anyone know how to use an icon instead of text for the UINavigationController
I know I can use Request.Browser.IsMobileDevice . But does anyone know how it works,
Does anyone know if its possible to use phing to copy an entire folder
Does anyone know how i can use BST for config.time_zone in my rails config/environment.rb
Does anyone know if it's possible to use regex capture within Apache's DirectoryMatch directive?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.