0

I want to use <p:watermark> for a <p:inplace> editor. I tried it as below

<p:watermark for="txtSvcName" value="Please enter service name..." />
<p:inplace id="ipSvcName" editor="true" >                                   
    <p:inputText id="txtSvcName" value="#{service.serviceName}"  maxlength="50" 
     readonly="#{not subMerchantManagement.editPerspective}"    converter="UpperCaseConverter" />                                   
</p:inplace>

but unfortunately that doesn't work. How can I achieve this?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
ttakci
  • 77
  • 1
  • 8
  • 1
    Please do not use `[jsf-1.2]` tag if you aren't asking a question about JSF 1.2. – BalusC Jan 13 '13 at 13:20
  • I am sorry, u are right; i guess, i used wrong tag. I will try to be more carefull about that. Thanks... – ttakci Jan 13 '13 at 18:59

1 Answers1

0

According to Primefaces Showcase, you have to call p:watermark via javascript when some event is happened. You have lots of events over p:inputText where you can make your call: onblur, onchange... Just call PrimeFaces.showWatermarks(); function when the one you need happens. You should take a look to Primefaces Documentation too, because there is another function to clean the Watermarks when you need it. Good luck.

EDITED

You can trigger an ajax event when user saves inplaced content. When that request is processed just call the show function and update the main container. I guess it will be useful.

<p:panel id="panel">
    <p:watermark for="txtSvcName" value="Please enter service name..." />
    <p:inplace id="ipSvcName" editor="true" emptyLabel="Please enter service name..." >                                   
        <p:inputText id="txtSvcName" value="#{service.serviceName}" maxlength="50" 
            readonly="#{not subMerchantManagement.editPerspective}"    converter="UpperCaseConverter" /> 
        <p:ajax event="save" listener="#{subMerchantManagement.handleSave}" 
            oncomplete="PrimeFaces.showWatermarks();" update="panel" />  
    </p:inplace>
</p:panel>
Aritz
  • 30,971
  • 16
  • 136
  • 217
  • 1
    Thank u for your response. I analyzed the PF Guide. But actually i couldnt find a solution about this situation; where should i use that show and clear functions? Have u got any idea? – ttakci Jan 13 '13 at 18:54
  • You're welcome. It depends on what you want to achieve. I have edited my response with some functionality that can be useful. – Aritz Jan 13 '13 at 21:56
  • Thank you again. Actually, the watermark doesnt show the text initially when the textbox is in inplace editor. I guess we can also use a javascript for a workaround for this issue. I am thinking that I will give an initial value to the textbox and i will clear the textbox value while onclick event is fired. – ttakci Jan 15 '13 at 07:04
  • You can call `Primefaces.showWatermarks()` when the page is loaded or call it when the `p:inputText` is clicked using `onclick="PrimeFaces.showWatermarks();"` – Aritz Jan 15 '13 at 10:09
  • Hey, I found the problem. Inplace doesnt show the inner element if its value is empty. When i use 'emptyLabel' attribute for innerplace, everything works fine. Thank u for your all answers... – ttakci Jan 16 '13 at 11:50
  • You're welcome man. You can edit my answer or create your own one in order to mark the question as answered. – Aritz Jan 16 '13 at 12:08