1

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
TaherT
  • 1,285
  • 2
  • 22
  • 41
  • possible duplicate of [How to create dynamic JSF 1.2 form fields](http://stackoverflow.com/questions/3510614/how-to-create-dynamic-jsf-1-2-form-fields) – BalusC Sep 09 '10 at 09:46
  • Hi BalusC actually i had a h:inputtext in which i feed a no.(Ex:8) and click generate button and I had to generate 8 columns in h:datatable ...so please give solution – TaherT Sep 09 '10 at 11:18

2 Answers2

0

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
  • 25,281
  • 6
  • 70
  • 74
0

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
  • 11,444
  • 4
  • 50
  • 73