0

I try understand how JSF UIData () works programaticaly in JSF. I have following code:

    UIInput input = new UIInput();
    UIInput input2 = new UIInput();

    UIOutput header = new UIOutput();
    header.setValue("Header");

    UIColumn column = new UIColumn();
    column.setHeader(header);
    column.getChildren().add(input);
    column.getChildren().add(input2);

    UIData table = new UIData();
    table.getChildren().add(column);

this code render html like:

 <table>
   <thead>
     <tr>
       <th scope="col">Header</th>
     </tr>
   </thead>
   <tbody>
      <tr>
         <td></td>
     </tr>
   </tbody>
 </table>

where is my two inputs?? i expect something like:

  .....
   <tbody>
      <tr>
         <td>
            <input type="text" />
         </td>
     </tr>
      <tr>
         <td>
            <input type="text" />
         </td>
     </tr>
   </tbody>
   ......
Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139
Michał Ziembiński
  • 1,124
  • 2
  • 10
  • 31
  • i also try switch UIComponents (UIData,UIInput, UIColumn) to HtmlComponenets (HtmlDataTable, HtmlInputText, HtmlColumn) but still same result. empty row. – Michał Ziembiński Mar 11 '15 at 19:41
  • You would have exactly the same problem when declaring/creating components using XHTML (XML) instead of Java. There's **nothing** which is only possible in Java and not in XHTML as to declaring/creating components. XHTML has the major advantage that the code is so much more readable and easier to maintain. Just my 2 cents so that you can think twice if you would really continue in this direction. – BalusC Mar 12 '15 at 13:35

1 Answers1

0

i know what i do wrong. I have to set a collection of UIData for rows of table. When i set

    UIData table = new UIData();
    ArrayList list = new ArrayList();
    list.add("A");
    list.add("B");
    table.setValue(list);

than i get two rows with my inputs

Michał Ziembiński
  • 1,124
  • 2
  • 10
  • 31