简体   繁体   English

如何更改jsf primefaces中确认框的位置?

[英]How to change the position of confirmation box in jsf primefaces?

I am using primefaces confirmation box in JSF. 我在JSF中使用primefaces确认框。 The dialog is getting pop up at the end of the page but i want it to get pop up at the center of the page. 该对话框在页面末尾弹出,但我希望它在页面中央弹出。 on checking with inspect element in browser I am getting below html code whcih shows the dilog box by default have inline CSS defined. 在浏览器中使用检查元素进行检查时,我得到以下html代码,该代码默认情况下显示dilog框已定义内联CSS。 I tried to give css to its class but its not working . 我试图给CSS上课,但它没有用。

确认框的html代码

JSF Code : JSF代码:

<p:confirmDialog message= "Do you want to save your changes?"   showEffect="fade" widgetVar="Confirm" position="center"> 

<p:commandButton value="Yes" action="#{emdNew.save}" oncomplete="PF('Confirm').hide()" update=":form"/>

<p:commandButton value="No"  update="@form"  immediate="true" action="#{emdNew.no}" oncomplete="PF('Confirm').hide()" /> 

</p:confirmDialog>

Someone please help. 有人请帮忙。 Thanks in advance. 提前致谢。

You can use the appendTo -attribute to define the element on which the <p:confirmDialog> should be centered. 您可以使用appendTo -attribute定义<p:confirmDialog>应该居中的元素。 I would try using the following value: 我会尝试使用以下值:

<p:confirmDialog appendTo="body" ...></p:confirmDialog>

Another approach would be to override the default styling of the .ui-dialog class: 另一种方法是重写.ui-dialog类的默认样式:

.ui-class {
   top: 50%;
   left: 50%;
}

Be careful to include your custom stylesheet after default PrimeFaces CSS. 请注意在默认的PrimeFaces CSS之后包括您的自定义样式表。

I can't test this atm but I hope this helps you solve your issue. 我无法测试此atm,但希望它能帮助您解决问题。 Have a look at the docs for further information. 查看文档以获取更多信息。

If you use confirmDialog in form, you need to write like this; 如果在表单中使用confirmDialog ,则需要这样编写;

/*This code for dialog component*/

#formID\:dialogID {
  left: 5% !important;
  top: 15% !important;
}

/*This code for confirmDialog component*/

.ui-dialog {
  left: 5% !important;
  top: 15% !important;
}

but be careful using .ui-dialog . 但请小心使用.ui-dialog

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM