This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

narrow(java.lang.Object, java.lang.Class) parameters  RSS feed

 
chuck keuper
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on SessionFacade/DTO's. I created a test client for the Members table and used an iterator to loop through the values. The code is below:

try {
Integer sMemberId = new Integer("1");
Collection c = client.findByDocNames(sMemberId);
Iterator i = c.iterator();
while (i.hasNext()) {
MasterDocCatalogRemote mcr = (MasterDocCatalogRemote)PortableRemoteObject.narrow(i.next(),MasterDocCatalogRemote.class);
System.out.println("DocId = " + mcr.getMasterDocId() + " DocName = " + mcr.getDocName());
}
} catch (Exception ex) {
ex.getStackTrace();
System.out.println("Exception = " + ex);
}

The SessionFacade/DTO's is returning an array of MasterDocCatalogDto[]. I want to be able to loop through and see values. I need an object and class for the narrow parameters and i am not sure what needs to be placed in the object parameter. The code is listed below:

try {
Integer sMemberId = new Integer("1");
int i;
MasterDocCatalogDto[] c = client.masterDocCatalogFindByDocNames(sMemberId);
for (i=1; i lessthan c.length; i++) {
MasterDocCatalogRemote mcr = (MasterDocCatalogRemote)PortableRemoteObject.narrow(???, MasterDocCatalogRemote.class);
System.out.println("DocId = " + mcr.getMasterDocId() + "DocName = " + mcr.getDocName());
}
} catch (Exception ex) {
ex.getStackTrace();
System.out.println("Exception = " + ex);
}


Can someone set me staight???
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chuck, welcome to JavaRanch.

You've landed in the Cattle Drive forum, where the discussions are pretty much limited to the Cattle Drive. You'd have better luck getting help in a different forum, so we'll get this moved for you. Hang on a sec...


Pauline
[ May 27, 2004: Message edited by: Pauline McNamara ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds kind of like a CORBA question to me, so I'm going to move this to the Distributed Java forum for further discussion.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, this looks more like an EJB question... ( sorry for moving your question all over the 'ranch )

But I don't think the cast isn't needed in the first place if I am understanding the question correctly... isn't the point of a DTO to pass a serialized version of the data inside the class rather than a reference to the class itself? If the DTO objects you're getting is just serialized data then there's no reason to do the narrow - you only need to narrow remote references that you receive.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!