具有日期值的selectonemenu显示为红色 [英] selectonemenu showen red when have date value

查看:59
本文介绍了具有日期值的selectonemenu显示为红色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个示例selectOneMenu,它具有日期和日期列表作为值,但是当我尝试验证时,将其显示为红色,我将向您展示我的示例示例:

i have a sample selectOneMenu that have List of date and date as values but when i try to validate i have it red i will show you my sample example :

我的托管bean:

@ManagedBean
@SessionScoped
public class Testbean {
    @EJB
    private ManageOfPlanifieLocal manageOfPlanifie;
        List<Date> listdate = new ArrayList<Date>();
        Date newdate;

 @PostConstruct
    public void initialize() {     
        listdate=manageOfPlanifie.retournerdatedesplanif();;
    }
    public String gototest2(Date date)
    {

    return "test2.xhtml?faces-redirect=true";
    }
    public List<Date> getListdate() {
        return listdate;
    }
    public void setListdate(List<Date> listdate) {
        this.listdate = listdate;
    }

    public Date getNewdate() {
        return newdate;
    }

    public void setNewdate(Date newdate) {
        this.newdate = newdate;
    }  
}

这是我的两个jsf页面:

and this is my two jsf pages :

test1.xhtml

test1.xhtml

     <h:outputLabel for="dateplanif" value="date de planification : " />
     <p:selectOneMenu id="dateplanif" value="#{ testbean.newdate}">   
         <f:selectItems value="#{testbean.listdate}" var="da" itemValue="#{da}" />  
</p:selectOneMenu>        

  <p:commandButton value="suivant"  style="color:black;" action="#{testbean.gototest2(testbean.listdate)}" update="@form" />

test2.xhtml

test2.xhtml

  <h2>Choix de l'equipe</h2>  
     <h:outputText value="Date : "/>   
             <h:outputText value="#{ testbean.newdate}"/>

这个问题我很简单地在没有对话的情况下进行数据传输示例,我明白了:

the problem i do sample transfer of data with out converstion just simple and i get that :

你知道我有红色吗,我无法移动到下一页?

do you know i have it red and i cant move to the next page ??

推荐答案

当您有一个对象列表时,需要对其进行转换,以便正确设置该值.尝试以下代码.

When you have a list of Objects, you need to convert them, so that setting the value works properly. Try the following code.

<p:selectOneMenu id="dateplanif" value="#{testbean.newdate}">   
     <f:selectItems value="#{testbean.listdate}" var="da" itemValue="#{da}" />
     <f:convertDateTime pattern="dd-MM-yyyy" />
</p:selectOneMenu>

这篇关于具有日期值的selectonemenu显示为红色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆