Access Repository from Alfresco Share and change Property
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2014 10:35 AM
I am trying to change one property from my custom content type by clicking on an custom UI Action. The thing is I have very little knowledge of JavaScript. I suppose I need to create a javaScript file in share and a web script and js files in Repo. I have no idea where to put them or how to call them. I have the following code in share-config-custom.xml
< config evaluator="string-compare" condition="DocLibActions">
< actions>
< action id="example-active-enable" type="javascript" label="Active" icon="folder-manage-permissions">
< param name="function">onActionSimpleRepoAction</param>
< permissions>
< permission allow="true">Write</permission>
< /permissions>
< param name="action">enable-active-flag</param>
< param name="successMessage">message.active-flag.success</param>
< param name="failureMessage">message.active-flag.failure</param>
< evaluator>example.evaluator.doclib.action.notActive</evaluator>
< /action>
< action id="example-active-disable" type="javascript" label="Inactive" icon="folder-manage-permissions">
< param name="function">onActionSimpleRepoAction</param>
< permissions>
< permission allow="true">Write</permission>
< /permissions>
< param name="action">disable-active-flag</param>
< param name="successMessage">message.active-flag.success</param>
< param name="failureMessage">message.active-flag.failure</param>
< evaluator>example.evaluator.doclib.action.active</evaluator>
< /action>
< /actions>
< actionGroups>
< actionGroup id="folder-browse">
< action index="510" id="example-active-enable" />
< action index="520" id="example-active-disable" />
< /actionGroup>
< /actionGroups>
< /config>
I followed the Jeff Potts tutorial on Custom Actions http://ecmarchitect.com/alfresco-developer-series-tutorials/actions/tutorial/tutorial.html but can not quite finish my objective by using only the one. The custom-context.xml contains
< bean id="set-active-flag" class="example.action.executer.SetActiveFlag" parent="action-executer">
< property name="nodeService">
< ref bean="NodeService" />
< /property>
< /bean>
< bean id="enable-active-flag" class="example.action.executer.EnableWebFlag" parent="set-active-flag">
< property name="publicAction">
< value>false</value>
< /property>
< /bean>
< bean id="disable-active-flag" class="example.action.executer.DisableWebFlag" parent="set-active-flag">
< property name="publicAction">
< value>false</value>
< /property>
< /bean>
The example.action.executer.SetActiveFlag, example.action.executer.EnableWebFlag and example.action.executer.DisableWebFlag are the same as the ones from the tutorial. But I don`t need to add aspect as it is shown there - I need to change a property!
I need to change a property my:isActive from my custom model, but have no idea how to do this. Can somebody help
? It would be very appreciated!
Thanks in advance.
< config evaluator="string-compare" condition="DocLibActions">
< actions>
< action id="example-active-enable" type="javascript" label="Active" icon="folder-manage-permissions">
< param name="function">onActionSimpleRepoAction</param>
< permissions>
< permission allow="true">Write</permission>
< /permissions>
< param name="action">enable-active-flag</param>
< param name="successMessage">message.active-flag.success</param>
< param name="failureMessage">message.active-flag.failure</param>
< evaluator>example.evaluator.doclib.action.notActive</evaluator>
< /action>
< action id="example-active-disable" type="javascript" label="Inactive" icon="folder-manage-permissions">
< param name="function">onActionSimpleRepoAction</param>
< permissions>
< permission allow="true">Write</permission>
< /permissions>
< param name="action">disable-active-flag</param>
< param name="successMessage">message.active-flag.success</param>
< param name="failureMessage">message.active-flag.failure</param>
< evaluator>example.evaluator.doclib.action.active</evaluator>
< /action>
< /actions>
< actionGroups>
< actionGroup id="folder-browse">
< action index="510" id="example-active-enable" />
< action index="520" id="example-active-disable" />
< /actionGroup>
< /actionGroups>
< /config>
I followed the Jeff Potts tutorial on Custom Actions http://ecmarchitect.com/alfresco-developer-series-tutorials/actions/tutorial/tutorial.html but can not quite finish my objective by using only the one. The custom-context.xml contains
< bean id="set-active-flag" class="example.action.executer.SetActiveFlag" parent="action-executer">
< property name="nodeService">
< ref bean="NodeService" />
< /property>
< /bean>
< bean id="enable-active-flag" class="example.action.executer.EnableWebFlag" parent="set-active-flag">
< property name="publicAction">
< value>false</value>
< /property>
< /bean>
< bean id="disable-active-flag" class="example.action.executer.DisableWebFlag" parent="set-active-flag">
< property name="publicAction">
< value>false</value>
< /property>
< /bean>
The example.action.executer.SetActiveFlag, example.action.executer.EnableWebFlag and example.action.executer.DisableWebFlag are the same as the ones from the tutorial. But I don`t need to add aspect as it is shown there - I need to change a property!
I need to change a property my:isActive from my custom model, but have no idea how to do this. Can somebody help

Thanks in advance.
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2015 01:08 AM
A good starting point would be adding something like the following to your custom action java class;
static final String SEEDIM_MODEL_1_0_URI = "http://www.seedim.com.au/model/1.0";
//create a qname for your custom property
static final QName MY_ISACTIVE = QName.createQName(SEEDIM_MODEL_1_0_URI, "isActive");
//pass on the nodeRef being act upon, the qname of your custom property and the value you want to set.
nodeService.setProperty(nodeRef, MY_ISACTIVE, true);
static final String SEEDIM_MODEL_1_0_URI = "http://www.seedim.com.au/model/1.0";
//create a qname for your custom property
static final QName MY_ISACTIVE = QName.createQName(SEEDIM_MODEL_1_0_URI, "isActive");
//pass on the nodeRef being act upon, the qname of your custom property and the value you want to set.
nodeService.setProperty(nodeRef, MY_ISACTIVE, true);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2015 03:32 AM
By my custom action java class you mean the SetWebFlag class from the tutorial or another class that I should write?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2015 07:05 PM
Putting it in EnableWebFlag class would make more sense.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2015 04:26 AM
It underlines the nodeRef variable and says nodeRef cannot be resolved to a variable… I tried searching but can't find what is the problem?
This is the EnableWebFlag.java class
import company.model.myModel;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.cmr.repository.NodeService;
public class EnableWebFlag extends SetActiveFlag {
protected NodeService nodeService;
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
action.setParameterValue(SetEnableFlag.PARAM_ACTIVE, true);
QName MY_ISACTIVE = QName.createQName(myModel.NAMESPACE_COMPANY_ACTIVE_CONTENT_MODEL, "isActive");
//pass on the nodeRef being act upon, the qname of your custom property and the value you want to set.
nodeService.setProperty(nodeRef, MY_ISACTIVE, true);
super.executeImpl(action, actionedUponNodeRef);
}
}
This is the EnableWebFlag.java class
import company.model.myModel;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.cmr.repository.NodeService;
public class EnableWebFlag extends SetActiveFlag {
protected NodeService nodeService;
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
action.setParameterValue(SetEnableFlag.PARAM_ACTIVE, true);
QName MY_ISACTIVE = QName.createQName(myModel.NAMESPACE_COMPANY_ACTIVE_CONTENT_MODEL, "isActive");
//pass on the nodeRef being act upon, the qname of your custom property and the value you want to set.
nodeService.setProperty(nodeRef, MY_ISACTIVE, true);
super.executeImpl(action, actionedUponNodeRef);
}
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2015 05:25 AM
I needed to put actionedUponNodeRef instead of nodeRef
THANKS A LOT!!!
The two lines worked the miracle needed to complete the action
QName MY_ISACTIVE = QName.createQName(myModel.NAMESPACE_COMPANY_ACTIVE_CONTENT_MODEL, "isActive");
//pass on the nodeRef being act upon, the qname of your custom property and the value you want to set.
nodeService.setProperty(actionedUponNodeRef, MY_ISACTIVE, true);
Thanks,
Irena

The two lines worked the miracle needed to complete the action

QName MY_ISACTIVE = QName.createQName(myModel.NAMESPACE_COMPANY_ACTIVE_CONTENT_MODEL, "isActive");
//pass on the nodeRef being act upon, the qname of your custom property and the value you want to set.
nodeService.setProperty(actionedUponNodeRef, MY_ISACTIVE, true);
Thanks,
Irena
