RE: Problem using custom tags.

2001-10-09 Thread Shields James

Could someone managing this list stop these messages?
I've had about 200 of them, and I'm getting a bit pied of.

-Original Message-
From: Johan Fredriksson [mailto:[EMAIL PROTECTED]]
Sent: 09 October 2001 09:59
To: Orion-Interest
Subject: RE: Problem using custom tags.


inline

-Original Message-
From: E Stones [mailto:[EMAIL PROTECTED]]
Sent: den 8 oktober 2001 14:01
To: Orion-Interest
Subject: Problem using custom tags.


The following example is taken from Chapter 2 of Advanced Java Server 
Pages
by David M. Geary

I'm getting this error when I try to implement to code sample below:

--
500 Internal Server Error:
Error parsing JSP page /test1.jsp line 13
Bean 'item' already defined
--


Has anyone any ideas what might be the problem?


***
test.jsp code:
***

htmlheadtitleAn Iterator/title/head
%@ taglib uri='/WEB-INF/tlds/iterator.tld' prefix='it' %
body

% java.util.Vector vector = new java.util.Vector();
vector.addElement(one);   vector.addElement(two);
vector.addElement(three); vector.addElement(four);
%

Iterating over %= vector % ...p

--- declaration of item
it:iterate id='item' collection='%= vector %'
--- declaration 2 of item
   !--jsp:useBean id='item' scope='page' class='java.lang.String'/--

//above should not be necessary.
   
   Item: %= item %br
/it:iterate

/p
/body
/html



Iterator.tld

?xml version=1.0 encoding=ISO-8859-1 ?
!DOCTYPE taglib PUBLIC -//Sun Microsystems, Inc.//DTD JSP Tag Library 
1.1//EN web-jsptaglib_1_1.dtd
taglib
tlibversion1.0/tlibversion
jspversion1.1/jspversion
shortnamesmp/shortname
infoSun Microsystems Press Tag Library/info
tag
nameiterate/name
tagclasstags.IteratorTag/tagclass
teiclasstags.IteratorTagInfo/teiclass
bodycontentJSP/bodycontent
attribute
nameid/name
requiredtrue/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namecollection/name
requiredtrue/required
rtexprvaluetrue/rtexprvalue
/attribute
infoIterates over a collection/info
/tag
/taglib

***
IteratorTag.java
***

import java.util.Collection;
import java.util.Iterator;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class IteratorTag extends BodyTagSupport {
   private Collection collection;
   private Iterator iterator;

   public void setCollection(Collection collection) {
  this.collection = collection;
   }
   public int doStartTag() throws JspException {
  return collection.size()  0 ? EVAL_BODY_TAG : SKIP_BODY;
   }
   public void doInitBody() throws JspException {
  iterator = collection.iterator();
  pageContext.setAttribute(getId(), iterator.next());
   }
   public int doAfterBody() throws JspException {
  if(iterator.hasNext()) {
 pageContext.setAttribute(getId(), iterator.next());
 return EVAL_BODY_TAG;
  }
  else {
 try {
getBodyContent().writeOut(getPreviousOut());
 }
 catch(java.io.IOException e) {
throw new JspException(e.getMessage());
 }
 return SKIP_BODY;
  }
   }
}



*
IteratorTagInfo.java
*

package tags;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class IteratorTagInfo extends TagExtraInfo {
   public VariableInfo[] getVariableInfo(TagData data) {
  return new VariableInfo[] {
 new VariableInfo(data.getId(), // scripting var's name
   java.lang.Object, // variable's type
   true, // whether variable is created
   VariableInfo.NESTED) // scope
  };
   }
}








_
Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp






RE: Date conversion problem ??

2001-10-05 Thread Shields James

The javadoc documentation for Date and Timestamp in java.util and java.sql
is worth consulting.


public class Timestamp
extends Date

A thin wrapper around java.util.Date that allows the JDBC API to identify
this as an SQL TIMESTAMP value. It adds the ability to hold the SQL
TIMESTAMP nanos value and provides formatting and parsing operations to
support the JDBC escape syntax for timestamp values. 

Note: This type is a composite of a java.util.Date and a separate
nanoseconds value. Only integral seconds are stored in the java.util.Date
component. The fractional seconds - the nanos - are separate. The getTime
method will return only integral seconds. If a time value that includes the
fractional seconds is desired, you must convert nanos to milliseconds
(nanos/100) and add this to the getTime value. The
Timestamp.equals(Object) method never returns true when passed a value of
type java.util.Date because the nanos component of a date is unknown. As a
result, the Timestamp.equals(Object) method is not symmetric with respect to
the java.util.Date.equals(Object) method. Also, the hashcode method uses the
underlying java.util.Data implementation and therefore does not include
nanos in its computation. Due to the differences between the Timestamp class
and the java.util.Date class mentioned above, it is recommended that code
not view Timestamp values generically as an instance of java.util.Date. The
inheritance relationship between Timestamp and java.util.Date really denotes
implementation inheritance, and not type inheritance. 


-Original Message-
From: Sarathy Mattaparti [mailto:[EMAIL PROTECTED]]
Sent: 05 October 2001 06:33
To: Orion-Interest
Subject: Re: Date conversion problem ??


use java.util.Timestamp instead of Date that will solve your problem.

Sarathy


Hellu,

I retrieve a datetime  field from the Ms SQL server. With a win sql client 
I
see:
2001-10-03 19:33:10.257

When I print the field in an EJB (I use CMP) the millisecond part is zero
!!!:
Wed Oct 03 19:33:10 GMT+02:00 2001
In milliseconds: 100213039

I had the same problem with the Postgres driver so I don't think it is the
JDBC driver (Opta driver of i-net)

Has anyone any idea what is happening and how I can solve this ??
Hope to get an answer, otherwise I have to convert the datetime fields in
the database to a long to store it in milliseconds, which isn't very 
elegant
I think !?

Eddie







_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





RE: Design strategy

2001-10-02 Thread Shields James

Owen

You're design looks to handle the problem well.
You can even adapt it slightly to get the database to help you with
referential integrity.

However, what you are doing is handling the inheritance manually.
(This is not intended as a criticism.)

EJB does not give you any support to do this.
That is why you have to do it manually.
You cannot create an Entity EJB that is abstract, and then create
sub-classes for Class EJB, Group EJB and User EJB.

Remember an EJB is a component.
It has at least 2 interfaces (Home and Remote) and 1 class (Bean).

Which one(s) do you sub-class?

I had exactly the same problem with one of the most common sets of business
entities to do with managing participants/parties.
These are an abstract class called Party, and 2 concrete sub-classes called
Person and Organisation.
My solution was to implement an EJB for Party that handled Persons and
Organisations.
I had to manage the differences between the sub-classes manually.
It also meant that my DAO were acting like AbstractFactories in that they
could return Person or Organisation details, depending on what was actually
retrieved from the db.

Hopefully, a future version of the EJB spec will deal with inheritance.

HTH

James

-Original Message-
From: Owen Fellows [mailto:[EMAIL PROTECTED]]
Sent: 02 October 2001 10:58
To: Orion-Interest
Subject: RE: Design strategy


Hello,

We have done a similar thing were we don't know the type of class assign the
role except at runtime.

The solution we used was to have an Object Type table (contain Class, Group,
User).
Then created a interface which was Roleable (i.e. this class can have a role
assigned).
In the database you can store each assignment in a different table
(ClassRoles, GroupRoles, UserRoles),
or have a generic table that stores Roleable_id, Role_id and Object_type_id.

This does have drawbacks e.g. the Database does not have enforced
consistence as the Roleable_id is not a foreign key on any one table.  It
may also be slower to retrieve the Roles for a particular (Class, Group,
User) as you will have to lookup it object type and then its roles.  (You
could always cache object types as there will not be that many).

I'm sure you can implement a Bean with the above functionality (we haven't
used beans for this so I can help there).

Hope this is of some help.

Owen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of George Mardale
Sent: 02 October 2001 06:06
To: Orion-Interest
Subject: RE: Design strategy


Hello Alex,

Thank you for your prompt response. Your suggestions are excellent.

You're right, the analysis is not correct. I tried to reduce the problem to
a
simple example. To avoid complexity, I just limited the relationships to
1..*.
Maybe the example is not the best, but I only wanted to know if I could
model
the Abstract being bean in Orion.

There are still 2 issues we are unclear about:
1. what are the advantages of dumping entity Class? (Class has specific
fields
that Group does not have)
2. could you please detail the best way to implement  a *-* relationship in
Orion?

Thanks,
George.





RE: DAO design..

2001-09-28 Thread Shields James

Prashant

1. A DAO is used to do BMP, and is a regular Java class.
Instead coding JDBC calls directly in your EJB (find, create, store,
remove), you put them in a DAO which you call from your EJB.

2. A DAO can contain multiple SQL statements, including various SELECT,
INSERT, UPDATE, DELETE.
For a find*() you perform SELECTs; for a create() you perform an INSERT and
so on.

3. Sun has published a paper that includes use of DAOs.
I think it is one of the J2EE blueprints.

HTH

I don't have time to be more specific.
I hope you get the idea of DAOs, and I hope you can get a hold of the
blueprints.

James

-Original Message-
From: Prashant Gaikwad [mailto:[EMAIL PROTECTED]]
Sent: 28 September 2001 12:17
To: Orion-Interest
Subject: DAO design..


Hi,

I want to use DAO to access data in design. I have the following doubts and
need to understand the concept :-

Requirement is that session beans encapsulating business logic needs to
access access database through DAO object/objects.

1.)  What is DAO object suppose to be ? session/entity bean or a java class
2.)  Can I pack multiple SQL select queries in a single DAO class
3.)  Any specific design approach for DAO


Can I know any links for more information 

Thanks
prashant