1 2 3 4 Previous Next 53 Replies Latest reply on Jun 20, 2007 11:30 AM by gavin.king

    Seam jBPM: use annotation or pages.xml to get next task?

      After login, I need to show an actor a list of all owned processes, allowing the actor to click a button to get to the current task within that process (just like the jBPM web console). When clicking, a view that is applicable for that specific task will be shown, and this view might refer to some specific actions. Alternatively just a list of the current tasks would do as well, just as long as clicking the button allows me to show some task-specific view.

      So, I'd like something like:

      <h:dataTable value="#{taskInstanceList}" var="task">
       :
       <h:column>
       <s:button action="#{myGenericHandler.selectTask}" taskInstance="#{task}" value="Go"/>
       </h:column>
      </h:dataTable>


      ...but I guess I need to write my own code for action=#{myGenericHandler.selectTask} -- right?

      So: one cannot somehow use annotations or some configuration to specify what to do when a specific task is signaled by the actor, right? In other words: using annotations Seam can signal jBPM that a task is started or completed when some Java code is executed, but Seam has no means to tell what Java code needs to be triggered for some generic action.

      I know that in the jBPM web console the task-specific views are defined and stored along with the process definition itself (using forms.xml to tell what view goes with each task). This allows for rendering task-specific views.

      I also know that, when not using such form definitions but instead using Seam to define the views (while still allowing each task some specific view and action), one can use taskInstanceListForType to render the button, like the DVD Store example admin page:
      <h:dataTable value="#{taskInstanceListForType['approve']}" var="task">
       :
       <h:column>
       <s:button action="#{accept.viewTask}" taskInstance="#{task}" value="Review"/>
       </h:column>
      </h:dataTable>
      
      <h:dataTable value="#{taskInstanceListForType['ship']}" var="task">
       :
       <h:column>
       <s:button action="#{ship.viewTask}" taskInstance="#{task}" value="Ship"/>
       </h:column>
      </h:dataTable>


      I wonder if this can easily be made more "generic" (realizing that "generic" will in fact be very limited, and will not be usable for just any type of process definition).

      Thanks for any thoughts on this,
      Arjan.

        • 1. Re: Seam jBPM: use annotation or pages.xml to get next task?

          We've used jBPM and Seam a lot. It turns out the integration works great for the simplest cases, however, for issues like


          So: one cannot somehow use annotations or some configuration to specify what to do when a specific task is signaled by the actor, right?


          You'll probably find that you need to implement custom jBPM ActionHandler, DecisionHandler, etc. and place it at the 'right point' in your process definition. You're also going to find that figuring out and managing the resources (JbpmContext, EntityManager, etc.) shared between your custom jBPM code and your Seam components (and dealing with transactions) is going to be tricky.



          • 2. Re: Seam jBPM: use annotation or pages.xml to get next task?

             

            "bsmithjj" wrote:
            We've used jBPM and Seam a lot. [..] You'll probably find that you need to implement custom jBPM ActionHandler, DecisionHandler, etc. [..] figuring out and managing the resources (JbpmContext, EntityManager, etc.) shared between your custom jBPM code and your Seam components (and dealing with transactions) is going to be tricky.


            Uhuh, ok... But you're still happily using Seam with jBPM?

            And would you care to comment to another post in this forum, "seam in production systems"?

            Thanks,
            Arjan.

            • 3. Re: Seam jBPM: use annotation or pages.xml to get next task?

               

              But you're still happily using Seam with jBPM?


              Happy? Honestly, I think the Seam + jBPM hype in the early days of Seam (winter-spring 2006) was a bit over hyped and I don't think it receives enough attention by the Seam team. I think part of the problem is a lot of the features get implemented in a sort of 'toy' or 'proof-of-concept' mode - not really pushed around the block. I think the combo of jBPM + Seam + EJB3 holds a lot of promise - maybe there's opportunity for better integration between Seam and jBPM with respect to custom ActionHandlers, DecisionHandlers, things like that...possibly some even Seam base classes for these that deal with resource injection issues 'seamlessly' (e.g. JbpmContext, EntityManager, etc...).

              The jBPM API's are often weak in many areas - the core implementation and functionality is basically just what you need for long running processes. The API's (IMHO) are not really designed with the customer in mind (by customer, I mean the developer that uses the API's). As an example, try to get and cancel a timer task in a custom ActionHandler. Also, for extra points, try getting the 'current open task' on a process without knowing the taskId ahead of time via the API's... ;-)

              Anyway - I am happy using Seam, I am less happy about Seam + jBPM integration, I'm also concerned that the developers will stick with relatively simple use cases and increasingly will be distracted by all the JSF-tag library noise (first ICEFaces, now RichFaces, ...). Ultimately, I've been able to solve 'most' of my problems with jBPM and Seam, but my solutions are not as 'elegant' as they could be.

              • 4. Re: Seam jBPM: use annotation or pages.xml to get next task?
                gavin.king

                If you want the jBPM+Seam integration to improve, then you have to tell us exactly *what* limitations you are running into. I currently have only 9 open business process related issues in JIRA, most of which are definitely extremely minor, and only one of which came from a user (you).

                In fact, apart from the well-known limitation with respect to jBPM timers and asynchronous events (which is slated for fixing in 1.3), I am not aware of *any* major limitation to the Seam jBPM integration.

                I'm not claiming that there are no such limitations, merely that I don't know what they are.

                If you are regularly resorting to writing jBPM custom actions/decision/assignment handlers, then I need to know why that is and what feature it is that we are not providing for. This is the first time I have heard that from anyone!

                • 5. Re: Seam jBPM: use annotation or pages.xml to get next task?
                  gavin.king

                   

                  So: one cannot somehow use annotations or some configuration to specify what to do when a specific task is signaled by the actor, right? In other words: using annotations Seam can signal jBPM that a task is started or completed when some Java code is executed, but Seam has no means to tell what Java code needs to be triggered for some generic action.


                  I don't really understand what you're trying to say here (I have no clue what a "generic action" is), but I would have thought that this is completely provided for by being able to write:

                  <action expression="#{mycomponent.method}"/>


                  in your process definition. Note that jBPM supports all kind of s, not just transition events, and you can stick an on any of them.


                  • 6. Re: Seam jBPM: use annotation or pages.xml to get next task?
                    pmuir

                    The only issues I'm aware of are more JBPM than Seam

                    * JBPM could do with better/more EL interpretation - for example you can't do

                    <task description="This is an #{foo.bar}" />
                    as it only uses the EL interpreter if the string starts with #{

                    * Easier to put custom variables on a task (this is currently a pita, you have to declare custom taskinstances, assginment handlers)

                    I'll put them in JBPM's JIRA when i remember

                    In answer to the original question:

                    I worked around this by extending task instance, and adding a viewId property. Then, in the startTask action method, I just returned that viewId as the place to go.

                    • 7. Re: Seam jBPM: use annotation or pages.xml to get next task?
                      gavin.king

                       

                      I need to show an actor a list of all owned processes,


                      Define "owned". AFAIK, jBPM processes are not "owned" by an actor.

                      If you mean all processes for which the actor has an open task, you can write a query to do this using:

                      jbpmContext.getSession().createQuery(....)


                      If you guys think that this is important enough, I can easily add a built-in component that does this, but its the first time I've heard of someone wanting that, and since it is not a built-in feature of jBPM, I guess it is also not often wanted there...

                      In general, theres lots of different "lists of processes" that applications might want, so its best to write your own components for those (trivial, of course).

                      Clicking on a process instance and having that automatically associated with the conversation is possible using @ResumeProcess.

                      allowing the actor to click a button to get to the current task within that process


                      But there may be multiple tasks in a process! So this is not welldefined. You can get them all using:

                      processInstance.getTaskMgmtInstance().getTaskInstances()


                      Again, if you guys think it is important enough, I can add a "taskInstances" built-in component which gives you all the open tasks for the current process. But until now I did not know that this was so useful.


                      When clicking, a view that is applicable for that specific task will be shown, and this view might refer to some specific actions.


                      This part is trivial, right? Just like in the examples...

                      Alternatively just a list of the current tasks would do as well


                      Surely this alternative is better?? "owned processes" and "current task for a process" are not welldefined in jBPM, but "assigned tasks" is. This is what Seam is set up to support.

                      just as long as clicking the button allows me to show some task-specific view.


                      This is exactly what the examples do, right?


                      I don't really follow the rest of your post.

                      • 8. Re: Seam jBPM: use annotation or pages.xml to get next task?

                         

                        "gavin.king@jboss.com" wrote:
                        If you want the jBPM+Seam integration to improve, then you have to tell us exactly *what* limitations you are running into. I currently have only 9 open business process related issues in JIRA, most of which are definitely extremely minor, and only one of which came from a user (you).

                        In fact, apart from the well-known limitation with respect to jBPM timers and asynchronous events (which is slated for fixing in 1.3), I am not aware of *any* major limitation to the Seam jBPM integration.

                        I'm not claiming that there are no such limitations, merely that I don't know what they are.

                        If you are regularly resorting to writing jBPM custom actions/decision/assignment handlers, then I need to know why that is and what feature it is that we are not providing for. This is the first time I have heard that from anyone!


                        Go easy on me ;-) I just went through a lot of pain because of a deadline and our internal collective inexperience with JBoss. Seriously though - it may be that we didn't use jBPM as elegantly as we could have and I posted several questions here and in the jBPM forum. I also got stuck in a situation where some code I inherited, a jBPM ActionHandler, used Seam's ComponentgetInstance(...) to look up a SFSB and/or SLSB and invoke a method. In this case, we were regularly having issues with Seam trying to close managed resources - NO TRANSACTION exceptions. I couldn't find any decent documentation, examples, or discussions around such a use case. So it's not surprising if, as a user of Seam + jBPM, I don't have a glowing review.




                        • 9. Re: Seam jBPM: use annotation or pages.xml to get next task?

                           

                          our internal collective inexperience with JBoss


                          I mean

                          jBPM


                          • 10. Re: Seam jBPM: use annotation or pages.xml to get next task?
                            gavin.king

                            Oh, perhaps I understand now.

                            What you want is to navigate from a list of *all kinds of tasks*, to the specific page for the task, without using multiple tasks lists. Is that all?

                            Well, thats completely trivial:

                            @Name("taskSelector")
                            public class TaskSelector
                            {
                            
                             @In TaskInstance taskInstance;
                            
                             @StartTask
                             public String select()
                             {
                             return taskInstance.getName();
                             }
                            
                            }


                            Call it from:

                            <h:dataTable value="#{taskInstanceList}" var="task">
                             :
                             <h:column>
                             <s:button action="#{taskSelector.select}" taskInstance="#{task}" value="Go"/>
                             </h:column>
                            </h:dataTable>


                            And write navigation rules like:

                            <rule if-outcome="fooTaskName">
                             <redirect view-id="/foo.xhtml"/>
                            </rule>
                            <rule if-outcome="barTaskName">
                             <redirect view-id="/bar.xhtml"/>
                            </rule>


                            That's it!

                            If you want me to make TaskSelector a built-in component I can do it, but it's kinda trivial....

                            • 11. Re: Seam jBPM: use annotation or pages.xml to get next task?
                              gavin.king

                               

                              Easier to put custom variables on a task (this is currently a pita, you have to declare custom taskinstances, assginment handlers)


                              Pete, I don't understand this one.

                              • 12. Re: Seam jBPM: use annotation or pages.xml to get next task?
                                gavin.king

                                 

                                I also got stuck in a situation where some code I inherited, a jBPM ActionHandler, used Seam's ComponentgetInstance(...) to look up a SFSB and/or SLSB and invoke a method. In this case, we were regularly having issues with Seam trying to close managed resources - NO TRANSACTION exceptions.


                                Was this ActionHandler a Seam component? Again, I don't understand the scenario, nor why Seam was trying to close transactions that don't exist. Sounds very strange to me.

                                The issue that I do know of is this one:

                                http://jira.jboss.org/jira/browse/JBSEAM-798

                                And that is, clearly, a bug in Seam's jBPM integration, and one I plan to fix when I get time. There is a workaround, so it doesn't seem like any kind of blocker...

                                • 13. Re: Seam jBPM: use annotation or pages.xml to get next task?

                                  Gavin, you type a lot faster than I do :-) I was ready to respond to your posts two times now, but each time you already replied again before I hit submit. Thanks!

                                  "gavin.king@jboss.com" wrote:
                                  What you want is to navigate from a list of *all kinds of tasks*, to the specific page for the task, without using multiple tasks lists. Is that all?

                                  ...yes, "that's all"!

                                  And your solution, though you think trivial, is great, clean, and exactly what I need! And you're right: no need for a built-in component I guess.

                                  Thanks again!
                                  Arjan.


                                  • 14. Re: Seam jBPM: use annotation or pages.xml to get next task?


                                    Was this ActionHandler a Seam component? Again, I don't understand the scenario, nor why Seam was trying to close transactions that don't exist. Sounds very strange to me.


                                    No, it's not a Seam component (no @Name(...)) annotation - does that work? I mean if I put @Name on my custom ActionHandlers, DecisionHandlers, will Seam inject resources into them on invokation of the execute(ExecutionContext executionContext) methods?

                                    Thanks



                                    1 2 3 4 Previous Next