1

Problem Description

I use a workflow engine with a self-built JSF UI. Some processes in the engine use so called User tasks. These tasks are presented in my JSF frontend and contain small or medium-sized forms, which have to be filled by the user. The workflow frontend should be fully generic - it shouldn't know which tasks or which type of tasks are handled. Therefore, I want to define these task forms not within the JSF app. The forms should "live" along the related process, thus in the workflow engine. That's important because otherwise the frontend app has to be redeployed everytime changes are applied to any minor form.
So I want to fetch the form (basically a .xhtml file) from the engine and add it to the app as a simple JSF view. If a user wants to complete a task, the corresponding JSF form should be pulled and rendered.

I would like to integrate JSF components (or a whole view) into my application at runtime, thus fully unknown at build or startup-time.

How can I achieve this? Is this even possible?

Thanks in advance!

fnst
  • 5,574
  • 4
  • 23
  • 18
  • don't you want to wrap those two elements with `.....` and `render` it with ` – Daniel Apr 09 '13 at 07:35
  • @Daniel Maybe it's not clearly described in my question. I don't want render components conditionally. I would like add JSF elements at runtime, thus fully unknown at compile or startup time. The both elements are just an example. – fnst Apr 09 '13 at 08:01
  • 1
    @fnst Sometimes, the best generic questions are specific. Maybe if you showed us UI prototypes for your specific problem, then we could give you ideas on how to do that using JSF. – Elias Dorneles Apr 09 '13 at 11:52
  • @fnst start [here](http://balusc.blogspot.com.ar/2006/06/using-datatables.html#PopulateDatatable) – kolossus Apr 09 '13 at 12:47
  • @elias I rewrote the problem description added some background information. It's difficult to show code samples, because it is, in fact, a generic problem. I don't want to add a specific component - it could, given that it's possible, every JSF component. Thanks for the hint! – fnst Apr 10 '13 at 08:23

1 Answers1

2

As to JSF components, you can definitely create them programmatically. This is answered here: How to create dynamic JSF form fields. Note that the concept is not different for JSF 2.x. Only the timing is; you need to run it during view build time. A <f:event type="postAddToView"> on a parent is the ideal hook. Alternatively, do it lazily in getter of parent's binding attribute, however this breaks the view scope and the bean definitely needs to be request scoped.

As to JSF views, you need to create a custom ResourceResolver. Concrete examples can be found in those answers, with among others Obtaining Facelets templates/files from an external filesystem or database

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555