Tarun Sapra
Tarun Sapra

Reputation: 1901

Textbox as JSF data table Header

All example of h:datatable on the internet contain simple text as part of table header

example

<h:column>
<f:facet name="header">
<h:outputText value="name"/>
</f:facet> 
<h:outputText value="#{item.name}"></h:outputText>
</h:column>

But I want something like this -

<h:column>
<f:facet name="header">
<input type="text" id="column1">
</f:facet> 
<h:outputText value="#{item.name}"></h:outputText>
</h:column>

It's not rendering the column1 text-box as part of table header instead it's making this text-box part of loop only.

Please suggest.

Upvotes: 1

Views: 1085

Answers (2)

DRCB
DRCB

Reputation: 2121

I do not quite understand your problem with header. Does it get rendered at all?

By the way, <f:facet> must contain one JSF element inside (not a sequence). To make sure that the raw HTML will be interpreted correctly - use any grouping element as 'root' for your facet content. For example <h:panelGroup>:

<f:facet name="header">
    <h:panelGroup>
        <input type="text" id="column1"/>
    </h:panelGroup>
</f:facet> 

Upvotes: 1

Ventsislav Marinov
Ventsislav Marinov

Reputation: 604

Like this way I haven't got any problems. Try:

<h:column>
    <f:facet name="header">
        <h:inputText id="column1"/>
    </f:facet> 
    <h:outputText value="#{item.name}"></h:outputText>
</h:column>

Upvotes: 3

Related Questions