p:watermark for p:selectOneMenu not working

UI Components for JSF
Post Reply
RueKow
Posts: 331
Joined: 21 Jun 2011, 23:34
Location: Germany - Wiesbaden

24 Jun 2016, 20:06

I want to put a watermark on p:selectOneMenu component. It should look like this:
Image

This is not working (no watermark visible):

Code: Select all

<p:outputLabel for="itAzu05" value="Abschluss" />
<p:selectOneMenu id="itAzu05" value="#{mintController.matrix.meldungAzu.abschluss}"
	autoWidth="false" style="width:170px">
	<f:selectItem itemLabel="Ausbildung abgebrochen" itemValue="1" />
	<f:selectItem itemLabel="Prüfung bestanden" itemValue="2" />
</p:selectOneMenu>
<p:watermark for="itAzu05" value="Bitte wählen ..." />
However when using editable="true" it is working (see screenshot above):

Code: Select all

<p:outputLabel for="itAzu05" value="Abschluss" />
<p:selectOneMenu id="itAzu05" value="#{mintController.matrix.meldungAzu.abschluss}"
	editable="true" autoWidth="false" style="width:170px">
	<f:selectItem itemLabel="Ausbildung abgebrochen" itemValue="1" />
	<f:selectItem itemLabel="Prüfung bestanden" itemValue="2" />
</p:selectOneMenu>
<p:watermark for="itAzu05" value="Bitte wählen ..." />
Is this a bug or feature ???
My goal is not to use an editable p:selectOneMenu.
I'm pleased about any hint.
Rüdiger

PrimeFaces 11.0 | Ultima 2.0
Mojarra 2.3 | Tomcat 8/9 | Win7/10 | OS X 10.14

mpamps
Posts: 8
Joined: 09 Jun 2016, 11:27

25 Jun 2016, 23:23

According to the guide, p:watermark works with input fields.
p:selectOneMenu is not an input field. However, when you set editable=false, an input element is added in order to capture user's input
and therefore watermarks targets this input element.

Instead of watermark, you could use f:selectItem that results to "null" when selected:

Code: Select all

<f:selectItem itemLabel="Bitte wählen ..." itemValue="#{null}" />
This would have the result you want, except for the font color that won't be this ilght grey that the watermark has.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 47 guests