Question

I use an xe:objectData as a datasource for a xp:dataTable. objectData1 uses some Java code to retrieve all documents from a view that match a key ( username ). The Java code looks like this:

package com.isatweb.cois;

import static com.ibm.xsp.extlib.util.ExtLibUtil.getCurrentDatabase;
import static com.ibm.xsp.extlib.util.ExtLibUtil.getCurrentSession;

import java.io.Serializable;

import lotus.domino.Database;
import lotus.domino.Name;
import lotus.domino.Session;
import lotus.domino.View;
import lotus.domino.ViewEntryCollection;

public class ObjectDataVisits implements Serializable {

    private static final long serialVersionUID = 1L;

    ViewEntryCollection vec = null;
    public ObjectDataVisits(){
        try {
            this.update();
        } catch (Exception e) {
            System.out.print(e);
        }
    }

    public void update()  {
        try {
            Database _db = getCurrentDatabase();
            Session _session = getCurrentSession();
            Name nam = _session.createName(_session.getEffectiveUserName());
            String username = nam.getAbbreviated().replace(" ", "#").replace("/", "#").toUpperCase();
            View view = _db.getView("vw_visit_open");
            this.vec = view.getAllEntriesByKey(username);

        } catch (Exception e) {
            System.out.print(e);
        }
    }

    public ViewEntryCollection getVisits(){
                return this.vec;
    }
}

The XPage has the following code enter image description here

When I first load the page, the data is read from the wiew and the dataTable displays the NoteIDs of all matching documents. When I refresh the page using the button, I get an "Object has been removed or recycled" error. Can anyone pls. show me what I'm doing wrong? ( and perhaps, how to do it right )

Was it helpful?

Solution

The problem is, that Notes objects are not serializable. During the partial refresh the getVisits() method is executed before the update() method. The ViewEntryCollection is a references to a view, and this view is already recycled.

If you just want to store some note id's then you could store them in a Vector instead. Otherwise you have to call your update() method in your getVisits() method everytime.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top