09-11-2012 06:33 AM
Hi,
In Nuxeo Studio, I created a "User Action" attached to a specific contentView (category) and I would like the button is active only when the selected documents are in a life cycle validated?
I can not use in this case the "current document has life cycle" because I'm in a contentView but an EL expression like this:
$ {selectedDocument.currentLifeCycleState = 'approved'}
But my syntax is not correct?
Thank you

09-12-2012 07:06 AM
Hi,
I publish the final code for users interested
@Name("yourProjectAction")
@Scope(ScopeType.EVENT)
public class yourProjectAction implements Serializable {
private static final long serialVersionUID = 1L;
@In(create = true, required = false)
protected transient CoreSession documentManager;
@In(create = true)
protected NavigationContext navigationContext;
@In(create = true)
protected DocumentsListsManager documentsListsManager;
protected List<DocumentModel> getCurrentlySelectedDocuments() {
if (navigationContext.getCurrentDocument().isFolder()) {
return documentsListsManager.getWorkingList(DocumentsListsManager.CURRENT_DOCUMENT_SELECTION);
} else {
return null;
}
}
public boolean isSelectionAreAllApproved() throws ClientException {
List<DocumentModel> selectedDocs = getCurrentlySelectedDocuments();
if (selectedDocs == null) {
return false;
}
for (DocumentModel doc : selectedDocs) {
if (!doc.getCurrentLifeCycleState().equals("approved")) {
return false;
}
}
return true;
}
}
09-11-2012 07:51 AM
There is no way (I think to do with just a simple EL.
The way (not so hard) is to use Nuxeo IDE if you have a bit development skills :
And in it:
List<DocumentModel> selectedDocs = getCurrentlySelectedDocuments();
if (selectedDocs != null) {
return false;
}
for (DocumentModel doc : selectedDocs) {
if (!doc.getCurrentLifeCycleState().equals("approve")) {
return false;
}
return true;
And in your el just fill : yourProjectActions.selectionAreAllApproved
You will have to clean up a bit what have generated the Nuxeo IDE template (create a button hello world => you can look what have been generated to understand a bit more Nuxeo behind the Nuxeo Studio scene). But in your case you will have to :
To generate the jar => right click on the project name > Nuxeo > Export jar...
To install it into your Nuxeo instance copy it in $Nuxeo_HOME/nxserver/bundles
Hope will help.
09-12-2012 07:06 AM
Hi,
I publish the final code for users interested
@Name("yourProjectAction")
@Scope(ScopeType.EVENT)
public class yourProjectAction implements Serializable {
private static final long serialVersionUID = 1L;
@In(create = true, required = false)
protected transient CoreSession documentManager;
@In(create = true)
protected NavigationContext navigationContext;
@In(create = true)
protected DocumentsListsManager documentsListsManager;
protected List<DocumentModel> getCurrentlySelectedDocuments() {
if (navigationContext.getCurrentDocument().isFolder()) {
return documentsListsManager.getWorkingList(DocumentsListsManager.CURRENT_DOCUMENT_SELECTION);
} else {
return null;
}
}
public boolean isSelectionAreAllApproved() throws ClientException {
List<DocumentModel> selectedDocs = getCurrentlySelectedDocuments();
if (selectedDocs == null) {
return false;
}
for (DocumentModel doc : selectedDocs) {
if (!doc.getCurrentLifeCycleState().equals("approved")) {
return false;
}
}
return true;
}
}
09-12-2012 07:18 AM
Thank you for the community. I marked your answer as the one. Mine is more general.