jozeph
jozeph

Reputation: 1

JSF: inputText with converter in dataTable Problem

I build a h:inputText for a cell in h:dataTable with customized converter. The input text can be converted and the converted text can be displayed if I rerender the whole table.

The problem is, the reredering of the whole table will release the focus of next input box. I try to explain it clearly.

The problem that I have:

  1. User input data in a table cell.
  2. User press tab key and jump to next input box in the table.
  3. Meanwhile the just inputed text will be converted and displayed immediately.
  4. But user lost the focus of the next input box because of the rerendering of whole table.

What I want is:

  1. User input data in a table cell.
  2. User press tab key and jump to next input box in the table.
  3. Meanwhile the just inputed text should be converted and displayed immediately.
  4. User should not lose the focus of the next input box (maybe use a partial rerendering).

I also try to assign id to every single cell for the partial rerendering, but I don't know how to do this in dataTable.

Anyone has any solution to solve the problem? Thanks.

Upvotes: 0

Views: 1106

Answers (2)

Matt Handy
Matt Handy

Reputation: 30025

Try this:

<h:inputText value="#{item.value}">
  <f:ajax event="blur" render="@this" execute="@this"/>
</h:inputText>

The execute attribute should trigger the converter. You do not need a separate outputText this way.

Upvotes: 0

BalusC
BalusC

Reputation: 1108742

Just refer the id of the output component in render attribute of f:ajax.

<h:dataTable value="#{bean.model}" var="item">
    <h:column>
        <h:inputText value="#{item.value}">
            <f:ajax event="blur" render="output" />
        </h:inputText>
    </h:column>
    <h:column>
        <h:outputText id="output" value="#{item.value}" />
    </h:column>
</h:dataTable>

Upvotes: 1

Related Questions