All what I want is to pick up an ActionEvent when the DataPager is clicked. Is that too much?! :S

9 views
Skip to first unread message

David Crespo

unread,
Aug 10, 2016, 7:50:09 AM8/10/16
to Alfresco Technical Discussion
Hi folks,

First of all, I would like to thank the Alfresco community for all the great support and contributions. It is nice to find help when once needs it.

Now, let me cut the chase. My problem looks simple, it should be simple and straightforward, but I am struggling to solve it. I am using the richList UIComponent and the dataPager UICommand, this last one as a child of the richList, just as the Alfresco Explorer source is using it. I am using those components to display all the pooled workflow tasks in the system and paging the result. Until now everything works smoothly. Now, I need to pick up the ActionEvent when the DataPager is clicked with the aim to find out what the next current page will be, since I am improving the paging mechanism by building the model for just the workflow tasks in the current page, rather than for all the resulting workflow tasks, as it does by default. This change will improve very significantly the performance when loading the worflow tasks in the dashboard, and the end users will be happy because they don't have to wait an average of 7 sec to move between pages.

Now, taking a look at the UICommand class (https://docs.oracle.com/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.1/docs/api/) it says:

"When the decode() method of this UICommand, or its corresponding Renderer, detects that this control has been activated, it will queue an ActionEvent. Later on, the broadcast() method will ensure that this event is broadcast to all interested listeners."

Great! I just need to add a new Listener to the DataPager and I will be notified when someone clicks that UIcomponent. Therefore, I take a look at the ActionListener type (https://docs.oracle.com/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.1/docs/api/) and it says:

"A listener interface for receiving ActionEvents. A class that is interested in receiving such events implements this interface, and then registers itself with the source UIComponent of interest, by calling addActionListener(). "

I feel very excited at this point since it looks very promising. Therefore, I implement my customActionListener and then I added to the DataPager UIComponent by dataPager.addActionListener(). At this point, I have to tell  you that I am getting the DataPager UIComponent in my managed bean by binding it, just like this:

<a:dataPager styleClass="pager" binding="#{WorkflowDashletBean.dataPager}" />

This way the dataPager filed in my WorkflowDashletBean is initialized with the dataPager component.

Anyway, I have not yet been able to get this working. My CustomActionListener does not do anything when I click on the dataPager component, so I think that I am not adding the listener to the right dataPager component. In particular, I would like to know whether or not my approach to pick up that ActionEvent from the DataPager is correct or not, and It would be great if you could share or give me some feedback about getting this working.


May Thanks,
David


 

David Crespo

unread,
Aug 12, 2016, 1:32:58 PM8/12/16
to Alfresco Technical Discussion
Hi all, 

Forget about this issue. I just found a workaround because the approach mentions below does not work. My workaround is to get rid of the alfresco component datapager and create my own one, just a few tags and a few methods are needed. Using my own datapager I am able now to use events such as action, valueChangeListener, etc. Another trick for those who get involved in this, is to pass inputHidden parameters with values from the current page and context and then get them in the managed bean using FaceContext externalContext.

I understand that what I am saying might not make much sense for the majority of you guys. Anyway I just wanted to mention here briefly how I get over my issue just in case someone else may need it. 

Have a good weekend, 
David    
Reply all
Reply to author
Forward
0 new messages