Domanda

<rich:column sortBy="#{entity.double_amt}" filterBy="#{entity.double_amt}" >
    <h:inputText value="#{entity.double_amt}">
    <a4j:support event="onchange" reRender="entityTable" ajaxSingle="true" />
</rich:column>

I have a column inside a rich:dataTable, where user will be able to input Amount and filter/sort.

If user haven't inputted double_amt, it will be blank.
However, if I don't input anything, and click on the column header to sort the table (or type anything for filter), double_amt will be defaulted with 0.0. Worse, if I have multiple records on this table, one random double_amt from another row is inserted in the empty row (instead of 0.0).

When I click on the column header, setDouble_amt(Double double_amt) is called, and double_amt here is 0.0, or the value from another record.

Am I missing anything here? Please help.

È stato utile?

Soluzione 2

It seems to be similar to this problem described here:

JSF - UIInput component with no input sets String Property to empty string

In my problem, however, I need to know if user has inputted 0.0 or haven't input anything at all. Either way, the setter is passed 0.0.

I manage to solve the problem by changing the getter/setter to String (getDoubleAmt() and setDoubleAmt(String doubleAmt)), and check for empty String inputted as in the link provided. If it is not empty, I will parse the double to the original field (double_amt).

Hope this helps someone facing the same problem.

Altri suggerimenti

I would start setting the "id" property in all of the elements (specially in a4j:support, I do not think that this solves your problem, but I had bad experiences wit this in the past).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top