I think that you got no tapestry problem.
You could do it like your discribed it or add an if-condition, to
catch the other state:
if(this.quatation != null){
// compare the quatation
} else {
// do nothing
}
It depends on your business-logic...
Izak Wessels wrote:
Hey Stijn,
thanks for you reply. here is the code is snippet of my compareTo() method :
private Quotation_IF quotation;
private SupplierProduct_IF supplierProduct;
/**
*
*/
public int compareTo(Object object){
log.debug("compareTo Initiated");
if(!(object instanceof QuotationProduct_IF)) {
throw new ClassCastException();
}
final QuotationProduct_IF quotationProduct =
(QuotationProduct_IF)object;
final int EQUAL = 0;
//this optimization is usually worthwhile, and can
//always be added
if ( this == quotationProduct ) return EQUAL;
//objects, including type-safe enums, follow this form
//note that null objects will throw an exception here
196 --> int comparison = this.quotation.compareTo(
quotationProduct.getQuotation());
if ( comparison != EQUAL ) return comparison;
comparison = this.supplierProduct.compareTo(
quotationProduct.getSupplierProduct());
if ( comparison != EQUAL ) return comparison;
return EQUAL;
}
Ahhh, I just realized that at this point, quotation is actually null since
the quotation hasn't yet
been saved to the database at this point. I probably need to save the
quotation in the database,
return the id and then set the quotation as my Application State Object so
that I can access it in my cart,
and thus avoid the NullPointer exception.
What you think?
-- Izak
On 2/6/06, Stijn Christiaens <[EMAIL PROTECTED]> wrote:
Hello Izak,
could it be that you just have a bug in your compareTo method.
This method is called when you use a TreeMap, but not when you use an
ArrayList.
Try looking at line 196 of QuotationProduct. Your problem should be on
that line.
Ciao,
Stijn
On Mon, 2006-02-06 at 10:54 +0200, Izak Wessels wrote:
java.lang.NullPointerException
Stack Trace:
*
net.pokkie.jupiter.model.quotationproduct.QuotationProduct.compareTo(
QuotationProduct.java:196)
* java.util.TreeMap.compare(TreeMap.java:1093)
* java.util.TreeMap.put(TreeMap.java:465)
* java.util.TreeSet.add(TreeSet.java:210)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]