How to put catche in liferay? - liferay

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);

Related

Upgrade LanguageUtil.get method

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)

cq:component vs normal component in aem

I want to know what is the difference between if we make a component without cq: component property and with cq: component property in aem . I am new in aem so correct me if i am wrong.
Thanks in advance.
cq:primarytype is like data that you use in java, which basically define the type of node. and cq:component is like type there are many type of node available in aem on which we works so by defining cq:component use defines that node is component type. for more information have a look what is aem
First of all how can you make a component without cq:component? cq:component is the primary type of a node that you want to act as a component. If you dont declare a node as cq:component then basically its not a component and you cannot reuse it in any other of the page. You can think jcr:primary types as the data types used in java or any other programming language.
Hope this clears the doubt!!!
As mentioned above, cq:Component is the jcr:primaryType of a Component.
jcr:primaryType is the type of the node you are creating, in your case, a component.
By default a node has the jcr:primaryType nt:unstructured, and if you want to change it to give more specific functionality, like a component, template, clientlibrary, you have options to do so.

Liferay overriding JSONAction using hook

Liferay has feature to modify Struts Action using hook which is straight-forward. However I am trying to override getJSON method of RateEntryAction.
The use case is I need total positive score and total negative score instead of average score that Liferay's OOTB rating component provides.
I already have necessary methods readily available in Liferay API to get the total positive and negative scores. I created a custom type just like "stars" and "votes" to write my necessary logic in hook. I was then planning to override struts action represented by /portal/rate_enty to override the method and add negative and positive votes in the json that is already being returned.
But RateEntryAction (which is the original class) is extending JSONAction and overriding getJSON method. Is it possible to override just getJSON method using struts action hook?
I can see this action class in struts-config.xml, so it's a Struts Action.
This is the path you could try to override.
<action path="/portal/rate_entry" type="com.liferay.portal.action.RateEntryAction" />
I would try to override this path, and see if can put your logic there.
RateEntryAction extends from JSONAction , and this one from org.apache.struts.action.Action , which is the same class that PortletAction extends.
Hope this help
As per my research we can only hook com.liferay.portal.struts.PortletAction sub classes, Yeah JSONAction also extend org.apache.struts.action.Action class same as PortletAction, but liferay allow only those classes hookable which comes under PortletAction class not except that.
As RateEntryAction is not a Struts Action, you can't overload it with a Struts Action Hook. I'm not aware of any hookable way to override it, thus my best guess is that you'll have to either go for ext or introduce a whole new JSON API function and hook all places in Liferay that refer to the original implementation to now go to your implementation.
I suspect that in this case an ext plugin will be easier to maintain. Someone correct me if I'm wrong.

Liferay - Translate

I am using Liferay 6.1.0 GA1.
I added Documents and Media portlet. When I change language in Add menu, it is still named Documents and Media display.
Where I can change that?
Edit: I have hook for translations I just don't know what to write to make it work.
As excepcted for rookie, problem was trivial.
In portlet.xml name wasn't documents-and-media. It was some number.
So then just javax.portlet.title.1= fixed it.
If You don't have a hook, look there -
https://www.liferay.com/community/wiki/-/wiki/Main/Portal+Hook+Plugins
https://www.liferay.com/community/forums/-/message_boards/message/5368654

How many ways there are to declare variables in facelets?

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.

Resources