简体   繁体   English

RichFaces:使用a4j:support消失了JSF消息

[英]RichFaces: JSF Message disappears using a4j:support

I am unsing JSF 1.2 with the richfaces implementation. 我将通过richfaces实现取消JSF 1.2的使用。 What I am trying to do is to enable a selectOneRadio when a selectBooleanCheckbox is checked. 我正在尝试做的是在选中selectBooleanCheckbox时启用selectOneRadio。 It works so far. 到目前为止,它仍然有效。 But there is a strange effect: 但是有一个奇怪的效果:

Consider following situation: Field selectA shows an error-Message in its rich:message tag. 考虑以下情况:字段selectA在rich:message标签中显示一条错误消息。 After checking myCheckbox selectOneRadio selectToReRender is enabled but the error message in all rich-message tags on the page disappear. 选中myCheckbox后,启用了selectOneRadio selectToReRender,但是页面上所有富消息标记中的错误消息都消失了。

Thanks for your Help. 谢谢你的帮助。

Regards, 问候,

Max 最高

<!-- Field which shows error-Message if vlaue was not entered -->
<h:selectOneRadio id="selectA" 
                  value ="#{controller.entity.valueA}"
                  required="true"
                  label="#{text['selectA.label']}"
                  layout="pageDirection">
    <f:selectItem itemValue="#{true}" itemLabel="Yes" />
    <f:selectItem itemValue="#{false}" itemLabel="No"/>
</h:selectOneRadio>

<rich:message for="selectA"/>



<!-- Field which enables selectOneRadio selectToReRender if it is checked -->
<h:selectBooleanCheckbox id="myCheckbox" 
                         label="#{text['myCheckbox.label']}"
                         value="#{controller.entity.valueB}" 
                         required="false">
    <a4j:support event="onclick" ajaxSingle="true" reRender="selectToReRender"/>
</h:selectBooleanCheckbox>
<rich:message for="myCheckbox"/>

<!-- Field which is disabled until myCheckbox is checked. 
     Function getSelectToReRenderDisabled() of controller checks the boolean value of controller.entity.valueB -->
<h:selectOneRadio id="selectToReRender"
                  value="#{controller.entity.valueC}"
                  label="#{text['selectToReRender.label']}"
                  layout="pageDirection"
                  required="true"
                  disabled="#{controller.selectToReRenderDisabled}">
    <f:selectItems value="#{MySelectItems.myEntitySelectItems}"
                   var="" />
</h:selectOneRadio>
<rich:message for="selectToReRender"/>

The manual says, that the component rich:message supports "auto rerendering after Ajax request without help of <a4j:outputPanel> ". 该手册说,组件rich:message支持“在Ajax请求后无需<a4j:outputPanel>帮助下自动重新呈现”。 So this component is rerendered automatically within every AJAX-request. 因此,此组件会在每个AJAX请求中自动重新呈现。 In the list of attributes you can see, that ajaxRendered has it's default value set to true . 在属性列表中,您可以看到ajaxRendered的默认值设置为true

So you could try to set it to false but then you have to be aware that it has to be rerendered manually during concerned AJAX-requests (eg if your selectA has AJAX-support). 因此,您可以尝试将其设置为false但是随后您必须知道,在相关的AJAX请求期间(例如,如果selectA具有AJAX支持)必须手动selectA它。

ajaxSingle="true" in the <a4j:support/> for myCheckbox means that when that box is checked, only myCheckbox is submitted for processing (sort of) and validation. <a4j:support/>myCheckbox ajaxSingle="true"表示选中该复选框时,仅myCheckbox提交进行处理(排序)和验证。 As a result, all other components within that form and any associated validation errors and messages are ignored during processing of that request. 结果,在处理该请求期间,将忽略该表单中的所有其他组件以及任何关联的验证错误和消息。

To ensure that the entire form is submitted and validated when myCheckBox is selected, set ajaxSingle="false" or remove it altogether 为了确保整个表单提交,并且当验证myCheckBox被选择时,设定ajaxSingle="false"或完全删除它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM