Is it possible to implement a dynamic component tree in JSF?

I am trying to build a component tree in JSF 1.2 (Mojarra), where the tree consists of several types of transition nodes and leaf. Each node leaf should be displayed in a unique way and should be sent back with potential changes. The goal is to allow the user to update processing logic, where each leaf node represents an operation, such as "value is equal" or "value is not equal."

For instance:

Root | +- InternalNode1 (type I_A) | | | +- LeafNode1 (type L_A) | | | +- LeafNode2 (type L_B) | +- InternalNode2 (type I_B) | +- LeafNode3 (type L_B) | +- LeafNode4 (type L_A) 

Each node leaf type must be rendered differently, depending on the needs of this node type. In addition, the tree will be modified, and nodes can be added or removed using Javascript and updates sent back to the server, etc. For example, in the above tree, LeafNode4 can be deleted or its type has changed to L_B.

Is this possible with JSF components? Am I mistaken when trying to use polymorphic user interface components?

+4
source share
2 answers

You can create a component tree programmatically, but this will be the wrong approach for your use case. It would usually be unsafe to allow a user agent to manipulate such server code.

It would be better to use a model to control your tree structure (essentially the approach suggested by don Rob ). The data that makes up this model can then be checked, like any other user input, to ensure that attackers are not trying to put server data in an invalid state.

The JSF declarative approach makes it difficult to do this out of the box (you can see the tree rendering example here .) If you don't want to drag and drop in a third-party library (or write your own control) you might be better off processing the entire tree user interface in JavaScript and using JSF hidden field for transferring it to / from the server.

+1
source

You can see <rich:tree> .

+2
source

All Articles