11-16-2018 06:10 AM
I am trying to use authority.ftl to select a group that is going to be used in an action for editing group roles. How do i write the java action so that there are no erros? Tried this
protected void addParameterDefinitions(List<ParameterDefinition> list) {
list.add(new ParameterDefinitionImpl(X, DataTypeDefinition.TEXT, true,getParamDisplayLabel(X)));
}
But i got the error that the types were different, think it was field.endpointtype. What is this, and how do i get it in the addParameterDefinitions, what type does the authority.ftl return, a string? I assume that you can use AuthorityService afterwards to get the group name or something similar.
Thanks in advance for the help.
11-17-2018 08:42 AM
11-19-2018 12:13 PM
This is exactly the way I use it.
11-20-2018 07:21 AM
How do i extract the groupname from node_ref?
This is what i used when i used textfield instead of authority.
Just changed the Strings to NodeRef as stupid me didnt notice that could be done, but what class is used to get the name of the authority?
11-20-2018 07:42 AM
There are other ways, this is one of them:
NodeRef groupNodeRef = (NodeRef) action.getParameterValue(PARAM_GROUP_NAME);
String groupName = nodeService.getProperty(groupNodeRef, ContentModel.PROP_NAME).toString();
11-20-2018 07:49 AM
I tried that, but i still get the error, maybe there is something wrong with how i added the form?
11-20-2018 08:07 AM
Here is the whole class, probably makes it easier to notice where things go wrong...
The class takes the groupname, makes a folder of it, and gives permissions to the group
11-20-2018 09:24 AM
Probably you have to add "GROUP_" to the name of the group to set permissions.
11-20-2018 12:11 PM
Ah ok, i did add that on the previous version, but thought that the name you got from NODE_REF was GROUP_X. Will test by tomorrow. Thanks for all the help so far! Been stuck for ages on this one.
11-20-2018 08:18 AM
You can do something like:
final NodeRef group = (NodeRef) action.getParameterValue(PARAM_GROUP_NAME); // your parameter should be simply PARAM_GROUP, as there is no real name in it
Map<QName, Serializable> groupProperties = nodeService.getProperties(group);
And then you can read the property you want from the groupProperties object.
I have not tested the code, but I guess you will be able to fix it if required.
Explore our Alfresco products with the links below. Use labels to filter content by product module.