PrimeFaces error messages are shown in different styles - css

I am developing a web-based application using JSF 2.3 Mojarra with PrimeFaces 7. My problem is that the error messages, which I define everywhere as
<p:message for="...">
<p:autoUpdate/>
</p:message>
are sown in a different style depending on the page I am currently showing. I suspect this is due to some custom style(s) I use, but I am not sure.
I have the following cases:
1.) Two messages are shown, one of which disappears shortly after being shown. Both messages are shown in white color having a red background:
2.) Two messages are shown, one of which disappears shortly after being shown. This time one of them has its text in white and a background in red, while the other has its text in red, and the background in white:
3.) And, I have two more cases as well (however they appear on different pages)
3a.) Only one message is shown with its text in red and without an own background color - meaning that the background color is inherited from parent (which is white)
3.b) Only one message in shown with the text in white, and with a red background color.
Is there a way that I show ALL messages as in the case in (3a.)?

Related

Does Background Color Without Text Matter?

Regarding color contrast:
In this example, do I need to be careful of the blue background even though there is no copy directly on top of it? I.e. do I only need to be concerned with background color when there is copy on top of it, and I could hide the element with the background color from screen readers without causing an issue?
And in this one, do I need to be careful of the contrast between the light blue background and the button or am I only concerned with the contrast between the copy and the button? (I know the image is blurry. It's just an example.)
Both examples are fine as they are.
There are two things that are applicable here.
The first is contrast between text and the background for that text - you must have a contrast ratio of 4.5:1 for normal text and 3:1 for large text / bold text to be WCAG AA compliant. In the first example it is essentially black on white so it will pass easily.
The second is for controls. Buttons, inputs etc. should have a contrast ratio with their background of 3:1 minimum, no matter what state they are in (so if your above button turned white with black text on hover it probably wouldn't pass). In your second example your button is black on light blue so it certainly passes this also.
Also worth noting is that text within controls (your button) has the same 4.5:1 contrast requirement. Yet again white on black passes easily so you are fine.
Just check the contrast (almost certainly fine) on the red button with white text, reds and oranges can be deceiving in their contrast ratios (but as it is quite a dark red I am 99% sure you are fine just by looking at it).
For clarity your blue background in the first one could be 1% darker than the white box and it would be fine as it is not an interactive control that it surrounds.

Shiny Dashboard Box Lines

I have some boxes on my dashboard body. But the thing is, I want to make my Shiny looks like a white page with something to display instead of having some boxes separate them. I already use CSS to change my background as white colors, is it possible to change the box lines into white colors or invisible?
Also can I change my Valid statuses to white one as well? At the moment they only have
primary Blue (sometimes dark blue)
success Green
info Blue
warning Orange
danger Red
Pictures with two boxes:

Modify default widget text color with applied stylesheet of QTreeWidget items

I have a QTreeWidget (however this question relates to any kind of widget) in which I have items which, under certain circumstances change their foreground color to red using item.setForeground(0,QBrush(QColor("red"))).
Later they can change their foreground color back to black. But the problem is that if the widget has been set some stylesheet which has changed the foreground color to other than black, I am in trouble. My question is how to revert the color of an item to the default color used by the widget for text color given the applied stylesheets?
For example if I apply a dark stylesheet which makes widget background dark and default text color white, first I can see white items, then they change to red and then they become black. But I want them white again. But I do not know how to find that it is white (and not black) color they should change to.
I tried this:
1) if I use item.setForeground(QtGui.QBrush()) which I hoped would use empty and therefore default brush, I always get black text
2) if I query the text color treeWidget.palette().text().color() I always get the same color regardless of the stylesheet
This question doesn't really apply to "any kind of widget", because there is no guarantee that setting the foreground colour will always work. To quote from the docs for QPalette:
Warning: Some styles do not use the palette for all drawing, for
instance, if they make use of native theme engines. This is the case
for both the Windows XP, Windows Vista, and the Mac OS X styles.
However, if the question is restricted to model items (such as QTreeWidgetItem), you can clear the current settings like this:
item.setData(column, QtCore.Qt.ForegroundRole, None)
On platforms that do allow changes via the palette, you could get the default palette like this:
palette = QtGui.qApp.style().standardPalette()
which should then allow you to restore the original values.

label background and foreground change Unexpectedly

In my web applicaton I have some div that contain labels, when I click on a label it's foreground become blue and background become white.how can I prevent that?
I would avoid disabling user select colours. I don't know about other people but I often select text on websites, not because I want to copy it but because I am struggling to read it and selecting text is by far the easiest way to change the colour of text against it's background. I even sometimes do it with black text on a white background.

Highlighting text in JavaFx Label

I am trying to set the text background of the JavaFx label text as green using the following CSS
label.setStyle("-fx-background-color:rgba(85, 255, 68,0.7););
And the unhighlight using the following
label.setStyle("-fx-background-color:rgba(0,0,255,0);");
However these does not work most of the times when it has to be done back to back.
Is there any way to set the style without using CSS i.e. using JavaFx API itself. I found label.textFill(Paint p) for text color but nothing for background colour i.e. the color of the label itself.
Is there any way to set the style without using CSS i.e. using JavaFx API itself.
For some styles (such as the text fill) yes. For background colors, background images, borders, etc API methods will not be available until JavaFX 8 is released (see Public API for Region backgrounds and borders in the JavaFX issue tracker for more information - anybody can sign up for access).
these does not work most of the times when it has to be done back to back.
If you just highlight a label and then unhighlight it again without using something like a PauseTransition to give the user some time to see the highlighted label, then, from the user's perspective nothing is going to happen as all the user will see is an unhighlighted label.
Not sure of your use case, but if you only want to highlight part of the text in a label or let the user highlight the text with a mouse, then you can use a TextField with editable set to false.
Possible Workaround
If the Java 8 preview does not work for you and you are experiencing errors due do bugs in the JavaFX CSS processing, then try placing a Pane then a label inside a StackPane. Set the background color of the Pane to label.setStyle("-fx-background-color:rgba(85, 255, 68,0.7);); Bind the Pane's preferred width and height to the Label's width and height and toggle setVisible on the Pane as appropriate.
Finally I found the workarround. I had to give a PauseTransition to give the system some time between unhighlight and highlight. CSS showed effect only after the pausetransaction if the labels were already highlighted. I think it may be a bug. I will file a jira. The duration of paustransition may be as low as 1 milisecond so that there is not lag from the user's point of view.

Resources