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>
renderCommentis a boolean attributes insidebean.setRenderCommentbasically toggle the state ofrenderCommentlike 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 ...
随机推荐
- 牛客网——C列一列
链接:https://www.nowcoder.net/acm/contest/71/C来源:牛客网 题目描述 小W在计算一个数列{An},其中A1=1,A2=2,An+2=An+1+An.尽管他计算 ...
- IOS UI-QQ好友列表
一.Model // // FriendsModel.h // IOS_0111_好友列表 // // Created by ma c on 16/1/11. // Copyright (c) 201 ...
- Python 编程核心知识体系-基础|数据类型|控制流(一)
Python知识体系思维导图: 基础知识 数据类型 1.序列 2.字符串 3.列表和元组 4.字典和集合 循环 & 判断
- 在ASP.NET中将GridView数据导出到Word、Excel
在ASP.NET中将GridView数据导出到Word.Excel asp.net,导出gridview数据到Word,Excel,PDF #region Export to Word, Exce ...
- .net 应用程序 发布上线注意事项
生产环境发布时,对应的程序目录必须新建当日rar压缩包进行备份生产环境数据库发布时,必须创建存储过程的副本sql用于回滚,操作方式:F7调出对象资源管理器详细信息->选中所有存储过程->编 ...
- c# 通过文件夹共享复制文件到服务器
public static string[] GetFileNames(string directoryPath, string searchName) { return Directory.GetF ...
- linux find查找并拷贝 exec xargs区别
-exec 1.参数是一个一个传递的,传递一个参数执行一次rm 2.文件名有空格等特殊字符也能处理-xargs 1.一次将参数传给命令,可以使用-n控制参数个数 2.处理特殊 ...
- 简单CSS3代码实现立方体以及3D骰子
1 实现3D立方体 首先准备好UL以及6个Li: 代码如下 ul { position: absolute; top: 50%; left: 50%; transform:translate(-50% ...
- 使用Maven简单配置Mybatis
1.新建一个Maven项目 2. 在pom.xml中进行配置,在pom.xml中配置的时候,需要网速好,当网速不是很好的时候,是加载不出Jar包的. 代码如下所示. <project xmlns ...
- 手动整合实现SSH项目开发02
在bean包下建立User类和User.hbm.xml文件,实现User类和数据库表User的映射关系,具体User类不多说,User.hbm.xml如下: <?xml version=&quo ...