Where to place resource-action-mapping in Liferay-Portlet? - permissions

I am trying to add permissions to a Liferay-Portlet based on the documentation of Liferay. Since the Portlet will be delivered in a war-package, I want to mantain the permission definition of the portlets inside the portlet itself.
I created a file resource-actions.xml with the following content (portlet-name is identical to the name specified in portlet.xml and liferay-*.xml):
<?xml version="1.0"?>
<resource-action-mapping>
<portlet-resource>
<portlet-name>test-portlet</portlet-name>
<supports>
<action-key>SELECT</action-key>
<action-key>VIEW</action-key>
<action-key>TEST_PERM</action-key>
</supports>
<community-defaults>
<action-key>VIEW</action-key>
</community-defaults>
<guest-defaults>
<action-key>VIEW</action-key>
</guest-defaults>
</portlet-resource>
There is no model-resource defined, because first I just want to see, if Liferay loads the permissions I set in the mapping file.
I placed the file in the folders
- WEB-INF
- WEB-INF/classes
- inside the portal-impl.jar of Liferay
- ...
But the new permission TEST_PERM does not show up under Control Panel -> Roles -> Define Permissions -> Add Portlet Permissions -> test-portlet. Does anybody know, what I am doing wrong here?

I posted this question in the offical Liferay forum and got a nice reply:
I've faced this before and placed resource file in \WEB-INF\classes\resource-actions
my resource-actions.zip is attached. hope it helps
UPDATE:
Link to the Liferay-Forum: Where to place resource-action-mapping in Liferay-Portlet?

Related

how to remove link to resource list view from menu?

I'm currently building out an application that has a boatload of resources that i will need list views of but don't want links to the list views in the menu. Is there a way to have access to them without having links on the side? to create the list i'm doing the following.
<resources
list={EmployeeList}
/>
docs don't mention this so any help would be appreciated.
I have say ~45 resources that i will need to access list views but only 6 or so are major enough to be accessed from the main menu. i'd still want access to them by viewing details of the other lists or show pages.
I'm no sure how or where you need to access these resources, but this is what I've done with some "lesser" resources I don't need to have the "List" view or sidebar link to:
Define
<Resource name="myresource" />
in App.js. Now you can make a list for example inside another resource's "show" view by using <ReferenceManyField resource="myresource" />

Sharepoint 2010 - how do I add a page using code

How do I add a new page on sharepoint using code?
I am coding site using SPservices, javascript and jquery
I pull the link from a List and use this variable to call the web page.
however if the page does not exist -- I will get page can not be displayed screen when I click on the on click event
is it possible to do the following?
1, check if the page exists
2, if page does not exist create a blank page
any help would be very grate full as I have searched online for days on end to find a solution
You can add the pages by referring the below steps:
1.Create a new folder, "Pages", under your solution
2.Add a new module,for eg. SampleModule
Module folder structure
3.Add an application page, for eg. SampleApplicaionPage.aspx. The newly added application pages can be found under Layouts Folder.
4.Drag and drop the newly created aspx page into the created "SampleModule", under pages folder.
5.Make necessary changes (module name, required layout, etc.,) in the element.xml file associated with the module as follows:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages" Url="$Resources:cmscore,List_Pages_UrlName;">
<File Path="SampleModule\SampleApplicationPage.aspx" Url="SampleApplicationPage.aspx" Type="GhostableInLibrary" ReplaceContent="True">
<Property Name="Sample Module" Value="Sample Module"/>
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/EnterpriseWiki.aspx, EnterpriseWiki"/>
</File>
</Module>
</Elements>
Update the following section in the SampleApplicationPage.aspx
<%# Page Language=”C#”
AutoEventWireUp=”true”
CodeBehind=”ChooseChecklist.aspx.cs”
Inherits=”YourProjectName.YourModuleName.YourClassName”
MasterPageFile=”../_catalogs/masterpage/V4.master” %>
Deploy.
You can view the newly created page under the specified module in Site Contents
Hope this helps.
Final Folder Structure

Liferay custom portlet permission label missing

I've followed the instructions from this tutorial to introduce a new portlet level permission for my custom portlet.
In the resource-action-mapping XML there is a new action-key called PARTNER_ADMIN_CONTRACTING, and I've added the following line to the Language.properties file:
action.PARTNER_ADMIN_CONTRACTING=Admin contracting
On the Define permissions tab, it still shows the label key, not the value:
What's missing?
You have to add the action.PARTNER_ADMIN_CONTRACTING=Admin contracting language key to the portal resource bundle, because the Control Panel does not look for the translation in your portlet. You can use the language hook feature do to this:
Create a liferay-hook.xml in your docroot/WEB-INF directory:
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
<hook>
<language-properties>content-portal/Language.properties</language-properties>
</hook>
Create docroot/WEB-INF/src/content-portal/Language.properties:
action.PARTNER_ADMIN_CONTRACTING=Admin contracting
This should work!

Using Visibility (Default) attribute in MVCSitemap to show nodes only in breadcrumbs

Anyone who has achieved a single xml file but different menu and breadcrumbs with MVCSiteMapProvider package.
I have MVC.Sitemap all working well with my menu and breadcrumbs. I have added a new node for Home - Products
This is Index Action on Products Controller
I dont want this to appear in my menu but I do want it to appear in my Breadcrumbs when someone lands on /myapp/Products/Index or Products/Index
At the moment I am using visibility="SiteMapPathHelper,!*" picked up from the example and I am assuming the latest nuget package and my web.config is setup with
attributesToIgnore="visibility"
which is confusing as i dont understand that does this mean to ignore the parameters or does it tell that nodes that need to be ignored are filled with this parameter and value should be taken as condition.
By default, any attribute MvcSiteMapProvider sees in your menu XML declaration is added to the url parameter.
So, if you have this:
<mvcSiteMapNode area="Admin" controller="User" action="Index" title="Users" someRandomAttribute=3/>
the sitemap will use
/admin/user/index?someRandomAttribute=3 for the url.
If you put attributesToIgnore="someRandomAttribute" in the config, the url it will generate will become:
/admin/user/index
The visibility provider is a plug-in system - and the default one uses a 'visibility' attribute so it can decide if the node is visible or not.

Change the Category for Web Part to be displayed

In Sharepoint 2010, is there any way to change the category where custom web parts created in VS2010 to be placed.
VS2010 is putting the custom web part in "Custom" category by default. I'm curious that, is there any way for us to change it, for example "MyCustomWebParts" category.
incase I couldn't made myself clear:
You can change file Elements.xml. Into File tag add line:
<Property Name="Group" Value="MyCustomWebPart" />
or
Select “Site Actions” >> “Site Settings” >> “Modify All Site Settings”.
Click the “Web Parts” link in the Galleries group.
Open your webpart for edit.
In the Group section, check the “Specify your own value” option and type in a group name (e.g. MyCustomWebParts)
There is! In the .webpart file, under the Module/File path, add a tag like this:
<Property Name="Group" Value="My Custom Group"/>
That's all there is to it!