- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 JSF 2 应用程序,它有两页,一页用于列出学生,另一页用于显示给定学生的详细信息。列表页面在学生表的每一行中都有一个指向详细信息页面的链接,单击该链接会在浏览器中打开一个新选项卡以显示这些详细信息。
现在,要求更改为不再在新选项卡中显示详细信息,而是在列表页面的模式对话框中显示详细信息。
我的想法是简单地将详细信息页面内容嵌入到模式对话框中,这样列表页面就不会变得太大并且难以维护。从这里开始我的疑惑。经过一番研究后,我将列表每一行中的链接更改为以下按钮:
<p:commandButton value="Details" type="button"
onclick="PF('dialog-details').show()">
</p:commandButton>
对话框声明如下:
<p:dialog widgetVar="dialog-details" header="Details" modal="true" width="95%">
<ui:include src="student_details.xhtml">
<ui:param name="id" value="#{student.id}"/>
</ui:include>
</p:dialog>
最后,详情页改成这样:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:metadata>
<f:viewParam name="id" value="#{studentBean.id}" />
</f:metadata>
<h1 class="title ui-widget-header ui-corner-all">Details of #{studentBean.bean.name} / #{studentBean.bean.number}</h1>
</ui:composition>
当我单击按钮时,对话框真正显示,内容是详细信息页面。我在对话框中看到以下内容:
Details of /
完全没有错误,但应该显示的数据却没有。断点设置在 StudentBean.setId()
(此方法加载名为 bean
的属性,其中 Student
实例对应于传递的 id),但它永远不会被命中。
经过一段时间的思考,我明白了为什么它不起作用。详情页传递的参数为student.id
,但是student
是用作 var
的名称在 <p:datatable/>
显示所有学生,所以 student
在 <p:dialog/>
中无效位于 <p:datatable/>
之外.
所以,我需要的是一种使用给定行中相应学生的 id 显示对话框的方法。理想情况下,我希望在此处进行 ajax 调用,以便仅在需要时才加载详细信息。
有什么想法吗?
最佳答案
该按钮应该是一个ajax按钮,它设置bean中当前迭代的实体,然后更新对话框的内容,最后显示它。该对话框应该只引用 bean 中的该实体并在保存时更新列表和表格。将对话框放置在主窗体之外并拥有自己的窗体非常重要。
这是一个启动示例:
<h:form id="master">
<p:dataTable value="#{bean.entities}" var="entity">
<p:column>#{entity.property1}</p:column>
<p:column>#{entity.property2}</p:column>
<p:column>#{entity.property3}</p:column>
...
<p:column>
<p:commandButton value="View" action="#{bean.setEntity(entity)}"
update=":detail" oncomplete="PF('detail').show()" />
</p:column>
</p:dataTable>
</h:form>
<p:dialog id="detail" widgetVar="detail">
<h:form>
<p:inputText value="#{bean.entity.property1}" />
<p:inputText value="#{bean.entity.property2}" />
<p:inputText value="#{bean.entity.property3}" />
...
<p:button value="Close" onclick="PF('detail').hide(); return false" />
<p:commandButton value="Save" action="#{bean.save}"
update=":master" oncomplete="if(!args.validationFailed) PF('detail').hide()" />
</h:form>
</p:dialog>
将其放在 @ViewScoped
bean 中:
private List<Entity> entities; // +getter
private Entity entity; // +getter+setter
@EJB
private EntityService entityService;
@PostConstruct
public void load() {
entities = entityService.list();
entity = null;
}
public void save() {
entityService.save(entity);
load();
}
关于jsf - 如何显示 p :dataTable in a p:dialog and update after save 中当前行的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28236228/
使用的浏览器 - Chrome 67.0.3396.99 我创建了一个 DialogsModule它有一个组件 ConfirmDialog.component.ts使用以下模板 confirm-dia
我一直在尝试制作一个简单的程序来使用Electron创建和读取文件。 到目前为止,我已经尝试了很多,并且似乎没有提供与dialog.showOpenDialog一起提供的回调函数。 dialo
我有一个登录对话框,想防止它在按下回车键时自动关闭。 更具体地说,当用户输入凭据并按下回车键时,凭据的响应返回错误,我希望对话框保留(这样我就可以向他们显示一些错误消息,让用户再试一次) . 这就是我
Jquery对话框的含义是什么:它是单独的网页还是网页的一部分? (我不太了解 Jquery)。 谢谢 最佳答案 jQuery 对话框将出现在页面上方,但它实际上是当前页面的一部分。当您加载对话框时,
当用户退出 xe:dialog 时,我需要做一些清理工作。我将代码放在 onUnload 事件中,如下所示: viewScope.remove("vsSomeVariable"); viewScope
我想相对于我的 html 元素之一定位 Dojo 的 Dijit 对话框。是否可以? 如是。如何? 目前它总是在视口(viewport)中间显示对话框。 有人可以帮我解决这个问题吗? 谢谢。 amar
即使属性设置为“openDirectory”,是否也可以在 showOpenDialog 中显示文件?当然,文件不应该是可选的,但可能会显示为灰色。所以用户知道他选择了正确的目录。在 OSX 上一切正
如何使用 android 标准组件 Bottom Sheet 单实现以下设计功能: 出现 Bottom Sheet 对话框片段时的图像: 用户向上滚动以查看内容底部时的图像: 我将使用 ViewPag
我刚开始使用对话框,我非常喜欢在资源文件中定义布局的可能性。但是是否可以设置一个对话框并将其嵌入到另一个对话框中(即没有 float 对话框)? 对于普通窗口,我创建了一个带有一个子窗口的主窗口。然后
我正在尝试更改 dialog 的背景颜色元素的 backdrop使用自定义 CSS 属性,但不需要。这是 Chrome 中的错误还是有原因? document.querySelector('dialo
我有一个 Electron 应用程序。如果我通常使用dialog.showmessageBoxSync,则必须等待用户输入。选项为:关闭,取消或确定。 它工作正常,但是如果我在对话框外部(应用程序内的
我有一个启动确认对话框的 View ,但代码不是等待对话框返回结果,而是直接跳转到 promise 的“then”部分。请参阅下面的代码: ConfirmDialog.ts import { inje
我有一个启动确认对话框的 View ,但代码不是等待对话框返回结果,而是直接跳转到 promise 的“then”部分。请参阅下面的代码: ConfirmDialog.ts import { inje
我正在使用 MonoTouch.Dialog 的 OwnerDrawnElement,但它似乎不允许用户在触摸屏幕时“突出显示”单元格。我查看了示例,但它没有显示突出显示。有什么建议么? 我注意到 T
此选择器在 http://jqueryui.com/demos/dialog/#modal-confirmation 中引用(源代码)。 $( "#dialog:ui-dialog" ).dialog
我有一个奇怪的问题。当 Activity 开始时,我会显示一个对话框,说明某些项目正在加载,如下所示: Dialog dialog; @Override public void onCreate(Bu
jquery-ui 中 .dialog("close") 和 .dialog("destroy") 有什么区别? 我有一个脚本,以前的开发人员使用了 .dialog("destroy") 但现在我必须
我正在使用 Acengage (Ad4Push),我想自定义它的对话框。 Acengage 团队说可以使用自定义主题更改对话框样式,我做到了。我可以更改 textSize、textColor、wind
我有一个标准 View ,顶部有一个导航栏。我还在它自己的源文件中设置了一个 Monotouch.Dialog。我四处寻找解决方案,但似乎找不到关于如何将 MTD 添加到普通 View 的明确答案。
我试图从一个打开的 md-dialog 中打开一个 md-dialog,但问题是第一个 md-dialog 在第二个打开时关闭了 // the controller of the first popU
我是一名优秀的程序员,十分优秀!