简体   繁体   English

如何使用Ajax a4j重新渲染panelGroup:支持

[英]How to reRender panelGroup with Ajax a4j:support

Let me start by saying I am obviously very new to ajax / jsf so please excuse me. 首先,我要说我显然对ajax / jsf非常陌生,所以请原谅。 First I have been reading some of the richFaces docs, and am still not clear on the difference is between 'render' and 'reRender'. 首先,我已经阅读了一些richFaces文档,但仍不清楚“ render”和“ reRender”之间的区别。

What I am trying to achieve is a page with two "areas" that are hidden/ not rendered by default. 我想要实现的是一个页面,其中包含两个默认隐藏/未渲染的“区域”。 When the user selects a <h:selectBooleanCheckbox> this would trigger the rendering of the "area" that corresponds to this BooleanCheckbox. 当用户选择<h:selectBooleanCheckbox>将触发与该BooleanCheckbox对应的“区域”的呈现。 This seems to be far more work then it should be and maybe I am missing something very elementary. 这似乎要比应该做的工作多得多,也许我缺少一些非常基本的东西。

Here is my Code. 这是我的代码。

<h:outputLabel for="saveNote" value="Create Note "/>            
<h:selectBooleanCheckbox id="saveNote" value="#{noteController.saveNote}" immediate="true" >            
    <a4j:support event="onchange" reRender="noteArea"/>                         
</h:selectBooleanCheckbox>
<h:outputLabel for="sendEmail" value="Send Email "/>    
<h:selectBooleanCheckbox id="sendEmail" value="#{noteController.sendEmail}" immediate="true">
    <a4j:support event="onchange" reRender="emailArea"/>                                                        
</h:selectBooleanCheckbox>

This is nested inside an <h:form> 它嵌套在<h:form>

The "area" I am trying to control the rendering of is as follows... 我正在尝试控制渲染的“区域”如下...

<h:panelGroup id="noteArea" rendered="#{noteController.saveNote}" layout="block"> 

This is also nested inside the same h:form as the <h:selectBooleanCheckbox> 这也嵌套在与<h:selectBooleanCheckbox>相同的h:form中。

Please help, ajax is starting drive me nuts! 请帮助,ajax开始让我发疯!

Thanks so much in advance!!!! 提前非常感谢!!!!

The reRender attribute will a number of client ids to render upon postback. reRender属性将提供许多客户端ID,以在回发时呈现。 This is supposed to be the client id, not the server id of noteArea . 应该是客户端ID,而不是noteArea的服务器ID。

Unless in your h:form element if you have specified prependId to be false, the form id will be preceding the panelGroup id in your form to make your unique client id. 除非在h:form元素prependId指定为false, prependId ,表单ID将在表单中的panelGroup id之前,以使您的客户ID唯一。

form1:noteArea

Also I don't think you want to set immediate to true on the checkboxes. 另外,我不希望您将复选框的“ immediate设置为true。

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

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