Good afternoon, I am new to liferay and I am trying to migrate the code of a portlet from 6.2 to 7.4, I need to know how to use the LanguageUtil.get() method in liferay 7.x, currently it is implemented like this in my JSP LanguageUtil.get(pageContext, "key"), but I get an error "PortletConfig get/format methods" I have tried some ways like LanguageUtil.get(themeDisplay.getLocale(), "key") but I can't get the error to go away, any suggestion or correct way is appreciated to do it.
In a JSP you'd often use <liferay-ui:message key="key"/>, to prevent too many code snippets in the JSP. With this, you'd have no upgrade efforts.
If you want to use LanguageUtil, with a specific ResourceBundle (e.g. the one that comes with the module that you're upgrading), you'll need the locale as well: ResourceBundleUtil.getBundle(locale, this.getClass().getClassLoader()) - you can get the relevant locale through pageContext or themeDisplay. Then use LanguageUtil.get(resourceBundle, key)
Related
In my project I have to implement a page which use primefaces v6.1 but other pages are written in primefaces version 3.
Its hard to update versions for other pages, on the other hand i dont want to use v3 for the new page.
First i have a idea; manipulating primefaces-p.taglib.xml which is in META-INF,
<namespace>http://primefaces6version.org/ui</namespace> . Try to use in the xhtml page:
xmlns:p="http://primefaces6version.org/ui" and components now can be in primefaces 6 versions! But its not worked, i dont know why.
Is there any idea how to use different primefaces versions in same project?
This is not easily possible and would require a lot of work. It would e.g. require fully refactored (classes renamed etc) version of PrimeFaces including everything in the taglibs and more. You could try just creating a customized PF version for just the datatable, but personally I'd bite the apple and upgrade the application.
Earlier we are putting catche in liferay with help of below code.
MultiVMKeyPoolUtil.put("SCHOOL", "ID", "Files");
In Liferay 6.2 MultiVMKeyPoolUtil not available so how can we put catche.
There are no method like put in MultiVMPoolUtil class. I had search many alternative but couldn't find put method in it.
As MultiVMKeyPoolUtil not supported by liferay 6.2. I had used MultiVMPoolUtil class like below.
MultiVMPoolUtil.getCache("SCHOOL").put("ID","Files");
If you want to put collection as cache use below code.We require to make list serializable
MultiVMPoolUtil.getCache("SCHOOL").put("ID",(Serializable) courses);
I want to write integration tests for my application. I want to test, that the required=true attribute on my text components are set on some JSF Pages.
When extending SeamTest, I can simulate a FacesRequest, and here I can overwrite the processValidationsPhase. There is a bultin method called validateValue, but this is just for Hibernate Validator Validations. So how can I invoke JSF Validators manually? Has anyone done this successfully before?
Is searched the whole JBoss JIRA and the JBoss Forums for a solution, but did not find anything, besides that it was asked very often, but never answered :(
You can use Selenium (firefox add-on) for testing.
Once you have recorded the tests, you can export to plain Java code, and use it in your extended SeamTest class, making sure that the values are required = true are in the request.
To learn more, see http://seleniumhq.org/projects/ide/
I have links and pictures related to these links on my page. I want to change the pictures everytime when onmouseover event occurred in the links. I want to do this in JSF.
A lot of Thanks to everyone.
You are looking specifically for JSF to do it, or you are open to other Javascript frameworks that provide a slick and easy solution on this? For example Jquery and Dojo etc may be easy to incorporate in your application and will give Rich UI effects.
On the other hand if you are looking at JSF specifically for these UI effects than probably I can try to think of some ways and let you know.
JSF isn't designed directly to do this; It's designed to give you the tools to do this yourself. In order to do this you would need to create a custom JSF component to do this and you would use Java script to do it.
You could possibly find a JSF framework that does this already (a4j, IceFaces, etc.) but this is such a simple and well documented JavaScript thing that just tossing a little Java script among your JSF is perfectly acceptable. However, if you don't want to reinvent the wheel, take a look at those other options.
Javascript solution:
Define onmouseover event on the commandLink tag calling some kind of javascript you may give link address from like onmouseover="doSomething('addressOfImage')" then in doSomething javascript method, first find the image, then set src attribute of a default image to given address.
JSF Solution:
You might want to use a4j for this.
Add a4j:support to link for onmouseover event then just rerender graphicImage component ofcourse you need to give value of graphicImage dynamically. There is an example of using a4j support below. You can add this a4j:support between your link tags for mouseonover event. Then manage everything on backing bean to handle which image to be displayed.
example
<h:graphicImage id="imageToBeRendered" value="#{myBean.imageAddress}"/>
Just google a4j if you have no idea.
I noticed that c:set does not work well used inside "include of include of include", as important notice facelets documentation does't recommend it too.
Now I am using ui:param inside ui:include, but it is a bit dispersive when no attached notes about params comes with the include, is there something other way to declare "global vars"?
This is really a matter of trying to fit old JSP programming into the JSF framework. You should be using backing beans to hold your data.
If you try to hard-code data directly into your xhtml file, you are defeating the purpose of JSF's MVC framework. If you have a specific example of what you are trying to do, I could give you a specific recommendation.