jsf - 页面加载时显示 Primefaces 的 OverlayPanel
问题描述
overlayPanel
当单击目标组件 (a ) 时,该页面会显示 Primefaces commandButton
:
<p:commandButton id="inputBtn" value="Choose a data source" type="button" action="#{dataImportBean.oAuth}"/>
<p:overlayPanel
id="overlaypanel1"
for="inputBtn"
dynamic="false"
widgetVar="inputChooser"
>
// contents of the overlay panel
</p:overlayPanel>
我需要overlayPanel
在页面加载时显示,而无需单击目标commandButton
。
用例是:用户已overlayPanel
打开但 oAuth 流程使用户导航离开页面。oAuth 完成后,用户将被重定向到该页面。但是,当页面加载时,overlayPanel 会关闭,而我需要将用户直接带回 overlayPanel,以保持一致性。
解决方案
在您的小部件 var 上使用客户端 API。您可以使用show()
来显示面板,因此在您的情况下:PF('inputChooser').show()
.
要在页面加载时执行此操作,您可以将其放在p:overlayPanel
:
<c:if test="#{yourCondition}">
<script>$(function() { PF('inputChooser').show() })</script>
</c:if>
也可以看看:
推荐阅读
- java - 就 DDD 而言,是否可以在域服务中为聚合根实体而不是聚合根存储库实现 crud 逻辑?
- python - 如何从多个 vCenter 获取所有 vm 的详细信息?
- powerbi - Power Query : 会计月日数 WorkingDay
- javascript - Discord.js - 正确使用:for (const guild of client.guilds.cache)?
- javascript - 拒绝执行脚本并启用严格的 MIME 类型检查
- .net - dotnet 核心中的 DefaultModelBinder 替代品
- regex - 如何为 AWS 资源制作正则表达式
- ios - Flutter iOS Firebase Analytics 和 Crashlytics 未显示
- c - 如何在 CUnit 的帮助下测试自定义错误消息?
- javascript - 通过数据ID引用使javascript更改选择选项