【问题标题】:how to render selected date when I select date from calendar using primefaces?当我使用primefaces从日历中选择日期时如何呈现选定的日期?
【发布时间】:2012-06-13 20:36:51
【问题描述】:

当我从 primefaces 的日历控件中选择日期时,所选日期应显示在 outputText 中。我为此编写了代码,但没有工作。

<p:calendar mode="popup" showOn="both" mindate="15-06-2012" pattern="dd-MM-yyyy" effect="fadeIn">
       <p:ajax event="keyup" update="out1"/>
</p:calendar><br/><br/><hr/>
<h:outputText id="out1" value="#{sampleBean.selectedDate}"/>

【问题讨论】:

  • 你试过渲染属性了吗? p:ajax 中的 render="out1" 之类的?
  • 没有渲染属性。
  • 对不起!我的错。我在 Rich:faces 上工作,我认为你需要使用“更新”。看到这个链接forum.primefaces.org/viewtopic.php?f=3&t=6028
  • 我已经用过了,但是没用。
  • 请给我解决方案。

标签: jsf-2 primefaces


【解决方案1】:

好吧,我不确定您要完成什么,但是从日历返回的值转到缺少的“值”标签,为什么您不能简单地使用类似的东西:

<p:calendar value="#{sampleBean.selectedDate}" id="calId"  mode="popup" showOn="both" mindate="15-06-2012" pattern="dd-MM-yyyy" effect="fadeIn" />

这应该(根据文档和Showcase)应该用日历渲染 n 输入就好了......

【讨论】:

    【解决方案2】:

    从您的问题中,我了解到您想在您选择的输出中显示日期。

    为此在你的

    <p:calendar..... code 
    

    添加声明

    value="#{sampleBean.selectedDate}" update=":out1"
    

    这样选定的值将保存在您的 sampleBean 的 selectedDate 属性中。

    <h:outputText id="out1" value="#{sampleBean.selectedDate}"/>
    

    【讨论】:

    • 另外,当您提出问题时,请说明您目前正在处理的内容,例如 jsf 版本、primefaces、richfaces 等版本以及您的服务器...
    猜你喜欢
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-12
    • 1970-01-01
    • 1970-01-01
    • 2020-01-11
    • 2021-09-09
    相关资源
    最近更新 更多