Reputation: 498
I found this code which positions a PrimeFaces dialog in the top left corner in our project:
<p:dialog styleClass="dialog-top-left" ...>
and in the .css file:
.top-left-dialog {
top: 10px !important;
left: 10px !important;
}
Now this is clearly wrong (it prevents the dialog from being dragable), you should actually do it like this:
<p:dialog position="top, left" ...>
However, the incorrect version using CSS has a nice advantage: I can just change the CSS to change the positioning of all of my dialogs that have the dialog-top-left
class. Is there a way to also control the position =
attribute from some central point (like the .css file for the CSS variant)?
Upvotes: 1
Views: 223
Reputation: 20253
You could create an ApplicationFactory
for this. In the ApplicationWrapper
use something like:
@Override
public UIComponent createComponent(FacesContext context, String componentType, String rendererType) {
final UIComponent component = super.createComponent(context, componentType, rendererType);
if (component instanceof Dialog) {
final Dialog dialog = (Dialog) component;
dialog.setPosition("top, left");
}
return component;
}
For a complete example follow the linked documentation page.
Upvotes: 1