2016-04-22 66 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

而不再使用向量;-) –