Primefaces 3.4 in-cell editable table marks inputtext-cell as red after failed validation

坚强是说给别人听的谎言 提交于 2019-12-25 05:25:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!