I have a jboss seam 2.2.2 project and it is my first time using internationalization with this framework. I have already set the default locale and using the global messages_XX.properties is already working.
Well, this project is growing fast and for better organization and for ease of maintance I would like to have the messages better organized in various properties files for specific pages.
Seam documentation on internationalization mention this and in a specific paragraph it says:
If you want to define a message just for a particular page, you can
specify it in a resource bundle with the same name as the JSF view id,
with the leading / and trailing file extension removed. So we could
put our message in welcome/hello_en.properties if we only needed to
display the message on /welcome/hello.jsp
This paragraph can be found at: http://docs.jboss.org/seam/2.2.2.Final/reference/en-US/html/i18n.html#d0e14166
The docs mention pages with .jsp extension but in my case I am using facelets and what I have is a .xhtml file so for my home.xhtml page I have created a home_pt_BR.properties file being pt_BR the default locale for my app and I have placed messages for this specific page in this .properties file.
Actually this approach did not work for me.
I have also tryed to register the page in faces-config.xml and also in pages.xml but again this does not seem to work.
So, how do I configure Seam to support multiple bundle files for my application?
You could add the bundle files to components.xml
For example:
<core:resource-loader>
<core:bundle-names>
<value>messages</value>
<value>strings</value>
</core:bundle-names>
</core:resource-loader>
Related
I created a mvc-portlet module in Liferay 7.x, that has 2 portlets, test and test2. Each portlet has its own Language.porperties. Each property is its subfolder
resources/content/test/Language.properties
and
resources/content/test2/Language.properties.
In the portlet compoent properties I have
"javax.portlet.resource-bundle=content.test.Language"
and
"javax.portlet.resource-bundle=content.test2.Language"
but the default values (for the mvc-portlet template) for the keys won’t load. What am I doing wrong here?
You can find some sample code here: https://github.com/charalamposc/liferay-literals
So, I found a solution (don’t know if it's the best - but it works). I implemented two resource bundle loaders (https://help.liferay.com/hc/en-us/articles/360029317371-Resource-Bundle-Override), one for every resource. It seems, it adds an additional resource bundle to the module components.
I'm attempting to port over a huge website to Spring Boot. I have just about every piece of put in place except the security in JSP.
Unfortunately, the library that supports the security tag lib;
Causes my project to crash. I've tried looking for conflicts in the pom file but it's not to be.
I was able to get the principle using scriptlets but there are several times I conditionally display menus, based upon the authorization of the user. I even thought of writing my own tag libs but I it would take too long.
Are there any security tag libs that specifically work with Spring-Boot?
We have several in-house developed application in Groovy/Grails and use a shared plugin containing code that is common to all applications. We're needing more advanced authentication (LDAP, CAS, etc.) so it's time to implement the Spring Security plugin. I've been doing a bunch of reading on it, but I'm stuck at something as simple as changing the URLs and GSP pages that are used for the login and logout. I'm assuming that we'll also need a custom controller to make these changes.
In a normal situation where an application is using the Spring Security plugin, changing the default controller and/or GSPs seems to be as easy as just creating a file with the same name and location as the original files (since application files override plugin files). However, we're including the Spring Security plugin in our shared plugin which then is included in the application ... so unless it's possible to have one plugin override another plugins files this sort of solution doesn't seem to work here.
What would be the correct approach for overriding the default login/logout pages, url, and possibly controllers being used?
The controllers and GSPs are part of the plugin in 2.0. If you want to customize them copy them from the installed plugin directory to your project in the same folders and make the changes there. App files always override plugin files because the plugins are compiled first, then the app, so the app's files take precedence.
This procedure worked successfully for me.
I am using the new Grails Spring Security Core 2.0 plugin and am wondering how i can customize the login view and the LoginController/LogoutController?
The previous versions of the plugin generated these files but now it seems that I have to copy them from the plugin to my project. Is this the correct approach?
And if so, can I put the copied controllers and views into another package then the original ones. IntelliJ seems to dislike having the same artifacts in the same package.
By default in version 2.0 logouts are only allowed via POST requests. To change this to allow GET requests add the following to your Config.groovy file.
grails.plugin.springsecurity.logout.postOnly = false
Once you have that set you can link directly to logout controller in order to logout
<g:link controller="logout">logout</g:link>
If you want to find more info on what else was changed in version 2 look to the What's New in Version 2.0 documentation
Another option would be to use a remote link which by default uses the "post" method
<g:remoteLink class="logout" controller="logout">${message(code: 'springSecurity.logout.link')}</g:remoteLink>
I don't think any of the above answers actually answer the question.
If you want to override the controllers and the views in your web-app then yes copy them up into your web-app. You can even give them a different package hierarchy if you wish as the spring-security-core plugin seems to reference them by URL and yours would replace them.
This works because controllers and views declared in the main web-app take precedence over those that are in the plugins.
However if you are doing this in another plugin thats when things get a bit tricky. See this questiona and answer for a solution to that problem
When I open a Spring configuration files at my application on Intellij IDEA sometimes it says
File Set Not Configured For The File
and gives me a link
Configure File Set
When I click it it says:
MVC dispatcher servlet
Create New File Set
or opens a new window cnd let me check some files.
What happens when I click them and what is this for? I click MVC dispatcher Servlet and check the code but doesn't see any changes.
What it is for?
this is for IDEA to help you out with dependencies between different files.
For example you have "service-spring-config.xml" and "mvc-spring-config.xml", where the MVC config uses some beans from the Service config. If you add these both files to the "File Set", IDEA will know that these two files represent a single application context.
By knowing that, it will help you autocomplete beans in XML + will inform you if something is not resolvable without you having to actually run the app.
I click MVC dispatcher Servlet and check the code but don't see any changes
This is because you only have a single file (for now). Later on, you can add some other configs that use/reference beans from each other => then it'll become REALLY helpful
From IDEA File Sets documentation:
By combining Spring XML configuration files in a file set you tell IntelliJ IDEA that these files are mutually related. In this way you form a common editing context for these configuration files and get all the associated coding assistance.
Spring file sets on IntelliJ are for grouping related files.
IntelliJ could autodetect some of this groups, for example files that are loaded with ContextLoaderListener on web.xml or default files for DispatcherServlet (That seems to be your case)
When IntelliJ asks to configure a File Set for a Spring file, is 'cause IntelliJ couldn't detect a default way to include in a group, for example files that are loaded within the ApplicationContext's constructor Ex:
new ClasspathXmlApplicationContext("somefile.xml","anotherfile.xml");
When file sets are correctly configured IntelliJ could bring many goodies like auto-complete, navigation, validation, dependency graphs and others