为什么不跳过转换?
我的页面上有两个输入组件。它们每个都有一个转换器(这是一个检查空值的转换器,就像 JSF 需要的那样,但由于某些原因我不能使用 jsf 转换器,所以我制作了自己的转换器)。
我还有一个 ice:selectBooleanCheckbox
:
<ice:selectBooleanCheckbox
styleClass="graUserAppUserGroupAddChk"
value="#{userGroupTableNewRecordBean.addNewDomain}"
partialSubmit="true"
immediate="true"
valueChangeListener="#{userGroupTableNewRecordBean.addDomainListener}"></ice:selectBooleanCheckbox>
如您所见,我在其上放置了 immediate=true
属性,因为当我选择此复选框时,我确实希望转换阶段被跳过但不起作用,转换器仍然显示警告。你知道为什么吗?
我还在这个复选框上添加了一个 valueChangeListener 并根据以下引用直接调用 renderResponse:
因此,在下拉列表的值更改侦听器方法中,只需
从以下位置调用 renderResponse() FacesContext 对象和验证以及 转换被绕过,你可以 还是做自己想做的事吧。
public void addDomainListener(final ValueChangeEvent valueChangeEvent) {
// skip validation
logger.info("listener calleddddddddddddd");
FacesContext.getCurrentInstance().renderResponse();
}
也许 JSF 大师可以提供帮助?
非常感谢...
更新:我知道解决方案是将复选框放在单独的表单中,但我负担不起...
更新2:我'已经更正了一些有关侦听器的代码,因此现在单击时会调用它,但转换器仍然失败并且渲染响应阶段未完成...
更新 3:这不是一个冰面问题...我尝试过h:selectBooleanCheckbox
并且它发生同样的事情......
I have two input components on my page. Each of them has a converter (It's a converter which checks for empty values, like JSF required one, but for some reasons I cannot use jsf one so I've made my own converter).
I also have a ice:selectBooleanCheckbox
:
<ice:selectBooleanCheckbox
styleClass="graUserAppUserGroupAddChk"
value="#{userGroupTableNewRecordBean.addNewDomain}"
partialSubmit="true"
immediate="true"
valueChangeListener="#{userGroupTableNewRecordBean.addDomainListener}"></ice:selectBooleanCheckbox>
As you see I put immediate=true
attribute on it, becase when I select this checkbox I do want the conversion phase to be skipped but it does not work, the converters still show their warnings. Do you know why?
I also add a valueChangeListener on this checkbox and called there the renderResponse directly, based on this quote:
So in the value changed listener method for the dropdown lists, just
call renderResponse() from the
FacesContext object and validation and
conversion is bypassed and you can
still do what you want.
public void addDomainListener(final ValueChangeEvent valueChangeEvent) {
// skip validation
logger.info("listener calleddddddddddddd");
FacesContext.getCurrentInstance().renderResponse();
}
Maybe a JSF guru can help?
Thanks a lot...
UPDATE: I know that a solution would be to put the checkbox in a separate form but I cannot afford this...
UPDATE 2: I've corrected some code about listener, so now it is called when clicked but still the converter fails and render response phase is not done...
UPDATE 3: This is not an icefaces issue... I've tried with a h:selectBooleanCheckbox
and it happens the same...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
整个问题和这一切背后的功能需求非常令人困惑。为什么使用转换器而不是验证器来验证输入?如果您似乎不关心转换/验证结果,为什么要使用转换器/验证器?
输入组件上的 code>immediate="true" 不会跳过转换/验证。他们只是将转换/验证转移到较早的阶段(即,它发生在应用请求值阶段而不是验证阶段)。您基本上需要从这些输入中删除
immediate="true"
并将其放在命令链接/按钮上,以便跳过这些输入的转换/验证。另请参阅调试 JSF 生命周期:The whole question and the functional requirement behind this all is pretty confusing. Why are you using a converter instead of a validator to validate the inputs? Why are you using a converter/validator if you don't seem to care about the conversion/validation outcome?
Putting the
immediate="true"
on input components does not skip conversion/validation. They just shifts conversion/validation to an earlier phase (i.e. it takes place in apply request values phase instead of validations phase). You basically need to removeimmediate="true"
from those inputs and put it on the command link/button in order to skip conversion/validation of those inputs. See also Debug JSF lifecycle:终于解决了......
我在这里发布问题和解决方案的总结。
我的弹出窗口中有一个复选框。当我选择它时,我想显示一些隐藏字段,但这不起作用,因为我在同一页面上还有两个必填字段,所以jsf PROCESS_VALIDATIONS 阶段出现了...
我认为放置
immediate=true
可以解决这个问题,但事实并非如此...因此,在复选框的 ValueChangeListener 中,我必须手动跳过
Solved it finally...
I post here the sum up of the question and the solution.
I had a checkbox in my popup. When I select it I want to show some hidden fields but this did not work because I also had two required fields on the same page so jsf PROCESS_VALIDATIONS phase came up...
I thought that putting
immediate=true
will solve this, but it did not...So, in my ValueChangeListener of the checkbox I had to manually skip the jsf validation phase: