0

I have filters for columns.

Here i want to show water mark in filter (As Shown in figure in red circle)

I am using prime faces 3.4

I have tred this

<h:form id="parametersListForm" prependId="false">      
    <p:dataTable id="parameteresList" value="#{parameterController.lstParameter}" 
                     var="parameters" selectionMode="single"  
                     selection="#{parameterController.selectedParameter}" 
                     styleClass="tnt-main-table"> 

            <p:ajax event="rowSelect" update=":parameterDetailsForm"
                    listener="#{parameterController.onParametersRowSelect}" />

      <p:column id="colomnRefType" filterBy="#{parameters.beRefType}" 
                 headerText="#{msgs['parameters.beRefType.label']}"
                 filterMatchMode="contains">
                                <h:outputText value="#{parameters.beRefType}"/>
            <p:watermark value="Ref Type" 
                         forElement= ":parameteresList:colomnRefType_filter">
             </p:watermark>
        </p:column>
      </p:dataTable>              
    </h:form>

enter image description here

How can I achieve this?

Venkat Maridu
  • 892
  • 3
  • 22
  • 45
  • I can't see the functionality of a watermark over there. What are you looking for? When it should be displayed? – Aritz Jan 25 '13 at 13:38
  • 1
    what you con't see? I have clearly specified that i want watermark in filter with figure. – Venkat Maridu Jan 25 '13 at 14:01
  • As far as I know water mark is a component which displays a text and filter is a component where you have to introduce text too. You maybe can add a format to the default filter and also set a default text, but to add a whole watermark there? I can't see the point. – Aritz Jan 25 '13 at 14:13
  • And try to be more more explicit in your explanations because it's not easy to see what you want – Aritz Jan 25 '13 at 14:15
  • @TejaMaridu Please also include the `form` and `datatable` in your attached code. I want to have a look whether you gave correct it to `forElement` or not –  Jan 30 '13 at 08:20
  • 1
    I have Updated it with form and datatable @dj aqeel – Venkat Maridu Jan 30 '13 at 08:27
  • 1
    @TejaMaridu Please remove starting colon from the `forElement` attribute. Ie it should look like this: `forElement="parameteresList:colomnRefType_filter"` –  Jan 30 '13 at 08:51
  • @TejaMaridu. Open your page in chrome or firefox. Right click on the filter textfield in the browser, then click inspect element. And please tell me what is the id of the textfield? –  Jan 30 '13 at 09:32
  • 1
  • Either use this id in `forElement`, or use `prependId=false` of your `h:form` –  Jan 30 '13 at 11:08
  • @TejaMaridu Have you succeeded? –  Jan 30 '13 at 13:12
  • I have tred it like you said. But no use. – Venkat Maridu Jan 30 '13 at 14:02

3 Answers3

2

There is an attribute forElement of p:watermark for that. The specifications state that forElement should contain jquery selector of the html input component. But according to these threads here and here, the forElement should strictly be only the client ID of the html input component.

So you can do following:

<p:dataTable id="battingStyleTable" ... ... ..>

    <p:column id="myColumn"
        filterBy="#{battingStyle.battingStyleString}" 
        filterMatchMode="contains">

        <f:facet name="header">Name</f:facet>
        <h:outputText value="#{battingStyle.battingStyleString}" />

        <p:watermark value="Watermark text"
            forElement='battingStyleTable:myColumn_filter'></p:watermark>
        <!-- Please note that the prependId of my form is false, and id of the datatable is battingStyleTable and id of the column is myColumn. Thats why the id of the textfield of the filter will be battingStyleTable:myColumn_filter. Please change it accordingly. If you can't do prependId="false" to your form then you must include form id in the start also, like myFormId:myDatatableId:myColumnId_filter -->
    </p:column>
    ...............
    ..........
    ................
</p:dataTable>
1

Finally got solution.

<h:form id="parametersListForm">      

    <p:dataTable id="parameteresList" value="#{parameterController.lstParameter}"
                 var="parameters" styleClass="tnt-main-table"> 

    <p:column id="columnRefType" filterBy="#{parameters.beRefType}" >
        <h:outputText value="#{parameters.beRefType}" />
        <p:watermark forElement="parametersListForm:parameteresList:columnRefType:filter"
                     value="#{msgs['parameters.beRefType.label']}"/>  
        </p:column>
     </p:dataTable>              
</h:form>

Hope it helps to some one :)

Venkat Maridu
  • 892
  • 3
  • 22
  • 45
1

Try to use this syntax to address the filter field. Worked for me with Primefaces 6.1.

<h:form id="f_myForm">
  <p:dataTable id="dt_myTable">
    <p:column id="col_myCol>
      <h:outputText id="ot_myText" />
      <p:watermark for="@(#f_myForm\\:dt_myTable\\:col_myCol\\:filter)" value="MyPlaceholder" />
    </p:column>
  </p:dataTable>
</h:form>
Richard
  • 582
  • 5
  • 19
  • Thank you so much. I'm also in Primefaces 6.1 and this also worked for me. I'm using prependId="false" then in my case it was for="@(#dataTableId\\:columnId\\:filter)" – jmoran Mar 06 '18 at 01:27