Cant seem to get rendered to work correctly with update attributes. Here is my codes

        <ui:define name="left">
<h:form>
<p:commandLink value="Hey"
actionListener="#{bean.setRenderComment}"
update="comment"/>
</h:form>
</ui:define>
<ui:define name="right">
<h:panelGroup id="comment" rendered="#{bean.renderComment}">
hello
</h:panelGroup>
</ui:define>
renderComment is a boolean attributes inside bean. setRenderComment basically toggle the state of renderComment like this
this.renderComment =!this.renderComment;

Right, every time I click on the link Hey, I need to refresh to either render hello on or off. How can I fix it, so that I dont need to refresh.

solution:

am not using Primefaces but Richfaces on my projects. So I am not really aware on how the refresh process is done by Primefaces. However, I have an idea that can be tested easily.

Your problem may be due to the fact that the component to re-render (i.e. update) is not found on the HTML page. If your rendered attribute is equals to false, then the <SPAN> with comment id is not integrated in the HTML page generated. Thus, when the Ajax request is received on the client side, the Ajax engine is not able to refresh this <SPAN> as it is not found.

So what you can do is to always render your panelGroup and move your rendered attribute to a nested <h:outputText> that contains the Hello message.

Here is what I am suggesting:

<h:panelGroup id="comment"><h:outputText value="Hello" rendered="#{bean.renderComment}"/></h:panelGroup>

This way, the panelGroup will always be refreshed after the Ajax call, and it will contain the Hello message or not, regarding the value of the renderComment attribute of your bean.

JSF + Primefaces: Problem with “rendered” components with ajax的更多相关文章

  1. JSF primefaces dataTable paginator 表格分页 问题

    当第一次查询返回list列表,分页1,2,3.....这是选择2,当前页面停留在第2页. 当再次查询后,因为使用的ajax,结果更新了,但当前页面依旧是第2页. 可以在jsf页面,datatable的 ...

  2. JSF primefaces session view expired 会话失效后页面跳转

    web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=" ...

  3. jsf primefaces note

    对应cdi,inject的变量,必须使用getter才能访问的值. @Inject DateView dateView; dateView.getFromDate1() 这样是娶不到的: dateVi ...

  4. Lazy JSF Primefaces Datatable Pagination

    http://www.javacodegeeks.com/2012/04/lazy-jsf-primefaces-datatable.html

  5. JSF中使用f:ajax标签无刷新页面改变数据

    ajax本是用在前端的一种异步请求数据的操作,广泛用于js中,一般的js框架如jq都有被封装好的方法,用于发起异步请求操作.异步操作可以增强用户体验和操作,越来越多的程序都在使用ajax.JSF的fa ...

  6. commandLink/commandButton/ajax backing bean action/listener method not invoked (转)

    Whenever an UICommand component fails to invoke the associated action method or an UIInputelement fa ...

  7. Tutorial: Build a Spring WebMVC App with Primefaces

    Tutorial: Build a Spring WebMVC App with Primefaces by Team Stormpath | September 7, 2016 | Java Pri ...

  8. MSCRM 通过Ajax调用WCF服务

    Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...

  9. Ajax.BeginForm 在 Chrome下的问题

    项目背景:MVC4 代码: @using (Ajax.BeginForm("Index", "GoingMeter", new AjaxOptions { On ...

随机推荐

  1. lvs+keepalived+bind实现负载均衡高可用智能dns【转】

    转:https://www.cnblogs.com/mikeluwen/p/7068356.html 整体架构: 1.IP地址规划: Dns1:172.28.0.54 Dns2:172.28.0.55 ...

  2. 解决MySQL workbench的Can't connect to MySQL server on '127.0.0.1'(10061)问题

    如题,今天打开MySQL时,出现了这种问题,无法连接到数据库 问题原因:The error (2003) Can't connect to MySQL server on 'server' (1006 ...

  3. DTD文档说明

    模块说明 l  元素 l  属性 l  实体 l  PCDATA(parsed character data) PCDATA 是会被解析器解析的文本.这些文本将被解析器检查实体以及标记. l  CDA ...

  4. Scrum冲刺博客(总)

    一.在 Alpha 阶段认领的任务 二.明日任务安排 成员 任务 任务量/小时 陈伟泽 项目进度把控 1 李嘉廉 24点算法" Stack数据结构实现,生成不重复的算式(考虑结合律和结合律) ...

  5. python 读写三菱PLC数据,使用以太网读写Q系列,L系列,Fx系列的PLC数据

    本文将使用一个gitHub开源的组件技术来读写三菱的plc数据,使用的是基于以太网的TCP/IP实现,不需要额外的组件,读取操作只要放到后台线程就不会卡死线程,本组件支持超级方便的高性能读写操作 gi ...

  6. Vitya in the Countryside

    Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge war ...

  7. 《FDTD electromagnetic field using MATLAB 》读书笔记001-差商种类

    有限差分就是用差商代替微商,有3钟: 1.向前差商 2.向后差商 3.中心差商 上面三张途中虚线就是函数在x的精确微商(偏导数),直线就是用来代替精确 微商的差商格式.

  8. [UOJ300][CTSC2017]吉夫特

    uoj bzoj luogu sol 根据\(Lucas\)定理,\(\binom nm \mod 2=\binom{n\%2}{m\%2}\times\binom{n/2}{m/2}\mod 2\) ...

  9. 【java多线程】java的内存模型

    Java内存模型 下面是我从百度上引入的一张具有代表性的图 ①解释:我根据这张图来解释java内存模型,从图中可以看出每个线程都需要从主内存中读取操作,这个就是java内存模型的规定之一,所有的变量存 ...

  10. 使用jsonschema2pojo-maven-plugin 插件根据json文件生成代码

    jsonschema2pojo 是一个不错的工具,可以帮助我们快速的根据json 文件生成pojo代码,提高开发效率,以下为简单的 使用maven 插件进行代码生成 使用maven 插件配置 < ...