IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Forms Oracle Discussion :

[Forms-PJC]Les events en dehors de mon wrapper


Sujet :

Forms Oracle

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut [Forms-PJC]Les events en dehors de mon wrapper
    Bonjour,

    Comment executer les evenements java avec les pjc ?

    Mon package contient 2 classes java

    Ma classe java à manipuler qui contient les méthodes, variables, actionlisteners
    Mon wrapper, contion les ID, les set, get, dispathevent et une instance de ma classe java.

    Normalement pour executer un evenement dans les pjc j'utilise la méthode suivante contenue dans mon Wrapper:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
      private static final ID MOUSEDOWN = ID.registerProperty("MOUSE_DOWN");       
      ...
     
      public void dispatch_event( ID id )
      {
          CustomEvent ce = new CustomEvent(mHandler, id);
          dispatchCustomEvent(ce);
      }
      ...
     
      dispatch_event( MOUSEDOWN )
    Ma question est comment faire cette operation en dehors du wrapper. C'est à dire dans la classe que je vais instancier.
    Le problèmre est que dans ce cas on ne déclare pas les ID et mHandler, donc comment faire ?

    merci

  2. #2
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Qu'est-ce qui vous empêche d'appeler une fonction de la classe A (wrapper) depuis une classe B ?
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  3. #3
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut
    C'est çà le problème, je désire appeler dispatch_event.

    Comment le feriez-vous ?

  4. #4
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    N'appelez pas directement dispatch_event. placez-la dans une fonction de la classe wrapper et appelez cette fonction.
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  5. #5
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut
    J'ai remis tous le code dans le wrapper a présent.

    Je reçoit un problème lors du dispatching de l'evenenement.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
     
    Exception occurred during event dispatching:
     
    java.lang.IllegalArgumentException: null source
     
    	at java.util.EventObject.<init>(Unknown Source)
     
    	at oracle.forms.ui.CustomEvent.<init>(Unknown Source)
     
    	at cadtest20060320.CADViewerWrapper6.dispatch_event(CADViewerWrapper6.java:276)
     
    	at cadtest20060320.CADViewerWrapper6.HandleEventFromRemote(CADViewerWrapper6.java:299)
     
    	at com.cadviewer.ViewerCanvas_core.handleEvent(ViewerCanvas_core.java:2398)
     
    	at java.awt.Component.postEvent(Unknown Source)
     
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
     
    	at java.awt.Component.dispatchEvent(Unknown Source)
     
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
     
    	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
     
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     
    	at java.awt.EventDispatchThread.run(Unknown Source)
    Il me semble que je fait bien les choses.

  6. #6
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Citation Envoyé par patmaba
    Il me semble que je fait bien les choses.
    Pas vraiment. Ce n'est pas la première fois que je vous demande de fournir un peu plus de matériel. Vous semblez toujours persuadé que l'on va "deviner" le code qui génère vos erreurs.
    ça devient fatiguant...
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  7. #7
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut
    Le code source complet du code java est le suivant :

    L'endroit ou le problème à lieu est lors de l'appel à dispatch_event par
    public void HandleEventFromRemote.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
     
    package cadtest20060320;
     
    import sun.misc.BASE64Encoder;
    import sun.misc.BASE64Decoder;
    import javax.swing.*;
    import java.awt.FileDialog;
    import java.awt.Frame;
    import java.awt.Button;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.BufferedInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.util.zip.*;
    import java.util.StringTokenizer;
    import java.io.*;
    import java.beans.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.net.*;
     
    import javax.swing.filechooser.*;
     
    import oracle.forms.ui.VBean;
    import oracle.forms.ui.CustomEvent;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
     
    import oracle.ewt.meter.ProgressBar;
    import oracle.ewt.meter.BoundedRangeModelImpl;
    import oracle.ewt.thread.TaskScheduler;
    import oracle.ewt.thread.Task;
    import oracle.ewt.thread.TaskEvent;
    import java.beans.PropertyChangeSupport;
     
    import com.cadviewer.*;
     
     
     
     
    public class CADViewerWrapper6 extends VBean 
    	implements RemoteListener
    {
     
    	private static final ID time  = ID.registerProperty   ("time");
    	private static final ID value = ID.registerProperty   ("val");
    	public static final  ID changeEvent = ID.registerProperty ("CHANGE");
     
    	public static final  ID setinit = ID.registerProperty ("INIT");			
    	public static final  ID setcodebase = ID.registerProperty ("SETCODEBASE");				
     
        public static final  ID getmousex = ID.registerProperty ("GETMOUSEX");
    	public static final  ID getmousey = ID.registerProperty ("GETMOUSEY");
     
    	private int vx,vy,vw,vh;
    	public static final  ID setviewx = ID.registerProperty ("SETVIEWX");
    	public static final  ID setviewy = ID.registerProperty ("SETVIEWY");
        public static final  ID setviewwidth  = ID.registerProperty ("SETVIEWWIDTH");
    	public static final  ID setviewheight = ID.registerProperty ("SETVIEWHEIGHT");	
    	public static final  ID centerview = ID.registerProperty ("CENTERVIEW");
     
        public static final  ID getviewwidth  = ID.registerProperty ("GETVIEWWIDTH");
    	public static final  ID getviewheight = ID.registerProperty ("GETVIEWHEIGHT");
     
        protected static final ID MOUSEDOWN = ID.registerProperty("MOUSE_DOWN");        
     
    	static IHandler mHandler;
    	private Component mComp;
     
        ViewerAWT cadv=null;
     
        private String thecodebasedir = "D:\\CV_AWT_SNCB2006_03_15\\";
        private Container contentpane ;
     
     
     
    	public void init(IHandler handler) {
    		try {		
      			System.out.println("__START CadWrapper public void init");
            	// InfoSystem();
      			System.out.println("  super.init(handler)");
      			super.init(handler);  			
            	System.out.println("  mHandler = handler");
      			mHandler = handler;  		  		  			
      			System.out.println("__END CadWrapper public void init");
      		}
    		catch (Exception e) {
    			System.out.println("__EXCEPTION CadWrapper public void init");
      			e.printStackTrace();
      		}  		 
     
      	}
     
     
     
     
     
    	public CADViewerWrapper6() {
     
     
     
    		super();
            contentpane = this ;		        
     
        	try {
     
        	   Msg("_____START CADViewerWrapper6() constructor_____");
     
               InitViewer("D:\\CV_AWT_SNCB2006_03_15\\",		   				 
    		   				 "file:///d:/acad_B/es/cat/STIP/Extract/410009.dwf");		
     
    		   this.add(cadv.GetViewerPanel());
    		   this.setVisible(true);
    		   this.setEnabled(true);
     
    		   Msg("_____END CADViewerWrapper6() constructor_____");     	   		   
     
    		}
    		catch (Exception e) {
      			e.printStackTrace();
      		}  		 
    }
     
     
     
     
     
    	//set the delay time for the timer
      	public boolean setProperty(ID pid, Object value) {
    		try {			
    			if ( value != null ) {			
    				if ( pid  == setcodebase ) {
    					thecodebasedir = String.valueOf(value);
    					System.out.println("thecodebasedir="+thecodebasedir);
    					return true;
    				}								
     
    			    if ( pid  == setinit ) {
      				   System.out.println("setProperty pid  == setinit ");			    	
    				   String cad_file = String.valueOf(value); 
    				   return true;
    			    }											
     
    				if ( pid  == setviewx ) {					
    					vx = ((Integer)value).intValue();
    					return true;
    				}								
    				if ( pid  == setviewy ) {					
    					vy = ((Integer)value).intValue();
    					return true;
    				}								
    				if ( pid  == setviewwidth ) {					
    					vw = ((Integer)value).intValue();
    					return true;
    				}								
    				if ( pid  == setviewheight ) {					
    					vh = ((Integer)value).intValue();
    					return true;
    				}											    
    			}							
     
      		    if ( pid  == centerview ) {					  		         		    
    			   cadv.centerViewOn_DWG( vx, vy, vw, vh );			   
    			   return true;
    			}								
     
    		}
    		catch( Exception e ) {
    			System.out.println("Exception dans setProperty : " + e);
    		}
     
     
    		return super.setProperty(pid, value);
      	}
     
     
     
     
     
     
     
     
     
    	//if the value change, send a msg
      	public Object getProperty(ID pid) {		
        	try {    		  	    
     
     			if (pid==getmousex) {
                	String val;
                	val = Double.toString(cadv.getUnitsX());
                	return val;
       			}
     
     			if (pid==getmousey) {
                	String val;
                	val = Double.toString(cadv.getUnitsY());
                	return val;
       			}
     
     			if (pid==getviewwidth) {
                	String val;
                	val = Integer.toString(cadv.getViewWidth());
                	return val;
       			}
     
     			if (pid==getviewheight) {
                	String val;
                	val = Integer.toString(cadv.getViewHeight());
                	return val;
       			}
     
     
       			return "";   				
        	}
        	catch( Exception e ) {
        		e.printStackTrace();
        		return null;
        	}   		
    	}
     
        public void Msg( String s ) {
        	System.out.println(s);
        }
     
     
     
     
    	public void InitViewer(String codebase, String pFile ) {	
    		try
    		{
                cadv = new ViewerAWT(codebase);
     
                URL url = new URL(pFile);
     
                byte[] arr = cadv.getData(url);            
                cadv.OpenFile(arr);
     
                Panel p = new Panel();
     
                setSize(1000,500);
    			cadv.addActionListener((RemoteListener)this);
     
    			/*
        			Get Viewer AWT Panel
    			*/
                p = cadv.GetViewerPanel();
                add(p,BorderLayout.CENTER);
     
     
    		}
    		catch(Exception io)
    		{
    			//new MessagePanel(viewerControls.GetMessage("ERROR"),viewerControls.GetMessage("Cannot create parser")+": "+io.toString());
    		}
    	}
     
     
     /**
       * Send a message to the Forms module
       **/
      public void dispatch_event( ID id )
      {
          CustomEvent ce = new CustomEvent(mHandler, id);
          dispatchCustomEvent(ce);
      }
     
     
      public boolean PaintFromComponet() {return true;}; 
     
      public void doPaint(WidgetGraphics wg,int xMin,double constX,int uMin,int yMin,double constY,int vMin, int maxY)
       { System.out.println("do nothing"); }
     
       public void HandleEventFromRemote(java.awt.Event evt)
       {
    	   if(evt.id == evt.MOUSE_DOWN)
    	   {
    			if ( evt.clickCount == 2) {
    		   		System.out.println("mouse pressed");
    		   		System.out.println("Screen coord x="+evt.x+",y="+evt.y);
    		   		System.out.println("Drawing coord x="+cadv.getX()+",y="+cadv.getY());		                  
                    System.out.println("last x="+cadv.getUnitsX()+",y="+cadv.getUnitsY());                  
                    System.out.println("ViewWidth="+cadv.getViewWidth());
                    System.out.println("ViewHeight="+cadv.getViewHeight());              
                    System.out.println("______________________________________________");              
     
               		dispatch_event(MOUSEDOWN);
               	}
    	   }
       }
     
    }

  8. #8
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    et l'appel de la fonction ?
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  9. #9
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut
    Ben c'est HandleEventFromRemote qui appel dispatch_event.

    HandleEventFromRemote est une fonction géré par RemoteListener.

    Le bean est un implements de RemoteListener

    Et à chaque fois que mon composant à des evenenement. Ici dans mon exemple c'est un click souris. Ensuite, je teste si c'est un double click et à ce moment je fait le dispatch_event pour que forms reçoit l'event MOUSEDOWN.

  10. #10
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut
    en debugguant j'ai vu que c'est la variable mHandler qui est null.

    Comment l'initialiser ?

  11. #11
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Et si vous déclarez la variable de la sorte ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      public IHandler  m_handler;
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  12. #12
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut
    je viens de comprendre pourquoi ma variable m_handler est null et pourtant elle est bie nspécifié dans init.

    Dans ma java console, j'ai regardé les messages. la fonction init( handler ) qui initialise mhandler n'est j'amais appelé par forms.

    Je me suis dit comment est-ce possible alors que cela est initilasé par VBean.

    La réponse est que mon composant java dans forms en enregistré en when new form instance par la méthode fbean.register. Cela signifie que mon champs forms
    beanarea n'a pas l'iimplementation class définit dés le départ.

    Lorsque l'implementation class est définit dés l'originie, alors forms passe par Init( Handler ) du wrapper java class.

    Par contre lorsque c'est le mode fbean.register il ne passe jamais par la méthode Init.

    En utilisant la dernière méthode, comment initialiser le mhandler ? En effet, il est nécessaire d'avoir sa valeur pour le dispatch d'event par CustomEvent.

    Ou alors est-il possible de faire un dispatch d'event vers forms sans avoir un Handler définit ?

  13. #13
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Bonne question qu'il faudrait poser sur Metalink ou sur le forum Forms d'OTN.
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  14. #14
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201
    Par défaut
    je vous tiendrait au courant, en donnant une réponse à ce post.

    D'ici à quand, je ne sais pas vous le dire.

Discussions similaires

  1. Mouse events sur Form, à travers les contrôles
    Par Jeterh dans le forum Windows Forms
    Réponses: 2
    Dernier message: 02/11/2012, 18h52
  2. Réponses: 3
    Dernier message: 09/09/2009, 14h00
  3. Les events de mon UserControl ne marche pas
    Par obitskater dans le forum ASP.NET
    Réponses: 22
    Dernier message: 03/06/2008, 11h13
  4. Récupérer variables d'1 <form> et les utiliser dans X
    Par honeyz dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 20/04/2006, 11h39
  5. Capturer les event de ma souris en dehors de mon appl
    Par bpy1401 dans le forum AWT/Swing
    Réponses: 1
    Dernier message: 28/07/2005, 16h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo