Event handling betwwen two canvas classes
Hi again!
I have two canvas classes: MainCanvas and SubCanvas.
SunCanvas has keyPressed() method implemented and it's working perfectlly. The only problem is when a certain key is pressed, say Select, I want MainCanvas to be notified.
anybody have an idea?
I tried with CommandListener but I can't work it out. Can i 'active' an event through Cammandlistener maybe?
cheers
Indy
You have two choices here.
The first is like you said using CommandListener. If you add a Command to your SubCanvas, and then set the MainCanvas as the CommandListener, then the MainCanvas gets notified if the command is selected through the commandAction() method:
class SubCanvas extends Canvas {
Command something = new Command("Hi",Command.OK,1);
public SubCanvas(MainCanvas mc) {
addCommand(something);
setCommandListener(mc);
class MainCanvas extends Canvas implements CommandListener {
public void commandAction(Command c, Displayable d) {
}The second option is to keep a reference to the MainCanvas instance in SubCanvas, and use this reference to call your own callback function:
class SubCanvas extends Canvas {
MainCanvas mc
public SubCanvas(MainCanvas mc) {
this.mc = mc
void keyPressed(int keyCode) {
if (keyCode == theKeyThatCallsMainCanvas) {
mc.callbackFunction();
class MainCanvas extends Canvas {
public void callbackFunction() {
}shmoove
Similar Messages
-
Event handling... inner classes or not? what do you recomend?
Me question is should you
use
JButton addbutton=new JButton("Add");
addbutton.addNewActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
or this
class Window implements ActionListener
public void actionPerformed(ActionEvent e)
if (e.getSource()==addbutton)
if (e.getSource()==...
So when I would have say menu and 15 menuitems to listen, I would prefer the innerclass system becauses it somehow produces cleaner code, but it creates pretty much of those $1 $2 files... will it be a problem?I prefer to use inner classes since it makes clean code.
However I prefer to define one innerclass per source
type and not the getSource() trick. This gives a clean
separation of responsability. You can use the same
innerclass for different sources if the reaction should
be the same for different user inputs.you mean something like this:
Button b1=new Button("Edit1");
Button b2=new Button("Edit2");
b1.addActionListener(new InnerClass(b1));
b2.addActionListener(new InnerClass(b2));
... -
2 Displayable objects, 1 event handler object
Hi there,
I'm working on an application using J2ME and the MIDP profile. I was wondering, is it possible to use 1 event handler object for 2 Displayable objects? Lets say I have a list on one screen and a form on another, can I use 1 event handler object to handle the events for these two elements? I am implementing my event handler in another class, and I am trying to use the same event handler for all my screens, but it does not seem to be functioning. Any hints?
Also, is it advisable to implement the event handler in a separate class for a J2ME application? Does it really make any difference design-wise and efficiency-wise?
I would appreciate the insight..
Thanks...I would start with adding debug messages in commandAction and in nextScreen:
// debug messages are within System.out.println, do not forget to remove after fix
public void commandAction(Command s, Displayable x) {
System.out.println("command: [" + s.getLabel() + "] screen: [" + x.getTitle() + "]" );
// ...here starts your code...
public void nextScreen(int x) {
System.out.println("index: [" + x + "]);
System.out.println("screen[0] is not null: [" + (screen[0] != null) + "]" );
System.out.println("screen[0] title: [" + (screen[0].getTitle()) + "]" );
System.out.println("screen[1] is not null: [" + (screen[1] != null) + "]" );
System.out.println("screen[1] title: [" + (screen[1].getTitle()) + "]" );
// ...here starts your code...
{code}
then retry run and check messages shown in WTK console... -
How do I disable an event handler?
The file below contains a canvas and a button on the canvas. There are two event handlers, one for the button and one for the canvas. How to I disable the event handler for the canvas when the button is clicked?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
public function init():void{
canvas.addEventListener(MouseEvent.CLICK, handleClick)
button.addEventListener(MouseEvent.CLICK, handleButtonClick)
public function handleClick(e:Event):void{
trace("Application clicked")
public function handleButtonClick(e:Event):void{
trace("Button clicked")
]]>
</mx:Script>
<mx:Canvas id="canvas" x="108" y="82" width="200" height="200" backgroundColor="0xff0000">
<mx:Button id="button" x="10" y="168" label="Button" mouseChildren="false"/>
</mx:Canvas>
</mx:Application>u can do this when user clicks on any of the canvas or button, just check it currentTarget and then work with ur functions accordingly
-
Event Handler Error while Creating User
Hi,
I am not able to create users in OIM 11gR1 - " Event handler DemoNotificationEventResolver implemented using class/plug-in nrma.DemoNotificationEventResolver could not be loaded."
I have deleted this plugin from the "plugins" table in the database. What else am I supposed to do?Hi,
I have deleted it from the MDS Schema. Now I am getting a different error.
<Dec 20, 2012 5:24:57 PM EST> <Error> <oracle.iam.identity.usermgmt.impl> <IAM-3050030> <An exception occurred while performing the operation.
java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key IAM-301094
at java.util.ResourceBundle.getObject(ResourceBundle.java:374)
at java.util.ResourceBundle.getObject(ResourceBundle.java:371)
at java.util.ResourceBundle.getObject(ResourceBundle.java:371)
at java.util.ResourceBundle.getObject(ResourceBundle.java:371)
at java.util.ResourceBundle.getString(ResourceBundle.java:334)
at oracle.iam.ldapsync.impl.util.LDAPSyncUtil.createValidationFailedException(LDAPSyncUtil.java:700)
at oracle.iam.ldapsync.impl.util.LDAPSyncUtil.generateAndValidateRDN(LDAPSyncUtil.java:824)
at oracle.iam.ldapsync.impl.eventhandlers.user.RDNPreProcessHandler.execute(RDNPreProcessHandler.java:68)
at oracle.iam.platform.kernel.impl.OrchProcessData.runPreProcessEvents(OrchProcessData.java:898)
at oracle.iam.platform.kernel.impl.OrchProcessData.runEvents(OrchProcessData.java:634)
at oracle.iam.platform.kernel.impl.OrchProcessData.executeEvents(OrchProcessData.java:227)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.resumeProcess(OrchestrationEngineImpl.java:664)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.process(OrchestrationEngineImpl.java:435)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:381)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:334)
at oracle.iam.identity.usermgmt.impl.UserManagerImpl.create(UserManagerImpl.java:653)
at oracle.iam.identity.usermgmt.api.UserManagerEJB.createx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) -
Help needed in implementing validation event handler in OIM 11g
Hello experts,
I am trying to set username policy by implementing a validation event handler in OIM 11.1.1.5.
Following are the steps followed
1. Import metadata
Created a file called Eventhandler.xml as below and imported using weblogicImportmetadata.sh
<?xml version='1.0' encoding='UTF-8'?>
<eventhandlers xmlns="http://www.oracle.com/schema/oim/platform/kernel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/schema/oim/platform/kernel orchestration-handlers.xsd">
<validation-handler class="test.iam.eventhandlers.CustomValidationEventHandler" entity-type="User" operation="CREATE" name="CustomValidationEventHandler" order="1000" sync="TRUE"/>
</eventhandlers>
2. Register plugin
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<plugins pluginpoint="oracle.iam.platform.kernel.spi.ValidationHandler">
<plugin pluginclass="test.iam.eventhandlers.CustomValidationEventHandler" version="1.0" name="CustomValidationEventHandler" />
</plugins>
</oimplugins>
Just givng sys out in the below code to check whther it is getting triggerred during user create.
package test.iam.eventhandlers;
import java.util.HashMap;
import oracle.iam.platform.Platform;
import oracle.iam.platform.context.ContextAware;
import oracle.iam.platform.kernel.ValidationException;
import oracle.iam.platform.kernel.ValidationFailedException;
import oracle.iam.platform.kernel.spi.ValidationHandler;
import oracle.iam.platform.kernel.vo.BulkEventResult;
import oracle.iam.platform.kernel.vo.BulkOrchestration;
import oracle.iam.platform.kernel.vo.Orchestration;
public class CustomValidationEventHandler implements ValidationHandler {
@Override
public void initialize(HashMap<String, String> arg0) {
// TODO initialization
System.out.println("init validate event handler");
@Override
public void validate(long processId, long eventId, Orchestration orchestration)
throws ValidationException, ValidationFailedException {
System.out.println("Beginning of validation");
System.out.println("End of validation");
@Override
public void validate(long processId, long eventId, BulkOrchestration arg2)
throws ValidationException, ValidationFailedException {
// TODO - N/A
System.out.println("Bulk Orchestration not yet implemented");
Now when i create a user it is not allowing and i am getting system error in the front end and in the logs i could see something below
<May 28, 2012 3:03:29 PM CEST> <Error> <oracle.iam.identity.usermgmt.impl> <IAM-3050029> <The user cannot be created due to validation errors.
oracle.iam.platform.kernel.ValidationFailedException: Event handler CustomValidationEventHandler implemented using class/plug-test.iam.eventhandlers.CustomValidationEventHandler could not be loaded.
at oracle.iam.platform.kernel.impl.OrchProcessData.runValidationEvents(OrchProcessData.java:177)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.validate(OrchestrationEngineImpl.java:644)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.process(OrchestrationEngineImpl.java:497)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:444)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:378)
at oracle.iam.identity.usermgmt.impl.UserManagerImpl.create(UserManagerImpl.java:656)
at oracle.iam.identity.usermgmt.api.UserManagerEJB.createx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
I have implemented preprocess and postprocess event handler before with similar kind of plugin registration, metadata import and everything worked fine. Not sure what is the problem here with validation event handler.
Thanks
DKInstead of registering the plug-in can u try placing it in the plugins folder under Oracle_IDM1/server folder.
at times restart is required. esp when the server is running in production mode.
Regards
user12841694 -
Event handler for dropdownlistbox how to determine selection ?
Hello,
As a newby in BSP programming, I'm trying to build a small application with a menu structure . This menu is defined in a page fragment and consists of dropdownlistboxes. The event handling is located in the main page which contains the page fragment.
My problem is that I cannot get these dropdownlist boxes to work. The coding in the page fragment is :
==========================
<htmlb:content>
<htmlb:form>
<htmlb:dropdownListBox id = "myDropdownListBox1"
tooltip = "Tooltip for my DropdownListBox"
onClientSelect = "alert('myDropdownListBox1')"
onSelect = "mySelect" >
<htmlb:listBoxItem key = "k1"
value = "MenuChoice1" />
<htmlb:listBoxItem key = "k2"
value = "MenuChoice2" />
<htmlb:listBoxItem key = "k3"
value = "MenuChoice3" />
<htmlb:listBoxItem key = "k4"
value = "MenuChoice4" />
<htmlb:listBoxItem key = "k5"
value = "MenuChoice5" />
<htmlb:listBoxItem key = "k6"
value = "MenuChoice6" />
</htmlb:dropdownListBox>
</htmlb:form>
</htmlb:content>
==========================
The event handler ( OnInputProcessing ) code is :
==========================
CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
DATA: event TYPE REF TO if_htmlb_data,
ddlb_event TYPE REF TO CL_HTMLB_EVENT_SELECTION.
event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
IF event IS NOT INITIAL AND event->event_name =
'dropdownListBox'.
ddlb_event ?= event.
CASE event->event_id.
WHEN 'myDropdownListBox1'.
CASE ddlb_event->selection.
WHEN 'k1'.
.......( Contains other statements )
WHEN 'k2'.
.......( Contains other statements )
WHEN 'k3'.
.......( Contains other statements )
WHEN 'k4'.
.......( Contains other statements )
WHEN 'k5'.
.......( Contains other statements )
WHEN 'k6'.
.......( Contains other statements )
ENDCASE.
ENDCASE.
ENDIF.
==========================
I have tried several different event handlers including the example in the documentation of the dropdownlistbox HTMLB element, but in the event handler I don't know how to determine the selection made.
I would appreciate it hugely if someone could give me an example how to do this ?
With regards,
Fred van de LangenbergHello,
Thanks for your answers & suggestions Subramanian, Ulli & Sebastian.
I forgot the <htmlb:content> tags ( thanks Ulli ) and eventually I got things working with the following :
Main page layout : dopdownlistbox element
<htmlb:dropdownListBox
id = "Ddlb1"
onSelect = "OnInputProcessing" >
selection = "<%= selection1 %>"
<htmlb:listBoxItem key = " "
value = " "/>
<htmlb:listBoxItem key = "k1"
value = "k1" />
<htmlb:listBoxItem key = "k2"
value = "k2" />
<htmlb:listBoxItem key = "k3"
value = "k3" />
<htmlb:listBoxItem key = "k4"
value = "k4" />
<htmlb:listBoxItem key = "k5"
value = "k5" />
</htmlb:dropdownListBox>
Event handler
CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
IF event_id = CL_HTMLB_MANAGER=>EVENT_ID.
Scenario 1: Read event from manager.
DATA: event TYPE REF TO CL_HTMLB_EVENT.
event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
IF event IS NOT INITIAL AND event->name = 'dropdownListBox'.
DATA: data TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX.
data ?= CL_HTMLB_MANAGER=>GET_DATA(
request = runtime->server->request
name = 'dropdownListBox'
id = 'Ddlb1'
CASE data->selection.
WHEN 'k1'.
WHEN 'k2'.
WHEN 'k3'.
WHEN 'k4'.
WHEN 'k5'.
ENDCASE.
ENDIF.
ENDIF.
Fred van de Langenberg -
I would like to know how to handle events for messages i maintained in zmesg01.
messages are follow: when gv_spfli is initial
"No such flight available.
when gv_scarr is initial.
"Flight name not available with help of raise event ?
pls suggest.
* CLASS lcl_mytestclass DEFINITION
class lcl_mytestclass definition.
public section.
data: gt_spfli type table of spfli initial size 20,
gt_scarr type table of scarr initial size 20.
methods: get_data.
events: data_not_found.
endclass. "lcl_mytestclass DEFINITION
* CLASS lcl_mytestclass IMPLEMENTATION
class lcl_mytestclass implementation.
method: get_data.
select * from spfli into table gt_spfli.
if ( sy-subrc <> 0 ).
raise event data_not_found.
endif.
select * from scarr into gt_scarr
for all entries in gt_flight where carrname = gt_spfli-carrname.
if sy-subrc <> 0.
" How to call event for flight_name_not_found ?"
raise event flight_name_not_found.
endmethod. "get_data
endclass. "lcl_mytestclass IMPLEMENTATION
* CLASS handler DEFINITION
class handler definition.
public section.
methods handle_event
for event data_not_found of lcl_mytestclass.
endclass. "handler DEFINITION
* CLASS handler IMPLEMENTATION
class handler implementation.
method handle_event.
write: / 'Data not found'.
endmethod. "handle_excess
endclass. "handler IMPLEMENTATION
data: oref type ref to lcl_mytestclass,
h1 type ref to handler.
start-of-selection.
create object: oref, h1.
set handler h1->handle_event for all instances.
call method oref->get_data.
Thanks in advance.
Anee.Hello Anee
Events are not used for this kind of message handling.
If you want to collect all messages then use a message handler (see sample report ZUS_SDN_ABAP_OO_MSG_HANDLING ).
Alternatively, you may define an exception class and raise a class-based exception which contains the detailed error message.
The following sample report is based on the more elaborate Wiki posting
[Message Handling - Finding the Needle in the Haystack|https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/MessageHandling-FindingtheNeedleintheHaystack]
*& Report ZUS_SDN_ABAP_OO_MSG_HANDLING
*& Thread: Event Handling for messages
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1052131"></a>
REPORT zus_sdn_abap_oo_msg_handling.
TYPE-POOLS: abap.
* CLASS lcl_mytestclass DEFINITION
CLASS lcl_mytestclass DEFINITION.
PUBLIC SECTION.
DATA: gt_spfli TYPE TABLE OF spfli INITIAL SIZE 20,
gt_scarr TYPE TABLE OF scarr INITIAL SIZE 20.
METHODS: constructor.
METHODS: get_data
IMPORTING
value(id_carrid) TYPE s_carr_id.
METHODS: has_messages
RETURNING value(rd_result) TYPE abap_bool.
METHODS: display_messages.
EVENTS: data_not_found.
PROTECTED SECTION.
DATA: mo_msglist TYPE REF TO if_reca_message_list.
ENDCLASS. "lcl_mytestclass DEFINITION
* CLASS lcl_mytestclass IMPLEMENTATION
CLASS lcl_mytestclass IMPLEMENTATION.
METHOD constructor.
me->mo_msglist = cf_reca_message_list=>create( ).
ENDMETHOD. "constructor
METHOD has_messages.
IF ( me->mo_msglist->is_empty( ) = abap_false ).
rd_result = abap_true.
ENDIF.
ENDMETHOD. "has_messages
METHOD display_messages.
* define local data
DATA:
ld_handle TYPE balloghndl,
lt_log_handles TYPE bal_t_logh,
ls_profile TYPE bal_s_prof.
" Get log handle of collected message list
ld_handle = me->mo_msglist->get_handle( ).
APPEND ld_handle TO lt_log_handles.
* get a display profile which describes how to display messages
CALL FUNCTION 'BAL_DSP_PROFILE_DETLEVEL_GET'
IMPORTING
e_s_display_profile = ls_profile. " tree & ALV List
* set report to allow saving of variants
ls_profile-disvariant-report = sy-repid.
* when you use also other ALV lists in your report,
* please specify a handle to distinguish between the display
* variants of these different lists, e.g:
ls_profile-disvariant-handle = 'LOG'.
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
i_s_display_profile = ls_profile
i_t_log_handle = lt_log_handles
* I_T_MSG_HANDLE =
* I_S_LOG_FILTER =
* I_S_MSG_FILTER =
* I_T_LOG_CONTEXT_FILTER =
* I_T_MSG_CONTEXT_FILTER =
* I_AMODAL = ' '
* IMPORTING
* E_S_EXIT_COMMAND =
EXCEPTIONS
profile_inconsistent = 1
internal_error = 2
no_data_available = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMETHOD. "display_messages
METHOD: get_data.
SELECT * FROM spfli INTO TABLE gt_spfli
WHERE ( carrid = id_carrid ).
IF ( sy-subrc NE 0 ).
** RAISE EVENT data_not_found.
IF 1 = 2. MESSAGE e154(bc_datamodel_service). ENDIF.
* Flight not found (table SFLIGHT)
CALL METHOD me->mo_msglist->add
EXPORTING
* is_message =
id_msgty = 'E'
id_msgid = 'BC_DATAMODEL_SERVICE'
id_msgno = '154'
* id_msgv1 =
* id_msgv2 =
* id_msgv3 =
* id_msgv4 =
id_detlevel = '1'
* IMPORTING
* es_message =
ENDIF.
IF ( gt_spfli IS INITIAL ).
ELSE.
SELECT * FROM scarr INTO TABLE gt_scarr
FOR ALL ENTRIES IN gt_spfli
WHERE carrid = gt_spfli-carrid.
ENDIF.
IF ( gt_scarr is initial ).
" How to call event for flight_name_not_found ?"
** RAISE EVENT flight_name_not_found.
IF 1 = 2. MESSAGE e159(bc_datamodel_service) WITH '&all'. ENDIF.
* Airline & not found
CALL METHOD me->mo_msglist->add
EXPORTING
* is_message =
id_msgty = 'E'
id_msgid = 'BC_DATAMODEL_SERVICE'
id_msgno = '159'
id_msgv1 = '&all'
* id_msgv2 =
* id_msgv3 =
* id_msgv4 =
id_detlevel = '2'
* IMPORTING
* es_message =
ENDIF.
ENDMETHOD. "get_data
ENDCLASS. "lcl_mytestclass IMPLEMENTATION
* CLASS handler DEFINITION
CLASS handler DEFINITION.
PUBLIC SECTION.
METHODS handle_event
FOR EVENT data_not_found OF lcl_mytestclass.
ENDCLASS. "handler DEFINITION
* CLASS handler IMPLEMENTATION
CLASS handler IMPLEMENTATION.
METHOD handle_event.
WRITE: / 'Data not found'.
ENDMETHOD. "handle_excess
ENDCLASS. "handler IMPLEMENTATION
DATA: oref TYPE REF TO lcl_mytestclass,
h1 TYPE REF TO handler.
PARAMETER:
p_carrid TYPE s_carr_id DEFAULT 'AA'.
START-OF-SELECTION.
START-OF-SELECTION.
CREATE OBJECT: oref, h1.
** SET HANDLER h1->handle_event FOR ALL INSTANCES.
CALL METHOD oref->get_data( p_carrid ).
IF ( oref->has_messages( ) = abap_true ).
oref->display_messages( ).
ENDIF.
END-OF-SELECTION.
Regards
Uwe -
I am using two event handler
CLASS-METHODS:
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells.
CLASS-METHODS: catch_doubleclick
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_column es_row_no sender.
And after I call them like that
SET HANDLER ci_events_grid->handle_data_changed_finished
FOR ci_grid .
CALL METHOD ci_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
SET HANDLER ci_events_grid->catch_doubleclick FOR ci_grid.
There is a problem that when the changes finish on grid , it can handels handle_data_changed_finished
truely but when the user double click it couldnt gets true row id .
But when I do not use handle_data_changed_finished method there wasnt problem occurs ,
How can I use two methods together ?No I dont catch with user-command
Please below the code method implementations.
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed_finished.
PERFORM data_changed_finished TABLES et_good_cells.
ENDMETHOD. "HANDLE_DATA_CHANGED_FINISHED
METHOD catch_doubleclick .
IF e_column-fieldname NE 'REASON_ICON'.
EXIT.
ENDIF.
READ TABLE gt_itab INDEX es_row_no-row_id INTO gt_ch_itab.
CASE e_column.
WHEN 'REASON_ICON'.
IF gt_ch_itab-changed = 'X'.
CALL SCREEN 200 STARTING AT 40 8
ENDING AT 80 20.
ENDIF.
ENDCASE.
ENDMETHOD. "handle_double_click
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
FORM data_changed_finished TABLES et_good_cells STRUCTURE lvc_s_modi.
DATA ls_good_cells TYPE lvc_s_modi.
LOOP AT et_good_cells INTO ls_good_cells.
AT NEW row_id.
READ TABLE gt_itab INDEX ls_good_cells-row_id.
IF sy-subrc = 0.
IF gt_itab-pwmt1 NE gt_itab-old_pwmt1 OR
gt_itab-pwtt1 NE gt_itab-old_pwtt1 OR
gt_itab-dlvcnt NE gt_itab-old_dlvcnt.
gt_itab-changed = 'X'.
gt_itab-status = icon_led_yellow.
gt_itab-reason_icon = icon_system_help.
ELSE.
CLEAR : gt_itab-changed,gt_itab-status.
ENDIF.
MODIFY gt_itab INDEX ls_good_cells-row_id.
ENDIF.
ENDAT.
ENDLOOP.
CALL METHOD ci_grid->refresh_table_display
EXPORTING
i_soft_refresh = 'X'.
ENDFORM. " data_changed_finished -
Differnence between two codes of event handling
hello i am learning event handling in swing but confused between two codes :-
the first code of event handling is given in book "head first java " and working fine
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Swingdemo implements ActionListener {
JButton jbut = new JButton("Click me");
public void go(){
JFrame jfrm = new JFrame(" sample swing");
JLabel jlab = new JLabel("hello Swing");
jfrm.add(BorderLayout.NORTH,jlab);
jfrm.add(BorderLayout.CENTER,jbut);
jfrm.setVisible(true);
jbut.addActionListener(this);
jfrm.setSize(100,100);
jfrm.setDefaultCloseOperation(jfrm.EXIT_ON_CLOSE);
public static void main(String[] args) {
Swingdemo obj = new Swingdemo();
obj.go();
public void actionPerformed(ActionEvent e)
jbut.setText("i have been clicked");
}}THe second code which i think is fine is giving the following error :-
C:\java\iodemo\src\Swingdemo.java:26: non-static variable jbut cannot be referenced from a static context
jfrm.add(BorderLayout.CENTER,jbut);
C:\java\iodemo\src\Swingdemo.java:28: non-static variable this cannot be referenced from a static context
jbut.addActionListener(this);
C:\java\iodemo\src\Swingdemo.java:28: non-static variable jbut cannot be referenced from a static context
jbut.addActionListener(this); the second code is as follows :-
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Swingdemo implements ActionListener {
public static void main(String[] args) {
JFrame jfrm = new JFrame(" sample swing");
JLabel jlab = new JLabel("hello Swing");
jfrm.add(BorderLayout.NORTH,jlab);
jfrm.add(BorderLayout.CENTER,jbut);
jfrm.setVisible(true);
jbut.addActionListener(this);
jfrm.setSize(100,100);
jfrm.setDefaultCloseOperation(jfrm.EXIT_ON_CLOSE);
JButton jbut = new JButton("Click me");
public void actionPerformed(ActionEvent e)
jbut.setText("i have been clicked");
Plz help me wat this error means that not static variable cannot be reffered from static context .
thanksThere are multiple problems in your 2nd set of code. You call this:
jfrm.add(BorderLayout.CENTER,jbut);
Before you actually create the jbut button:
JButton jbut = new JButton("Click me");
But based on the error message, you have another 'jbut' variable somewhere that's not included in the code you posted, and that's the one it's complaining about being referenced in a static context.
The problem with the static context is because all your code is in the static void main method. In that method, a Swingdemo instance doesn't exist yet, therefore any non-static variables won't exist yet either. If you move all that code into the Swingdemo constructor, and just have main create a new Swingdemo instance, that should do it. -
Facing difficulties in dragdrop event handler while moving images from tilelist to canvas
1) my tile list contains images which are coming from
database.
2) i have to drag and drop those images from tile list to
canvas.
3) In tile list we don't have to write mouseMove event
handler where we can define dragInitiator . (if dragEnabled = true)
4) my dragEnter and dragOver is working properly . Problem is
in dragDrop .
5 ) how can i collect there dragged image
(event.draggedsource.....what must be write)
ERROR : Cannot access a property or method of a null object
referenceimport java.util.Timer;
import java.util.TimerTask;
public class Test {
public static void main (String[] args) {
final Timer timer = new Timer ();
System.out.println ("I'm gonna do something in 5 seconds.");
timer.schedule (new TimerTask () {
public void run () {
System.out.println ("Time's up !");
timer.cancel ();
}, 5000);
}if you want to display the time left it's better to make your own Thread that updates a "timeleft variable:
{code}
public class Test {
//set the time Left to 3 mins.
private long secondsLeft = 3 * 60;
public Test () {
new Thread (new Runnable () {
public void run () {
try {
while (secondsLeft > 0) {
//Let's update the timer every second.
Thread.sleep (1000);
secondsLeft = secondsLeft - 1;
System.out.println ("Time left: " + (secondsLeft / 60) + ":" + (secondsLeft % 60));
System.out.println ("Grats !");
} catch (InterruptedException e) {}
}).start ();
public static void main (String[] args) {
new Test ();
{code} -
Enhance standard class with event handler method
In trying to enhance a standard class with a new event handler class, I find that the ECC 6.0 EHP4 system does not appear to recognise the fact the method is an event handler method. The specific example is a new method to handle the event CL_GUI_ALV_GRID->USER_COMMAND.
I notice that the flag called Active has not been ticked - see image below. Perhaps this is the reason why the event handler is not being triggered.
Note that there is an event handler for the same event in the standard class which obviously is executed as expected. Any ideas on limitations in the system or I am missing a step?
Thanks
JohnThank you for your replies.
There is a bug in the ALV handler of a standard SAP class (when executed in ITS WebGUI) and I was hoping to create a custom event handler as an Enhancement to execute some custom code to sort of "handle the bug".
I agree - ideally it should be done in a Z class but that will not give me access to the object methods and attributes of the enhanced class.
Cheers,
John -
Event handling in seperate class
hello... i have a gui w/ a series of combo boxes, text fields, etc. (call this the GUI file)
upon pressing a button, i need to run a series of event handling that will use info from many of these components
i would like to create a separate java file for the button event handling, but need this file to have access to many componets in the GUI file - does anyone know a nice way to do this?i'm not quite sure how to do that... in my GUI class,
I construct the actuall gui within the constructor..
then i have a simple driver that creates an instance
of class GUI and calls the constructor... how can I
pass a reference of the GUI to the handler in that
scenario??it would be better if you post your code. Some people like me can't just imagine. -
Event handling in global class (abap object)
Hello friends
I have 1 problem regarding events in abap object... how to handel an event in global class in se24 .
Regards
Reema jain.
Message was edited by:
Reema JainHello Reema
The following sample report shows how to handle event in principle (see the § marks)..
The following sample report show customer data ("Header"; KNB1) in the first ALV list and sales areas ("Detail"; KNVV) for the selected customer (event double-click) in the second ALV list.
*& Report ZUS_SDN_TWO_ALV_GRIDS
REPORT zus_sdn_two_alv_grids.
DATA:
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv TYPE STANDARD TABLE OF knvv.
"§1. Define and implement event handler method
" (Here: implemented as static methods of a local class)
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1.
CHECK ( sender = go_grid1 ).
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"§2. Set event handler (after creating the ALV instance)
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1. " Or:
" SET HANDLER: lcl_eventhandler=>handle_double_click FOR all instances.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_cell_bottom
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Display data
gs_layout-grid_title = 'Customers'.
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
is_layout = gs_layout
CHANGING
it_outtab = gt_knb1
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gs_layout-grid_title = 'Customers Details (Sales Areas)'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
is_layout = gs_layout
CHANGING
it_outtab = gt_knvv " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* User has pushed button "Display Details"
WHEN 'DETAIL'.
PERFORM entry_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form ENTRY_SHOW_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM entry_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM knvv INTO TABLE gt_knvv
WHERE kunnr = ls_knb1-kunnr.
ENDFORM. " ENTRY_SHOW_DETAILS
Regards
Uwe -
Event handler doesn't work for a Canvas inside a canvas (Possible bug in Flex 4)
Hi Guys,
I have a canvas sitting inside another canvas. When i try to catch the mouseClick event in the child canvas, im not able to do it. When i change the child canvas component to a 'Panel', the event handler works perfectly fine. Any suggestions/solutions?ok a few things you should know... it is recomended to use the spark components when working with flash builder 4 thought the mx components are available spark is much litghter in weight. also if you want to use the equivalent of a canvas in spark then you want to use a "group" but ill warn you they dont support inline styles, a border container looked more appropiate for what you were trying to do below. However. i did fix your code for flex 4.0
look below.
component:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete ="canvas2_creationCompleteHandler(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
public function canvas1_clickHandler(event:MouseEvent):void
Alert.show("Clicked");
public function canvas2_creationCompleteHandler(event:Event):void
{// TODO Auto-generated method stub//
kenaCan.addEventListener(MouseEvent.CLICK, canvas1_clickHandler);
]]>
</fx:Script>
<mx:Canvas id="kenaCan"
width="400"
height="300"
borderStyle="solid"
borderColor="black"
backgroundColor="white"
/>
</mx:Canvas>
application:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
xmlns:local1="local.*">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<local1:canvas/>
</s:Application>
if this post answers your question please mark it as such thanks
Maybe you are looking for
-
How to replace hard drive in macbook pro?
How to replace hard drive in macbook pro?
-
MP4 Plays Fine in Quicktime, but Audio Lags Near Clip's End in WMP. Huh?
This is weird. I've made several MP4s in Premiere Pro CS6, some only 10 minutes long, and the audio goes a bit out of sync (lagging behind) only in WMP, not Quicktime, when playing the rendered MP4. QT plays it all just fine. Is there something needi
-
Second screen for MacBook Pro with new IOS update?
I have a second screen for my MacBook Pro and after doing the IOS update it does not work. I went to preferences and it does not appear as an available display.
-
I am facing the problem in the Oracle Warehouse Builder(OWB). The following is the error description. Please guide us. Cwm Error Message: SQL Exception Cwm Error: SQL Exception Class Name: CacheMediator Method Name: getDDEntryFromDB Repository Error
-
Buffer Misses On an hourly basis
Can anyone advise on guidelines I should pay attention to when determining if there is to much broadcase traffic in my network? For instance if I am looking at my switch should I see any buffer misses within a one hour time period? Are buffer misses