Bryan Schmiedeler
Bryan Schmiedeler

Reputation: 3127

Xpages: Trouble with OpenNTF ODA dates

Transitioning over to ODA for my Java in Xpages. I have a class for my PC object. Something is not working with dates. I am getting the error

java.lang.IllegalArgumentException: argument type mismatch

when I try to save my Xpage, which contains a date. I only get the error when I actually enter a date and try to save. The error occurs in this line:

public DateTime getCheckInDate() {
    return checkInDate;
}

Here is the relevant java code.

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;
    }

The relevant code on the form is as follows:

<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>

Upvotes: 0

Views: 117

Answers (1)

Frank van der Linden
Frank van der Linden

Reputation: 1271

Don't use DateTime in a Java class, make it a Date. At the save you an store a Date in the document, by replaceItemValue("dateField", dateProperty)

To get the DateTime from the Document, doc.getItemValue("dateField", Date.class)

Upvotes: 3

Related Questions