views:

62

answers:

2

how can I dynamically create html components in Jsf2. I have to make a dynamic form which is to be filled by user, so I am not getting how can I manage, I have to use JavaScript or what?? I am using richfaces too.

A: 

yes. use javascript. one way using js could be to have the various 'dynamic' html elements already on the page, but set to hidden via CSS: display:none;

when an element triggers a hidden element to be show, use js: document.getElementById('xyz').style.display = 'block';

Moin Zaman
this can't be used in my case suggest another one..
taher
A: 

Here, you can use panelGrid component, specify no of columns dynamically. You can then add other stuff into the panelGrid.

Page Code:

<ice:inputText value="#{bean.noOfColumns}"

<ice:panelGrid columns="#{bean.noOfColumns}" binding="#{bean.gridComponent}">

Backing Bean Code :

//---

for(int i=0; i < noOfColumns; i++)
     gridComponent.getChildren().add(uiComponent);

//---

You can add any uiComponent accordingly.

Nayan Wadekar
I am usig richfaces brother..... ;)
taher
Then you can use <h:panelGrid> as it is core JSF component, if it fits well according to your need.
Nayan Wadekar