Forums de discussion

JSF + Service builder + Permission

zohour abouakil, modifié il y a 9 années.

JSF + Service builder + Permission

New Member Publications: 2 Date d'inscription: 26/06/14 Publications récentes
Hello everybody,

I'm newbie to liferay. I'm using liferay 6.2 Tomcat.


I want to persist data in the database so I used Service Builder like explained in the liferay documentation. But when I want to add a "Employe" I get this error :

com.liferay.portal.ResourceActionsException: There are no actions associated with the resource pack.DB.model.Employe

I tried to search on the net and found that I have to add permission and action key :

So I add Employe.xml file to src/resource-actions

<?xml version="1.0"?>
<!DOCTYPE resource-action-mapping PUBLIC
"-//Liferay//DTD Resource Action Mapping 6.2.0//EN"
"http://www.liferay.com/dtd/liferay-resource-action-mapping_6_2_0.dtd">

<resource-action-mapping>
<portlet-resource>
<portlet-name>EmployeApp</portlet-name>
<permissions>
<supports>
<action-key>ADD_TO_PAGE</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</supports>
<site-member-defaults>
<action-key>VIEW</action-key>
</site-member-defaults>
<guest-defaults>
<action-key>VIEW</action-key>
</guest-defaults>
<guest-unsupported>
<action-key>CONFIGURATION</action-key>
</guest-unsupported>
</permissions>
</portlet-resource>

<model-resource>
<model-name>pack.DB.model.Employe</model-name>
<portlet-ref>
<portlet-name>EmployeApp</portlet-name>
</portlet-ref>
<weight>1</weight>
<permissions>
<supports>
<action-key>ADD_EMPLOYE</action-key>
<action-key>VIEW</action-key>
</supports>
<site-member-defaults>
<action-key>ADD_EMPLOYE</action-key>
<action-key>VIEW</action-key>
</site-member-defaults>
<guest-defaults>
<action-key>ADD_EMPLOYE</action-key>
<action-key>VIEW</action-key>
</guest-defaults>
</permissions>
</model-resource>
</resource-action-mapping>


and add to the same folder the file default.xml :

<?xml version="1.0"?>
<!DOCTYPE resource-action-mapping PUBLIC
"-//Liferay//DTD Resource Action Mapping 6.2.0//EN"
"http://www.liferay.com/dtd/liferay-resource-action-mapping_6_2_0.dtd">

<resource-action-mapping>
<resource file="resource-actions\Employe.xml" />
</resource-action-mapping>



and I add to src the file portlet.properties.


But I still have the same problem. emoticon

can someone help me please.
thumbnail
Vernon Singleton, modifié il y a 9 années.

RE: JSF + Service builder + Permission

Expert Publications: 315 Date d'inscription: 14/01/13 Publications récentes
Hi Zohour,

I just answered another fellow's post about creating JSF portlets that use Service Builder.
Maybe that post would be helpful to you also, since it describes how to start creating your own entities with service builder:
https://www.liferay.com/community/forums/-/message_boards/message/39656934

zohour abouakil:
I want to persist data in the database so I used Service Builder like explained in the liferay documentation. But when I want to add a "Employe" I get this error :

com.liferay.portal.ResourceActionsException: There are no actions associated with the resource pack.DB.model.Employe


Not sure what causes this exact error, but I do know that you simply need a portal.properties file in the root of your classpath, that contains something like this:
resource.actions.configs=resource-actions/default.xml

You would also then need a directory next to the portal.properties file called "resource-actions", and it would need to contain a file called "default.xml", and that file would need to contain the XML for the actions you noted in your post, assuming that the xml you posted was correct. I have never seen a "resource" tag like you neted you put in your default.xml ... that does not look right to me, at least it is not a feature I am aware of.

- Vernon
zohour abouakil, modifié il y a 9 années.

RE: JSF + Service builder + Permission

New Member Publications: 2 Date d'inscription: 26/06/14 Publications récentes
Hi Vernon,

Thank you very much for your answer emoticon.

I resolved the problem when I modified my xml resource file name. The exception disappeared.

But, I still don't understand the link between the command we define (example : delete, add, ...) and the action-key we add to the resource. How liferay map the command and the action-key.