简体   繁体   English

如何使用 <p:watermark> 对于 <p:inplace> 编辑

[英]How to use <p:watermark> for <p:inplace> editor

I want to use <p:watermark> for a <p:inplace> editor. 我想将<p:watermark>用于<p:inplace>编辑器。 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? 我该如何实现?

According to Primefaces Showcase , you have to call p:watermark via javascript when some event is happened. 根据Primefaces Showcase的说法,当某些事件发生时,您必须通过javascript调用p:watermark You have lots of events over p:inputText where you can make your call: onblur , onchange ... Just call PrimeFaces.showWatermarks(); p:inputText上有很多事件可以在其中进行调用: onbluronchange ...只需调用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. 您也应该看一下Primefaces文档 ,因为有另一个功能可以在需要时清除水印。 Good luck. 祝好运。

EDITED 已编辑

You can trigger an ajax event when user saves inplaced content. 当用户保存就位内容时,您可以触发ajax事件。 When that request is processed just call the show function and update the main container. 处理该请求后,只需调用show函数并更新主容器。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM