0

I am following the option suggested here to dynamically adding inputtext box in my PrimeFaces v3.5 application. The only problem I am facing is that the newly added inputtext are growing vertically. Screenshot is attached.enter image description here

Community
  • 1
  • 1
ravi
  • 6,140
  • 18
  • 77
  • 154

1 Answers1

2

The <h:dataTable> generates a HTML <table> element wherein each iteration generates a <tr> element which represents naturally a new row.

If you don't want to generate a table at all, then you should not be using a <h:dataTable>, but e.g. <ui:repeat>.

<h:form>
    <ui:repeat value="#{bean.items}" var="item">
        <h:inputText value="#{item.value}" />
    </ui:repeat>
    <h:commandButton value="add" action="#{bean.add}" />
    <h:commandButton value="submit" action="#{bean.submit}" />
</h:form>

This doesn't generate any markup and the HTML <input> elements will by default end up in a single line.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Just one more query. I am using `` I don't wanna update entire form so i am trying to update only `` part. but thats not happening. Any hack for this? – ravi Apr 02 '13 at 13:47
  • 1
    As answered, the `` doesn't generate any markup. Logically, wrap it in a component which generates something to HTML so that it's accessible/updateable by JavaScript/Ajax. A panel group with an `id`, for example? – BalusC Apr 02 '13 at 13:49