primeFaces 日历控件<p:calendar> 防止编辑功能使用小结

PrimeFaces日历控件<p:calendar>禁止编辑功能设置
本文介绍了如何使用PrimeFaces的<p:calendar>控件来防止用户直接编辑日期,确保输入格式正确。通过设置`readonlyInput="true"`属性,可以限制用户只能通过日历选择日期,而不能手动输入,简化了防止日期格式错误的问题。
部署运行你感兴趣的模型镜像

       不知道各位是不是也有这样的感受,当需要某个控件完成我们需要的功能,而我们又没有曾经使用过此功能时,你会怎么做呢?   我相信有相当一部分人和曾经的我相同:打开搜索引擎,在网上一顿搜,无论是有用的还是没用的,都全部拿来,再做筛选,当然了结果无非两种情况:(一)找到了,费了不少时间和精力.(二)没找到,时间也用了不少.

        这也是我写这篇博客的原因之一,以我对解决问题的真实体会,首先,提倡大家有问题直接查阅官方文档, 其次,到网上搜,希望有和我有相同功能需求的您,能找到这篇总结,避免花费太长时间还不能找到想要的结果.

1.<p:calendar>.属性:

2.完成小功能:

    为了避免在输入日期时格式出现错误,在界面上,只允许在日历控件中选择,从而完成输入,不允许编辑.

(*)xhtml代码片段:

<p:calendar    size="8"  readonlyInput="true"  value="#{user.date}" pattern="yyyy-MM-dd">                                          
                                </p:calendar>   
说明:功能的关键就在"readonlyInput="true""这么一句,是不是比在网上搜索别人的例子然后帅选来的快的多呢.


您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

帮忙美化下这个dialog <p:dialog header="编辑药物信息" id="drugDialog" widgetVar="drugDialog" modal="true" height="600px" width="500px"> <h:form id="drugForm"> <p:panelGrid columns="2"> <span class="ui-inputgroup-addon" style="font-weight: bold;width: auto;">药物编号</span> <p:inputText id="editDrugCode" style="width: 100px;height: 35px;" value="#{drugInfoList_MgBean.drugInfoDm.drugCode}" readonly="#{drugInfoList_MgBean.editMode}"/> <span class="ui-inputgroup-addon" style="font-weight: bold;width: auto;">药物名称</span> <p:inputText id="editDrugName" style="width: 100px;height: 35px;" value="#{drugInfoList_MgBean.drugInfoDm.drugName}"/> <span class="ui-inputgroup-addon" style="font-weight: bold;width: auto;">药物规格</span> <p:inputText id="editSpec" style="width: 100px;height: 35px;" value="#{drugInfoList_MgBean.drugInfoDm.spec}"/> <span class="ui-inputgroup-addon" style="font-weight: bold;width: auto;">生产厂家</span> <p:inputText id="editManufacturer" style="width: 100px;height: 35px;" value="#{drugInfoList_MgBean.drugInfoDm.manufacturer}"/> <span class="ui-inputgroup-addon" style="font-weight: bold;width: auto;">单价</span> <p:inputText id="editUnitPrice" style="width: 100px;height: 35px;" value="#{drugInfoList_MgBean.drugInfoDm.unitPrice}"/> <span class="ui-inputgroup-addon" style="font-weight: bold;width: auto;">适应症</span> <p:inputText id="editContraindications" style="width: 100px;height: 35px;" value="#{drugInfoList_MgBean.drugInfoDm.contraindications}"/> <span class="ui-inputgroup-addon" style="font-weight: bold;width:70px;">有效期至</span> <p:calendar class="ui-datepicker-buttonpane" id="editExpiryDate" navigator="true" pattern="yyyy-MM-dd" inputStyle="width:100px;height: 35px;" value="#{drugInfoList_MgBean.drugInfoDm.expiryDate}"></p:calendar> </p:panelGrid> <p:commandButton value="保存" update="resultsTable" action="#{drugInfoList_MgBean.saveDrug}"/> </h:form> </p:dialog>
05-29
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值