2016-04-22 67 views
0

在Xpages中转换为我的Java的ODA。我有我的PC对象的课程。有些东西不适用于日期。我收到错误Xpages:麻烦OpenNTF ODA日期

java.lang.IllegalArgumentException异常:参数类型不匹配

,当我尝试保存我的XPage,其中包含一个日期。当我实际输入日期并尝试保存时,我只会遇到错误。错误发生在这一行:

public DateTime getCheckInDate() { 
    return checkInDate; 
} 

这里是相关的java代码。

package com.scoular.model; 

import java.io.Serializable; 
import java.util.HashMap; 

import javax.faces.context.FacesContext; 

import org.openntf.domino.*; 
import org.openntf.domino.utils.Factory; 
import org.openntf.domino.xsp.XspOpenLogUtil; 
import org.openntf.domino.impl.DateTime; 

import com.scoular.cache.PCConfig; 

public class PC implements Serializable { 

    private static final long serialVersionUID = 1L; 

    // Common Fields 
    private String unid; 
    private Boolean newNote; 
    private String unique; 

    // Custom Fields 
    private String status; 
    private String serialNumber; 
    private String model; 
    private String officeLoc; 
    private DateTime checkInDate; 

    public DateTime getCheckInDate() { 
     return checkInDate; 
    } 

    public void setCheckInDate(DateTime checkInDate) { 
     this.checkInDate = checkInDate; 
    } 

表格中的相关代码如下:

<xc:cc_CommonFormField id="cc_CheckInDate" 
         placeholder="Check In Date" label="Check In Date"> 
         <xp:this.facets> 
          <xp:inputText xp:key="field" 
           id="checkInDate" value="#{PCModel.checkInDate}"> 
           <xp:this.converter> 
            <xp:convertDateTime type="both"> 
            </xp:convertDateTime> 
           </xp:this.converter> 
           <xp:dateTimeHelper></xp:dateTimeHelper> 
          </xp:inputText> 
         </xp:this.facets> 
        </xc:cc_CommonFormField> 

回答

3

不要在Java类中使用日期时间,使它成为一个日期。 在文档,通过replaceItemValue在节省您的存储日期( “的DateField”,dateProperty)

查看该文档, doc.getItemValue日期时间( “的DateField”,Date.class)

+1

关于ODA的一个非常好的事情是你不需要在存储之前创建一个DateTime - 你可以传递日期到replaceItemValue并自动转换它 –

+0

而不再使用向量;-) –