JSF + Primefaces: Problem with “rendered” components with ajax
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 insidebean
.setRenderComment
basically toggle the state ofrenderComment
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的更多相关文章
- JSF primefaces dataTable paginator 表格分页 问题
当第一次查询返回list列表,分页1,2,3.....这是选择2,当前页面停留在第2页. 当再次查询后,因为使用的ajax,结果更新了,但当前页面依旧是第2页. 可以在jsf页面,datatable的 ...
- JSF primefaces session view expired 会话失效后页面跳转
web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=" ...
- jsf primefaces note
对应cdi,inject的变量,必须使用getter才能访问的值. @Inject DateView dateView; dateView.getFromDate1() 这样是娶不到的: dateVi ...
- Lazy JSF Primefaces Datatable Pagination
http://www.javacodegeeks.com/2012/04/lazy-jsf-primefaces-datatable.html
- JSF中使用f:ajax标签无刷新页面改变数据
ajax本是用在前端的一种异步请求数据的操作,广泛用于js中,一般的js框架如jq都有被封装好的方法,用于发起异步请求操作.异步操作可以增强用户体验和操作,越来越多的程序都在使用ajax.JSF的fa ...
- 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 ...
- Tutorial: Build a Spring WebMVC App with Primefaces
Tutorial: Build a Spring WebMVC App with Primefaces by Team Stormpath | September 7, 2016 | Java Pri ...
- MSCRM 通过Ajax调用WCF服务
Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...
- Ajax.BeginForm 在 Chrome下的问题
项目背景:MVC4 代码: @using (Ajax.BeginForm("Index", "GoingMeter", new AjaxOptions { On ...
随机推荐
- fib博弈
链接:https://www.nowcoder.com/acm/contest/77/G来源:牛客网 幼儿园开学了,为了让小盆友们能尽可能的多的享受假期.校长大人决定让小盆友分批到校,至于每批学生来 ...
- html中元素盒子垂直居中的实现方法
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- IE8下的typeof(console.log)为"object"的BUG
今天发现IE8在开启过控制台后,console.log虽然可用,也是确实是一个函数,但是对其执行typeof操作返回的确是"object" 原生IE8:
- 16款最受关注的智能手表 苹果iWatch领衔
智能手表逐渐成为科技行业的新宠,而传闻中的苹果iWatch以及已经确认即将推出的三星Galaxy Gear,显然让这股热潮达到了顶峰,也预示着大牌厂商将逐渐进入该领域,推出更多成熟的产品.以下便是16 ...
- Beta阶段第1周/共2周 Scrum立会报告+燃尽图 03
作业要求与 [https://edu.cnblogs.com/campus/nenu/2018fall/homework/2284] 相同 版本控制:https://git.coding.net/li ...
- PHPExcel解决内存占用过大问题-设置单元格对象缓存
PHPExcel解决内存占用过大问题-设置单元格对象缓存 PHPExcel是一个很强大的处理Excel的PHP开源类,但是很大的一个问题就是它占用内存太大,从1.7.3开始,它支持设置cell的缓存方 ...
- C# 后台线程更新UI控件
/********************************************************************************* * C# 后台线程更新UI控件 * ...
- java面试题11
第九次面试题 1. GC是什么?为什么要有GC? GC是垃圾收集的意思(Gabage Collection),内存处理是编程人员容易出现问题的地方,忘记或者错误的内存回收会导致程序或系统的不稳定甚至崩 ...
- 490 - Rotating Sentences
Rotating Sentences In ``Rotating Sentences,'' you are asked to rotate a series of input sentences ...
- pandas dataframe 读取 xlsx 文件
refer to: https://medium.com/@kasiarachuta/reading-and-writingexcel-files-in-python-pandas-8f0da449c ...