问题
I'm using a in-cell editable datatable in PF 3.4 with Mojarra/Tomcat 7.0.29.
My problem is that I'm applying a validation on the inputtext which works great. The only issue I have is that after the validation fails, the cell is marked as red. Even if I close (i.e. click the cancel button) the editable-mode, it remains red next time I try to enter edit-mode. I need to have the red highlighting removed after I close the editable mode.
Its mostly a cosmetic issue as everything is working fine.
Any ideas?
So far, I've tried setValid(true)
on the component in my validator but it does not seem to help much.
回答1:
The component what you need is ResetInput.
Input components keep their local values at state when validation fails. ResetInput is used to clear the cached values from state so that components retrieve their values from the backing bean model instead.
Attach the reset input component to an action to reset another component state
<p:commandButton ....>
<p:resetInput target="input1" />
</p:commandButton>
An alternative solution would be using ResetInput from PrimeFaces Extensions which also support the event
attribute. By this way you can directly connect your rowEditCancel
with the resetInput
like this:
<p:ajax event="rowEditCancel"/>
<pe:resetInput event="rowEditCancel" for="input1"/>
来源:https://stackoverflow.com/questions/13045803/primefaces-3-4-in-cell-editable-table-marks-inputtext-cell-as-red-after-failed-v