Vaadin 23: different themes for different deliveries - themes

https://vaadin.com/docs/latest/ds/customization/custom-theme describes how to use a custom theme in Vaadin 23. The current theme is selected by writing its name into the Theme annotation like this: #Theme("my-theme").
The system I'm currently developing is always the same Java code but with different styles/themes. That means that system A for customer cA uses corporate design/theme dA and system B for customer cB uses corporate design/theme dB.
How is this (theming different deliveries) done with the theme mechanism?
(I'm not talking about switching the theme at run-time (which would be nice). I know that Vaadin talks about this limitation: The theme cannot be switched run-time.)
Idea 1: exchange the content theme/my-theme directory at delivery time. Feels not intended, because in this case there was no need for an individual theme-directory-name...
Idea 2: exchange the value at the Theme annotation at delivery time. Also feels not intended.
Idea 3: maybe there is a start parameter for that? I guess not, because it would have to change the (constant) value of the Theme annotation...

For build time usage of different themes, one of the intended methods is to package the them as jar module and use it as a dependency in your application project. This will allow you to use different theme jars by configuring maven profiles per each customer.

Related

Spring Boot Rest Multilanguage

I have an application, that uses Angular 2 for UI and Spring Boot Rest as a microservice. As a database, I have PostgreSQL.
I want this project to support multi-languages.
I heard that spring has something called i18n, but I don't know how to implement it.
One of my microservice is called categories, and what it does is CRUD operations. The default language is English, but I want to add french. So, if a call is like this:
get: http://localhost:8080/categories?lang=fr
I will get all the categories, where lang = 'fr'
Also, probably I will add a table called static_texts, where I will add words to translate, like: contact, menu, testimonials, etc. And for these words, when a user entered for the first time on site, angular will make a call to java to get all the static words, to save in a session, and to add those into the template.
Like this I see the multilanguage system, but, I don't understand how to implement it into my project. Do you have an example, because I couldn't find anything for what I need?
Thanks!
Spring Boot can manage any number of locales in an application flawlessly. Internationalization is a great way to increase users on a product so there are no limits in terms of how users use your product.
The first and simple solution is to implement a LocaleResolver and LocaleChangeInterceptor for managing some resource files for different languages. you can see this tutorial.
However, this approach depends on the access to the application’s resource files when adding a new supported language or modify the existing message files. In case an end-user is responsible for this job and obviously, this is not an optimal approach.
Hence, the second method shows how to move all of our localized messages to a database. This enables the end-user to add a new language or update existing localized messages at runtime with the help of i18n. In this tutorial you'll see how to use your table for translated texts

Is there a Joomla (3.x) development API for creating and managing custom user groups?

I just started with Joomla 3.x and I'm writing a component for Joomla v3 which is supposed to create new usergroups for creating 'groups'- the design requirements being:
An organisation may set up a group to offer access to some set of services -including communication but also also other types of services - to their members
(the other services is the reason why I believe the community and forum joomla extensions are not suitable- they mostly focus at fora and social media services, not the services I will implement.)
Other persons/members of the organisation may register to this group, which allow him/her to access these services
ps: it is also possible for person to set up a personal account and get access to the set of services. This person may also join one or more groups at a later stage
How to do code the creating of new usergroups? I noticed a possible suggested solution at How to create custom User Group Programmatically in Joomla 3.x, but I struggle to understand how to use the suggested JTableUsergroup class because of the limited documentation at http://docs.joomla.org/API17:JTableUsergroup(?) Does creating an instance of JTableUsergroup results in the creation of a new customer user group?
Another question: how to add users to a customer usergroup? The only hint I found was at http://api.joomla.org/cms-3/classes/JUserHelper.html - using the method addUserToGroup of class JUserHelper.
Many of the Joomla development concepts are well document but I could not find one for managing custom user groups...
Appreciate your help;-)
First, overall, the best consistent documentation of Joomla APIs is in the docblocks for the classes. Then to be honest what I do a lot of times is to search for where in the core the API is used. There are some great pieces of narrative documentation in the wiki, but on the whole I always start with the docblocks which are very complete. However in this case it's pretty simple.
You need to do something along the lines of
$newrow = JTable::getInstance('Usergroup');
//code to add your data
$newtable->save(); // Shortcut for check, bind, store
However, if I were you I would look carefully at UsersModelGroup because there are a lot of other things that should normally happen in this process such as running the user plugins. So I might include and extend that model (which manages the table class) rather than going to the table class directly. In fact your whole component might even be able to extend almost all of the users component or it might also be possible that you could do what you want with plugins rather than reinventing the whole thing.
In terms of assigning users to groups that is trickier because of some legacy things in the code. I think the setter followed by a $user->save() ($user being a JUser instance) is probably the way to go when adding to groups. What I probably would do is to write a custom JFormField that would manage opt-in groups because the core usergroup field includes everything. You could extend that and exclude the groups that you want to have only managed by admin.

Customize application for different customers

Based on a specific application (bakery ERP), I need to create a new branch as a general purpose ERP with basic functionality (invoices, orders, work orders, customer communications...).
This new branch must be customizable for each client: print formats, application colors and icons/images, and restricted access to some application parts...
I've read about resource files for text/icons/image customization, but I need some help or alternatives, maybe defining an Interface to provide needed resources.
I use DevExpress components, so, print formats, and forms layout can be customized storing formats and layouts in files. However, main form has to be completely redesigned, and i wonder about the best way to do this. ¿this can be done with a little project containing the main form and implementing an interface providing custom images for buttons and other customizations?
Apart from layout customization, I need to restrict access to some parts of ERP for each customer, but behavior customization will be minimal or nonexistent, so, maybe I can personalize behavior with an xml config file for each customer.
Independently of my ideas, I thank you for any idea or comment about mu purpose: interface customization for each client, and minimal behavior customization. Don't need complex solutions like Workflow Foundation or completely pug-in based development.
If it's only format of prints and screen images, just use resource files or database configurations.
If you need functionality to be changed - use interfaces and inject their implementation via some framework, like MEF, for example.
And your English is good, no need to sorry

How to use multiple themes at the same time

I'm looking for a way to use multiple themes in one XPages application, each theme active in a different section of the application. For instance to support an single .nsf application with both a public facing website (custom theme) and a CMS with a OneUI theme.
You can set which theme is used through the whole application on the XPage Properties tab in Application Properties. It's also possible to change the theme for a user's session with this code:
context.setSessionProperty("xsp.theme", <theme_id>)
But both options set the theme for all pages in the current .nsf, and I'm looking for a way to specify theme X for one part of the application and theme Y for a second part.
Is this possible?
On any page that should use an alternate theme, use the following syntax to apply the property directly to the view root:
<xp:view>
<xp:this.properties>
<xp:parameter name="xsp.theme" value="alternateThemeName" />
</xp:this.properties>
</xp:view>
I tried all of the above, but none of them worked for me. But I found a solution:
Paste this into the view's beforeRenderResponse event:
context.setSessionProperty("xsp.theme", "yourAlternateThemeName")
There is one issue: once you have used this way you have to use it always and on every page as this sets a session property which is stored as long as you are logged in.
Just talked with colleague Tony Mcguckin.
You can change the theme per page. Under all properties of the XPage select data-properties and create a new property with name "xsp.theme" and value "yourThemeName".
While I like the idea of having page-specific themes, based on the specific use case you're describing, the "right" way to do this is to have two separate XPage applications bound to the same back end data store. Not only does this make it simple to specify a different theme for each, it also simplifies the ACL (assuming you'll have different people accessing the public site vs. the CMS), makes it easier to tune performance by having different settings per application, and even without having application-specific settings, should improve performance slightly just because of Java class loader behavior: each NSF acts as a distinct ClassLoader, and each XPage or Custom Control in your NSF results in the storage of a separate class file. So, in theory, if the features of your public site require you to create 5 XPages and the CMS features span 10 XPages, simply splitting these into two separate apps makes it easier for the class loader to retrieve the class for any page a user loads, because it doesn't have to ignore the classes it will never need for that user just to find the one class it does need at the time. So I'm still tempted to find a way to get page-specific themes working just for the "cool" factor of it, but for this specific purpose, I'd recommend using two different applications entirely, with a different theme assigned to each.
I dont know that much about themes but cant you check in your theme (with some ssjs) at which viewroot ( by id? ) you are and according to that include the correct styles , css and other resources?

Prism with multiple Modules and Modules depends on

Hi I'm in a scenario where I'm thinking about to have several modules, and let modules depends on other modules.
say that we are building a business system while one part is invoicing and we have customers in different branches.
So one industry may want to use some tools and create the invoice in their way, and another industry may want to do it in another way. So I think we can do one module per create invoice method so when the application loads we can see in the configuration what module of the crate invoices module who have to load.
So to my first question, is this the way to solve this problem or are there more better solutions?
My next question is where should I put them in a tree?
Should the modules that depends upon Invoicing module be put under the Invoicing module or the same level?
I would first work on creating a viewengine to load view based on context criteria.
The criteria can be tenant (domain name), device, view size, current theme (all of these interfaces your viewengine depends on)
Maybe using an approach like DataTemplateSelector scattered across your views needing customization. You would probably want to approach it like in asp.net mvc to resolve the views (so you have the ability to override views) based on view search paths.
You would need to be able to load into app resources tenant styles for custom branding.
I would push back in creating your fine grain dependencies until after the above begins to show maintenance problems. For business logic that needs customization you can use a strategy pattern.
I see it costing more upfront to break it out now and having to manage these long dependency chains. The cost to implement later (after a good business feature requires it) will only take a few hours of work using ModuleInfo as explained here:
Silverlight PRISM Creating a custom module catalog
We choosed to go with modules, and I put them under the depending module in the tree.
It worked really great.

Resources