cancel
Showing results for 
Search instead for 
Did you mean: 

Syntax to access bpm:authorityName property in dashlet?

jdbrown
Champ in-the-making
Champ in-the-making
I am wanting to customize the tasks-active-dashlet to add a column to display the name of the bpmSmiley TongueooledActors for the tasks that have not yet been assigned an owner.

I am stuck on the syntax to access the actual usr:authorityName property within the JSP.

For example, I get this far, but not sure how on the syntax to access a property of bpmSmiley TongueooledActors.

<h:outputText id="col2b-txt" value="#{r['bpm:pooledActors']}" />

Any ideas on the best way to approach this?
5 REPLIES 5

gavinc
Champ in-the-making
Champ in-the-making
You can't access this data as a property as it is not a property, bpmSmiley TongueooledActors is defined in the model as an association.

In order to get this information you will need to add it to the property map for the task. Take a look at WorkflowBean.getAllActiveTasks(), this is where the list of tasks is built up. This in turn calls the protected createTask() method, it's in here you could retrieve the association and build a string representation of the assignee. Then add it as a property i.e.

node.getProperties().put("assignee", assignee);

Then in the JSP you could add:

<h:outputText id="col2b-txt" value="#{r.assignee}" />

Hope that helps!

jdbrown
Champ in-the-making
Champ in-the-making
Thanks Gavin!

Here is the code in case anyone is interested.  I created my own class, extending the product's class.


public class CustomWorkflowBean extends WorkflowBean {

   private static final Log logger = LogFactory.getLog(CustomWorkflowBean.class);

   public static final String BEAN_NAME = "CustomWorkflowBean";

   /**
    * Runs the super method for this and then adds an additional
    * custom property for displaying the pooled group name to the
    * task.
    *
    */
   protected TransientMapNode createTask(WorkflowTask task) {

      TransientMapNode node = super.createTask(task);

      List<NodeRef> pooledNodeRefs = (ArrayList<NodeRef>) task.properties.get(WorkflowModel.ASSOC_POOLED_ACTORS);

      if (pooledNodeRefs != null && pooledNodeRefs.size() > 0) {
         NodeRef pooledNodeRef = pooledNodeRefs.get(0);
         int offset = PermissionService.GROUP_PREFIX.length();
         String group = (String) nodeService.getProperty(pooledNodeRef, ContentModel.PROP_AUTHORITY_NAME);
         if (group != null) {
            String groupName = group.substring(offset);
            node.getProperties().put("pooledGroupName", groupName);
         }
      }

      return node;
   }
}

Note that in my use case, the pooledactors is always a group so I did not bother with handling the case when it is not.

Then, in my dashlet:

<h:outputText id="col2b-txt" value="#{r.pooledGroupName}" />

zomba
Champ in-the-making
Champ in-the-making
Hi, I'm newbie on Alfresco, and I'm try to create a new Dashlet that show the group assigned to my completed tasks.

I follow the steps on this topic, extending previously the default WorkflowBean buy I don't know how (where) to configure this bean.

From my JSP Dashlet I've try to use my new bean automatically, without any configuration, but obviously, it doesn't work:

#{CustomWorkflowBean.tasksCompleted}

My question is, where I can configure my CustomWorkflowBean?

Sorry…This is my first post and my english is really bad. Smiley Surprisedops:

jdbrown
Champ in-the-making
Champ in-the-making
You declare your custom bean in the your WEB-INF/faces-config-custom.xml file in your project.  If you don't already have this file, copy the one from the Web Client project and put your edits in it. 

Doing so overrides the default class for the bean named "WorkflowBean" and uses your own custom class.  In your dashlet, still reference the bean as "WorkflowBean" since you are just changing the backing Java class, not the bean name.

For example:

<managed-bean>
<managed-bean-name>WorkflowBean</managed-bean-name>
      <managed-bean-class>
   your.package.name.CustomWorkflowBean
      </managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
      <managed-property>
         <property-name>navigationBean</property-name>
         <value>#{NavigationBean}</value>
      </managed-property>
      <managed-property>
         <property-name>nodeService</property-name>
         <value>#{NodeService}</value>
      </managed-property>
      <managed-property>
         <property-name>workflowService</property-name>
         <value>#{WorkflowService}</value>
      </managed-property>
   </managed-bean>

zomba
Champ in-the-making
Champ in-the-making
Ok, a lot of thanks…(I'm newbie on JSF too :? )