- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
基本上我正在尝试为 <p:datatable>
设置动态列.
我的一个专栏的内容是p:commandLink
它曾经显示用于文本编辑的对话框,我在 XHTML 中的工作就像一个魅力,但我需要将它转换为 Java 以实现动态用户自定义和首选项。
这是我的 XHTML 版本:
<p:commandLink id="MRepShowButton" update=":form1:display" onclick="EditorDialog.show();" title="Editer le compte rendu">
<f:setPropertyActionListener value="#{exam}" target="#{examenListBean.selectedExamen}" />
</p:commandLink>
这是我的 Java 版本(不工作):
CommandLink rapstatelink = (CommandLink)application.createComponent(CommandLink.COMPONENT_TYPE);
rapstatelink.setId("MRepShowButton");
rapstatelink.setUpdate(":form1:display");
rapstatelink.setOnclick("EditorDialog.show();");
rapstatelink.setTitle("Editer le rapport du patient");
ValueExpression target = ef.createValueExpression(elc, "#{exam}", Object.class);
ValueExpression value = ef.createValueExpression(elc, "#{examenListBean.selectedExamen}", Object.class);
//rapstatelink.setActionListener(new SetPropertyActionListenerHandler(**i don't know wht to do here **));
column.getChildren().add(rapstatelink);
table.getChildren().add(column);
最佳答案
你需要 UICommand#addActionListener()
, 不是 UICommand#setActionListener()
. setActionListener()
是 JSF 1.x 中弃用的方法,它有效地执行 <p:commandLink actionListener="...">
用ValueBinding
.
关于创建 <f:setPropertyActionListener>
以编程方式,不幸的是没有 JSF 实现独立的方式。选择以下选项之一:
使用 JSF 实现特定类,在 Mojarra 的情况下是 com.sun.faces.taglib.jsf_core.SetPropertyActionListenerImpl
:
link.addActionListener(new SetPropertyActionListenerImpl(target, value));
如果是 MyFaces,则为 org.apache.myfaces.event.SetPropertyActionListener
:
link.addActionListener(new SetPropertyActionListener(target, value));
请记住,使用 JSF 实现特定类 com.sun.faces.*
或 org.apache.myfaces.*
在你自己的代码中是一种糟糕的做法。
创建自定义 ActionListener
完成工作的实现。基本上,只需从 Mojarra 中复制粘贴类的源代码即可。或 MyFaces源代码到你的包中。与 1) 相比,这具有以下优势:当您的 Web 应用程序部署到与其他 JSF 实现捆绑在一起的 Java EE 容器时,它不会中断。
利用 EL 2.2 的功能在 EL 表达式中传递方法参数。然后你就可以在action
中完成工作了或 actionListener
属性:
link.setActionExpression(ef.createMethodExpression(elc,
"#{examenListBean.setSelectedExamen(exam)}", Void.class, Exam.class));
(Exam.class
应该代表 #{exam}
的类型)
这实际上与
<p:commandLink ... action="#{examenListBean.setSelectedExamen(exam)}" />
或者如果你真的需要设置一个 Action 监听器:
link.addActionListener(new MethodExpressionActionListener(ef.createMethodExpression(elc,
"#{examenListBean.setSelectedExamen(exam)}", Void.class, Exam.class)));
这实际上与
<p:commandLink ... actionListener="#{examenListBean.setSelectedExamen(exam)}" />
关于jsf - 如何实现 <f :setPropertyActionListener> programmatically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20040052/
我正在尝试移动 p:dialog出h:form ,因为我已经读到这是首选方式(但是我想了解原因,因为我在 p:dialog 中的 form 在我的应用程序中运行良好)。 唯一的困难是对话框标题需要动态
我的 jsf 2.1 页面上有以下 primefaces 按钮: 在应用程序的另一点,我读取了值 ... ... 现在重点是读取按预期工
我使用的数据表有两列,其中有一个标签和一个 selectOneMenu。 我需要动态显示 selectOneMenu 列表,为此我需要在 bean 中设置级别 id。在 commandbutton/c
基本上我正在尝试为 设置动态列. 我的一个专栏的内容是p:commandLink它曾经显示用于文本编辑的对话框,我在 XHTML 中的工作就像一个魅力,但我需要将它转换为 Java 以实现动态用户自
我正在尝试使用 setPropertyActionListener 设置枚举属性,但我不知道该怎么做。这是实体: @Entity public class Invoice { public e
PrimeFaces 和 GAE 的结合再次让我发疯。内部 p:dataTable我想单击一个图像,调用一个 bean 方法并设置一个参数。方法被调用,但参数不起作用。这是一个简化的示例(没有表格):
我想在单击表格行时传递值: 我收到此错误: Parent is not of type ActionSource, type is: javax.faces.component.htm
我似乎无法让 View 范围的托管 bean 与 setPropertyActionListener 一起使用: 如果 companyHolder 是
我正在尝试将当前迭代的 使用 作为托管 bean 的属性.但是,它始终设置为 null . View ,dentistas.xhtml :
从 primefaces 3.0.M3 升级到 3.0.M4-SNAPSHOT 时出现此错误 @60,114 Parent is not of type ActionSource, type is:
我有一个用普通旧式 JSF 编写的 Web 应用程序,我想将其部分迁移到 ICEfaces 以使用它的一些组件,即现在的确认面板。为了使用它,我更改了我的表单,其中包含需要确认从 h: 到ice: 标
你能告诉我如何在 jsf 中使用 Primefaces 为程序化菜单添加 f:setPropertyActionListener public MenuBean() { model
我有一个基于 LazyDataModel 的 Primefaces DataTable。我成功地在表中加载数据,但无法使用 setPropertyActionListener 在对话框中显示所选项目,
我正在尝试创建一个接收链接并添加样式类的自定义组件。 在原始链接中,用户可能有 f:setPropertyActionListener不止一次。 我不想为每个创建 propertyActionList
在 JSF2 中我想设置一些整数值。 例如: 如何从 javascript 命令设置整数值: PrimeFaces.widgets["widgerVarValue"].paginator.getCu
它的作用 我有一个使用 PrimeFaces 3.1.1 的网络应用程序。该应用程序的目的是提供一种更加用户友好的方式来遍历我们拥有的 XML 聚合器。它最初是用 SCALA 编写的,但现在我用 Ja
我可以使用 吗?在自动完成组件中? 自动完成使用托管 bean mbAC例如,我想发送 cliCod从它到另一个 bean: 是这样做的正确方法是什么? 最佳答案 仅在实现 ActionSourc
我希望当用户单击按钮时会发生两件事: 首先触发 setPropertyActionListener,以更新我的 bean 的属性 然后进行 ajax 调用以执行 bean 中的方法 看来我必须在 f:
我在数据表中有一个 fileDownload 组件,但是当我单击它时,似乎在 setPropertyActionListener 设置 datlis.filepath 变量之前调用了 filedown
我想在我的 commandLink 中嵌套多个 setPropertyActionListener,但只有一个有效。你如何尝试这个?此命令链接设置属性,然后打开一个对话框,以便它基本上初始化对话框。
我是一名优秀的程序员,十分优秀!