gpt4 book ai didi

PrimeFaces p :dialog is not centered when combined with p:schedule

转载 作者:行者123 更新时间:2023-12-02 03:23:08 24 4
gpt4 key购买 nike

版本:PrimeFaces 5.2

我有什么:一个页面上有几个对话框,当单击 docker-icon 时会调用这些对话框。它适用于所有对话框,但包含 <p:schedule> 的对话框除外。

会发生什么:单击 docker-icon 时,<p:dialog><p:schedule>出现。

  • 位置粘在屏幕的右边缘。
  • 我可以垂直移动它
  • 当我水平移动它时,它只会水平调整大小(=宽度增加)。对话框仍然粘在右边框上。
  • 如果我最小化和取消最小化该对话框,那么它会出现在屏幕的中央并且没有发现不良行为。

我尝试了什么:我尝试使用 <p:dialog> <p:outputPanel> 提供的所有属性和 <p:schedule> .唯一改变行为的是当我替换 <p:schedule> 时有不同的东西。然后对话框出现在屏幕中央。

相关代码:

<p:dialog 
id="eventDialog"
widgetVar="event"
position="center"
minimizable="true"
maximizable="true">

<p:outputPanel id="eventPanel">
<ui:include src="/WEB-INF/pages/event.xhtml"/>
</p:outputPanel>
</p:dialog>
[...]
//this is where the event-dialog is called from
<p:menuitem value="Events" icon="#{resource['images/Arrows-icon.png']}" onclick="PF('event').show()"/>

事件.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:bnu="http://bootsfaces.net/ui">

<p:schedule id="schedule" value="#{scheduleView.model}" widgetVar="myschedule" timeZone="GMT+2"/>

</ui:composition>

调度 View .java

import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import org.primefaces.model.DefaultScheduleModel;
import org.primefaces.model.ScheduleModel;

@Named
@ViewScoped
public class ScheduleView implements Serializable{

private ScheduleModel model;

@PostConstruct
public void init(){
model = new DefaultScheduleModel();
}

public ScheduleModel getModel() {
return model;
}

public void setModel(ScheduleModel model) {
this.model = model;
}
}

问题:是否有避免这种行为的解决方案?我希望对话框在未最小化后完全按照它的方式显示。我可以自己调用最小化/取消最小化函数吗?

谢谢

最佳答案

Can I somehow call the minimize/unminimize function myself

不是根据文档,那里没有定义 javascript api,但可能有一个函数/方法(检查 dialog.js 源代码)。

原因是对话框在显示时会尝试根据其子项(在本例中为时间表)定义其大小,但失败了。

Is there a solution to avoid this behavior ?

一个解决方案是给对话框一个固定的高度

关于PrimeFaces p :dialog is not centered when combined with p:schedule,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31920349/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com