<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: User Action active in a specific contentView and LifeCycle for selected Document in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320623#M7624</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I publish the final code for users interested&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@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&amp;lt;DocumentModel&amp;gt; getCurrentlySelectedDocuments() {

    if (navigationContext.getCurrentDocument().isFolder()) {
        return documentsListsManager.getWorkingList(DocumentsListsManager.CURRENT_DOCUMENT_SELECTION);
    } else {
        return null;
    }
}    

public boolean isSelectionAreAllApproved() throws ClientException {

    List&amp;lt;DocumentModel&amp;gt; selectedDocs = getCurrentlySelectedDocuments();
    if (selectedDocs == null) {
      return false;
    }
    for (DocumentModel doc : selectedDocs) {
        if (!doc.getCurrentLifeCycleState().equals("approved")) {
          return false;
        }
    }
    return true;
 }
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Sep 2012 11:06:23 GMT</pubDate>
    <dc:creator>Pierre_Jenicot1</dc:creator>
    <dc:date>2012-09-12T11:06:23Z</dc:date>
    <item>
      <title>User Action active in a specific contentView and LifeCycle for selected Document</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320621#M7622</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;$ {selectedDocument.currentLifeCycleState = 'approved'}&lt;/P&gt;
&lt;P&gt;But my syntax is not correct?&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://connect.hyland.com/upfiles/Capture_2.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 10:33:24 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320621#M7622</guid>
      <dc:creator>Pierre_Jenicot1</dc:creator>
      <dc:date>2012-09-11T10:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: User Action active in a specific contentView and LifeCycle for selected Document</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320622#M7623</link>
      <description>&lt;P&gt;There is no way (I think to do with just a simple EL.&lt;/P&gt;
&lt;P&gt;The way (not so hard) is to use Nuxeo IDE if you have a bit development skills :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I let you look the Nuxeo IDE installation documentation : &lt;A href="http://doc.nuxeo.com/x/ZYKE" target="test_blank"&gt;http://doc.nuxeo.com/x/ZYKE&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Then you create a new Nuxeo Plugin Project (click on the yellow button &amp;gt; new Nuxeo Plugin name it &amp;gt; next &amp;gt; next )&lt;/LI&gt;
&lt;LI&gt;finally create an Action Bean (for instance named &lt;STRONG&gt;YourProjectAction&lt;/STRONG&gt;) with the yellow button &amp;gt; next &amp;gt; next&lt;/LI&gt;
&lt;LI&gt;create a method into the java class created named &lt;STRONG&gt;isSelectionAreAllApproved&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;And in it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    List&amp;lt;DocumentModel&amp;gt; selectedDocs = getCurrentlySelectedDocuments();
    if (selectedDocs != null) {
      return false;
    }
    for (DocumentModel doc : selectedDocs) {
    if (!doc.getCurrentLifeCycleState().equals("approve")) {
      return false;
    }
    return true;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And in your el just fill : yourProjectActions.selectionAreAllApproved&lt;/P&gt;
&lt;P&gt;You will have to clean up a bit what have generated the Nuxeo IDE template (create a button hello world =&amp;gt; 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 :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;remove the getCurrentlySelectedDocuments, doGet, accept methods in the java class&lt;/LI&gt;
&lt;LI&gt;remove the /src/main/resources/OSGI-INF/extensions/org.nuxeo.sample.YourProjectActionsBean.xml xml file&lt;/LI&gt;
&lt;LI&gt;remove the /src/main/resources/OSGI-INF/l10n directory&lt;/LI&gt;
&lt;LI&gt;remove the /src/main/resources/web directory&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To generate the jar =&amp;gt; right click on the project name &amp;gt; Nuxeo &amp;gt; Export jar...&lt;/P&gt;
&lt;P&gt;To install it into your Nuxeo instance copy it in $Nuxeo_HOME/nxserver/bundles&lt;/P&gt;
&lt;P&gt;Hope will help.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 11:51:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320622#M7623</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-09-11T11:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: User Action active in a specific contentView and LifeCycle for selected Document</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320623#M7624</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I publish the final code for users interested&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@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&amp;lt;DocumentModel&amp;gt; getCurrentlySelectedDocuments() {

    if (navigationContext.getCurrentDocument().isFolder()) {
        return documentsListsManager.getWorkingList(DocumentsListsManager.CURRENT_DOCUMENT_SELECTION);
    } else {
        return null;
    }
}    

public boolean isSelectionAreAllApproved() throws ClientException {

    List&amp;lt;DocumentModel&amp;gt; selectedDocs = getCurrentlySelectedDocuments();
    if (selectedDocs == null) {
      return false;
    }
    for (DocumentModel doc : selectedDocs) {
        if (!doc.getCurrentLifeCycleState().equals("approved")) {
          return false;
        }
    }
    return true;
 }
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Sep 2012 11:06:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320623#M7624</guid>
      <dc:creator>Pierre_Jenicot1</dc:creator>
      <dc:date>2012-09-12T11:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: User Action active in a specific contentView and LifeCycle for selected Document</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320624#M7625</link>
      <description>&lt;P&gt;Thank you for the community. I marked your answer as the one. Mine is more general.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2012 11:18:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/user-action-active-in-a-specific-contentview-and-lifecycle-for/m-p/320624#M7625</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-09-12T11:18:07Z</dc:date>
    </item>
  </channel>
</rss>

