Article View: borland.public.jbuilder.java.language
Article #7286Re: firing a property veto exception
From: Torsten Welches
Date: Sat, 30 Jun 2001 09:51
Date: Sat, 30 Jun 2001 09:51
29 lines
1855 bytes
1855 bytes
dnoyeB > schrieb in Nachricht <3b3cee8f$1_2@dnews>...
>When I fire a property veto exception it requires a property change object
>within it.
>
>Now since this change is vetoed, should oldvalue and newvalue both be
>oldvalue?? since I really am not setting the newvalue?
you don't create a new PropertyChangeEvent, rather you throw a
PropertyVetoException inside a vetoableChange method of a
VetoableChangeListener implementation. You get the PropertyChangeEvent as a
parameter, inspect the property change and fire a PropertyVetoException if
you are not happy with the change. You send the original PropertyChangeEvent
with your exception.
Here's some pseudo code (I have no JDK available at the moment, so don't
mind any syntax errors):
class SomeClass implements VetoableChangeListener {
...
public void vetoableChange(PropertyChangeEvent pce) {
if (!pce.getNewValue().isWhatYouHadExpected()) {
throw new PropertyVetoException("I don't like this new value",
pce);
}
}
...
}
Torsten
Technical Details
Message-ID:
<3b3da103_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3b3cee8f$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,e79ac2a4b52682c7 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-06-30 02:57:03 PST From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de> Newsgroups: borland.public.jbuilder.java.language References: <3b3cee8f$1_2@dnews> Subject: Re: firing a property veto exception Date: Sat, 30 Jun 2001 11:51:19 +0200 Lines: 33 X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 NNTP-Posting-Host: 195.14.233.153 Message-ID: <3b3da103_1@dnews> X-Trace: dnews 993894659 195.14.233.153 (30 Jun 2001 02:50:59 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews