You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Worrell, Bryan A." <bw...@mitre.org> on 2008/06/04 21:28:32 UTC

XMLBeans Events

Hi,

I have recently read an article on the IBM developerWorks website
(http://www.ibm.com/developerworks/library/x-xmlbeanse/index.html )
that describes how to use interface extensions to utilize events within
XMLBeans.  I am able to register event listeners, fire events, and do
everything else they describe in the article but I am having a problem
where I set one XmlObject to another through use of the
XmlObject::set(XmlObject arg) method which does not execute my preSet()
and postSet() methods.

This is an example using the PurchaseOrderDocument example found on the
XMLBeans tutorial page: 

public static void main(String[] args){
  PurchaseOrder po_one =
PurchaseOrderDocument.PurchaseOrder.Factory.newInstance();
    
  po_one.addModelChangeListener(new IModelChangeListener(){ 
    public void modelChange(ModelChangeEvent evt){
      System.err.println("EVENT");
    }
  });
    
  PurchaseOrder po_two =
PurchaseOrderDocument.PurchaseOrder.Factory.newInstance();
  
  po_one.addNewCustomer(); // prints "EVENT" on stderr
  po_one.set(po_two);	   // does not print anything
  po_one.addNewCustomer(); // prints "EVENT" on stderr
}


I am using an extremely stripped down version of the code on the IBM's
website for the static implementation files so that my preSet and
postSet methods basically do this:

public static boolean preSet(...){
  return true;
}


public static void postSet(XmlObject xo, ...){
  ((IModelChangeListener)xo).fireModelChangeEvent(new
ModelChangeEvent(...));
  
  return;
}


Is this happening because po_one.set(po_two) isn't really changing
anything about po_one except what it's pointing to in memory?


Thank you,
Bryan Worrell

__
Bryan Worrell    
The MITRE Corporation
bworrell@mitre.org 





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: XMLBeans Events

Posted by Cezar Andrei <ce...@bea.com>.
The events are triggered only when calling the methods that we generate
specific for that type, there are no events generated for any of the
XmlComplexContentImpl methods or its baseclasses (XmlComplexContentImpl
is the class that almost all generated classes inherit from). 

Cezar

> -----Original Message-----
> From: Worrell, Bryan A. [mailto:bworrell@mitre.org]
> Sent: Wednesday, June 04, 2008 2:29 PM
> To: user@xmlbeans.apache.org
> Subject: XMLBeans Events
> 
> Hi,
> 
> I have recently read an article on the IBM developerWorks website
> (http://www.ibm.com/developerworks/library/x-xmlbeanse/index.html )
> that describes how to use interface extensions to utilize events
within
> XMLBeans.  I am able to register event listeners, fire events, and do
> everything else they describe in the article but I am having a problem
> where I set one XmlObject to another through use of the
> XmlObject::set(XmlObject arg) method which does not execute my
preSet()
> and postSet() methods.
> 
> This is an example using the PurchaseOrderDocument example found on
the
> XMLBeans tutorial page:
> 
> public static void main(String[] args){
>   PurchaseOrder po_one =
> PurchaseOrderDocument.PurchaseOrder.Factory.newInstance();
> 
>   po_one.addModelChangeListener(new IModelChangeListener(){
>     public void modelChange(ModelChangeEvent evt){
>       System.err.println("EVENT");
>     }
>   });
> 
>   PurchaseOrder po_two =
> PurchaseOrderDocument.PurchaseOrder.Factory.newInstance();
> 
>   po_one.addNewCustomer(); // prints "EVENT" on stderr
>   po_one.set(po_two);	   // does not print anything
>   po_one.addNewCustomer(); // prints "EVENT" on stderr
> }
> 
> 
> I am using an extremely stripped down version of the code on the IBM's
> website for the static implementation files so that my preSet and
> postSet methods basically do this:
> 
> public static boolean preSet(...){
>   return true;
> }
> 
> 
> public static void postSet(XmlObject xo, ...){
>   ((IModelChangeListener)xo).fireModelChangeEvent(new
> ModelChangeEvent(...));
> 
>   return;
> }
> 
> 
> Is this happening because po_one.set(po_two) isn't really changing
> anything about po_one except what it's pointing to in memory?
> 
> 
> Thank you,
> Bryan Worrell
> 
> __
> Bryan Worrell
> The MITRE Corporation
> bworrell@mitre.org
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org


Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org