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...
Similar Messages
-
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 -
Is event handling possible with any object?
can i set a event notification to any object? say for example if i have a multidimensional array of strings can i associate a event handler with it so that when a different application or part of a code changes it's contents i can fire a method?
consider the scenario
initially...
String userId[][]=new String[R][C];
public MyServer()
userId[0][0] = "mr00047";
userId[0][1] = "false";
userId[1][0] = "dider7";
userId[1][1] = "false";
userId[2][0] = "thegreendove";
userId[2][1] = "false";
}now at some point the content of the userId array changes
for(int i=0;i<3;i++)
if(temp.equals(MyServer.userId[0]))
flag=true;
MyServer.userId[i][1]="true"; // I want to fire a method from this point
break;
can any body tell me how can i do it? please help!!!This could help you: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Observable.html
-
Amfphp - flex remote object error event handler
I'm using amfphp and I want it to return an error that the flex remote object error event handler will pick up. At the moment I can get only the result handler to do anything in flex.
Hi,
Try throwing an exception in the remote method. For example,
function inverse($x) {
if (!$x) {
throw new Exception('Division by zero.');
else return 1/$x; -
OIM 11g: Event Handler "Data Object"
Is there any way in the OIM 11g Users event handler model (pre-insert) to get a "data object" type structure of the column names and values which will be inserted into the database (i.e USR_FIRST_NAME = "John"). This would be similar to what the legacy 9.1x event handler model provided via the getDataObject() method.
I know how to get the data from the orchestration parameters, but for our requirements we need the data to be keyed by database column name ("USR_FIRST_NAME") and not field name as in the orchestration params ("First Name").
OIM must do this conversion at some point (field name -> database column name). Can we somehow leverage this same function?
Thanks.You can accomplish through if statements in your event handler to check for the attributes that determine the logic. For example, if your user's last name changes, you can check the orchestration.getParameters() to see if it contains a key for "UserManagerConstants.AttributeName.LAST_NAME.getId()" and if it does, then perform your logic to update the user.
You could also come up with a lookup that can be referenced for these and have your own custom java code that outputs information based on the values in the lookup. Just think creatively and anything is possible.
Or you can get a connection to the database, and have a constants file that translates the metadata names back to database fields and continue to use your existing code.
Lots of options.
-Kevin -
How to duplicate an displayable object?
HI are there any other possible ways to duplicate a
displayable objects like Sprites for example?
I'm using that approach:
var GetInstance:Class =
targetDisplayableObject["constructor"];
var copyOfTargetDisplayableObject:Sprite = new GetInstance();
Thanks
mloncaricHi Venkat ,
Please check the link which gives to details of authorization checks and the procedure to create Authorization Object .
http://help.sap.com/saphelp_nw04s/helpdata/en/52/67167f439b11d1896f0000e8322d00/content.htm
Hope this helps .
Regards,
Ranjita -
Input value given on web page is not getting pickedup in event handler
Hi friends,
I have created one simple page in SE80 with program with flow logic option, in which I would like to show business partner details from BUT000 table with the input of partner number. But the thing is the input value(partner no.)which I am giving on web page is not getting picked up in selection in event handler though I am giving input value it is becoming initial while selecting. What could be the reason?
Below I am mentioning the code which I have written in even handler for OnInputProcessing event.
CASE EVENT_ID.
WHEN 'select'.
NAVIGATION->SET_PARAMETER( 'partner' ).
SELECT * FROM but000 INTO TABLE I_but000 WHERE partner BETWEEN partner AND partner1.
WHEN OTHERS.
ENDCASE.
Thanks in advance,
SteveHi Abhinav,
I tried with the one you posted. But it is giving run time error as shown below.
Note
The following error text was processed in the system CRD : Access via 'NULL' object reference not possible.
The error occurred on the application server crmdev_CRD_00 and in the work process 0 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Method: ONINPUTPROCESSING of program CLO24DDFJW575HVAQVJ89KWHEHC9OCP
Method: %_ONINPUTPROCESSING of program CL_O24DDFJW575HVAQVJ89KWHEHC9OCP
Method: DO_REQUEST of program CL_BSP_PAGE===================CP
Method: ON_REQUEST of program CL_BSP_RUNTIME================CP
Method: IF_HTTP_EXTENSION~HANDLE_REQUEST of program CL_HTTP_EXT_BSP===============CP
Method: EXECUTE_REQUEST_FROM_MEMORY of program CL_HTTP_SERVER================CP
Function: HTTP_DISPATCH_REQUEST of program SAPLHTTP_RUNTIME
Module: %_HTTP_START of program SAPMHTTP
Regards,
Steve -
Swing: when trying to get the values from a JTable inside an event handler
Hi,
I am trying to write a graphical interface to compute the Gauss Elimination procedure for solving linear systems. The class for computing the output of a linear system already works fine on console mode, but I am fighting a little bit to make it work with Swing.
I put two buttons (plus labels) and a JTextField . The buttons have the following role:
One of them gets the value from the JTextField and it will be used to the system dimension. The other should compute the solution. I also added a JTable so that the user can type the values in the screen.
So whenever the user hits the button Dimensiona the program should retrieve the values from the table cells and pass them to a 2D Array. However, the program throws a NullPointerException when I try to
do it. I have put the code for copying this Matrix inside a method and I call it from the inner class event handler.
I would thank you very much for the help.
Daniel V. Gomes
here goes the code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import AdvanceMath.*;
public class MathF2 extends JFrame {
private JTextField ArrayOfFields[];
private JTextField DimOfSis;
private JButton Calcular;
private JButton Ativar;
private JLabel label1;
private JLabel label2;
private Container container;
private int value;
private JTable DataTable;
private double[][] A;
private double[] B;
private boolean dimensionado = false;
private boolean podecalc = false;
public MathF2 (){
super("Math Calcs");
Container container = getContentPane();
container.setLayout( new FlowLayout(FlowLayout.CENTER) );
Calcular = new JButton("Resolver");
Calcular.setEnabled(false);
Ativar = new JButton("Dimensionar");
label1 = new JLabel("Clique no bot�o para resolver o sistema.");
label2 = new JLabel("Qual a ordem do sistema?");
DimOfSis = new JTextField(4);
DimOfSis.setText("0");
JTable DataTable = new JTable(10,10);
container.add(label2);
container.add(DimOfSis);
container.add(Ativar);
container.add(label1);
container.add(Calcular);
container.add(DataTable);
for ( int i = 0; i < 10 ; i ++ ){
for ( int j = 0 ; j < 10 ; j++) {
DataTable.setValueAt("0",i,j);
myHandler handler = new myHandler();
Calcular.addActionListener(handler);
Ativar.addActionListener(handler);
setSize( 500 , 500 );
setVisible( true );
public static void main ( String args[] ){
MathF2 application = new MathF2();
application.addWindowListener(
new WindowAdapter(){
public void windowClosing (WindowEvent event)
System.exit( 0 );
private class myHandler implements ActionListener {
public void actionPerformed ( ActionEvent event ){
if ( event.getSource()== Calcular ) {
if ( event.getSource()== Ativar ) {
//dimensiona a Matriz A
if (dimensionado == false) {
if (DimOfSis.getText()=="0") {
value = 2;
} else {
value = Integer.parseInt(DimOfSis.getText());
dimensionado = true;
Ativar.setEnabled(false);
System.out.println(value);
} else {
Ativar.setEnabled(false);
Calcular.setEnabled(true);
podecalc = true;
try {
InitValores( DataTable, value );
} catch (Exception e) {
System.out.println("Erro ao criar matriz" + e );
private class myHandler2 implements ItemListener {
public void itemStateChanged( ItemEvent event ){
private void InitValores( JTable table, int n ) {
A = new double[n][n];
B = new double[n];
javax.swing.table.TableModel model = table.getModel();
for ( int i = 0 ; i < n ; i++ ){
for (int j = 0 ; j < n ; j++ ){
Object temp1 = model.getValueAt(i,j);
String temp2 = String.valueOf(temp1);
A[i][j] = Double.parseDouble(temp2);What I did is set up a :
// This code will setup a listener for the table to handle a selection
players.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSM = players.getSelectionModel();
rowSM.addListSelectionListener(new Delete_Player_row_Selection(this));
//Class will take the event and call a method inside the Delete_Player object.
class Delete_Player_row_Selection
implements javax.swing.event.ListSelectionListener
Delete_Player adaptee;
Delete_Player_row_Selection (Delete_Player temp)
adaptee = temp;
public void valueChanged (ListSelectionEvent listSelectionEvent)
adaptee.row_Selection(listSelectionEvent);
in the row_Selection function
if(ex.getValueIsAdjusting()) //To remove double selection
return;
ListSelectionModel lsm = (ListSelectionModel) ex.getSource();
if(lsm.isSelectionEmpty())
System.out.println("EMtpy");
else
int selected_row = lsm.getMinSelectionIndex();
ResultSetTableModel model = (ResultSetTableModel) players.getModel();
String name = (String) model.getValueAt(selected_row, 1);
Integer id = (Integer) model.getValueAt(selected_row, 3);
This is how I got info out of a table when the user selected it -
Hello all,
I have a problem with event handling. I have two buttons in my GUI application with the same name.They are instance variables of two different objects of the same class and are put together in the one GUI.And their actionlisteners are registered with the same GUI. How can I differentiate between these two buttons?
To be more eloborate here is a basic definition of my classes
class SystemPanel{
SystemPanel(FTP ftp){ app = ftp};
FTP app;
private JButton b = new JButton("ChgDir");
b.addActionListener(app);
class FTP extends JFrame implements ActionListener{
SystemPanel rem = new SystemPanel(this);
SystemPanel loc = new SystemPanel(this);
FTP(){
add(rem);
add(loc);
pack();
show();
void actionPerformed(ActionEvent evt){
/*HOW WILL I BE ABLE TO KNOW WHICH BUTTON WAS PRESSED AS THEY
BOTH HAVE SAME ID AND getSouce() ?
In this case..it if was from rem or loc ?
} It would be really helpful if anyone could help me in this regard..
Thanks
Hari VigenshHi levi,
Thankx..
I solved the problem ..using same concept but in a different way..
One thing i wanted to make clear is that the two buttons are in the SAME CLASS and i am forming 2 different objects of the SAME class and then putting them in a GUI.THERE IS NO b and C. there is just two instances of b which belong to the SAME CLASS..
So the code
private JButton b = new JButton("ChgDir");
b.setActionCommand ("1");
wont work as both the instances would have the label "ChgDir" and have setActionCommand set to 1!!!!
Actually I have an array of buttons..So I solved the prob by writting a function caled setActionCmdRemote that would just set the action commands of one object of the class differently ..here is the code
public void setActionCommandsRemote()
for(int i = 0 ; i <cmdButtons.length ; i++)
cmdButtons.setActionCommand((cmdButtons[i].getText())+"Rem");
This just adds "rem" to the existing Actioncommand and i check it as folows in my actionperformed method
if(button.getActionCommand().equals("DeleteRem") )
deleteFileRemote();
else if(button.getActionCommand().equals("Delete") )
deleteFileLocal();Anyway thanx a milion for your help..this was my first posting and I was glad to get a prompt reply!!! -
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 -
Can DISABLE preProcess Event Handler add to the Orchestration parameters?
I have a DISABLE pre-process event handler defined on the User object. I need to set the current date on a USR UDF attribute whenever the user is disabled or enabled or created. The CREATE handler works and the date value shows up on the user profile. However, when I try to set this attribute on the pre-process DISABLE or ENABLE event handlers, the new date does not show up. Here is the code I am using in my DISABLE/ENABLE event handler:
Date currentTime = new Date(System.currentTimeMillis());
orchestration.addParameter(USER_STATUS_DATETIME_ATTR_NAME, currentTime);
Where the orchestration object is from the execute() parameter list.
Any ideas as to why this is not working? Is adding to the orchestration not allowed for DISABLE or ENABLE event handlers? I know my handler is getting calls as I am logging the orchestration.getOperation() value.
Thanks for any suggestions.
-Dave
Edited by: user552098 on Nov 12, 2012 1:56 PMWhen you update the field, make sure you are using the field label name, and not the UDF value.
-Kevin -
Can File Based events Handle wildcards in the filename
The question was can file events handle wildcards in the filename? That way, the object scheduled to handle the event can query the file event specifics and process accordingly. The impact is that we will have to create a file event for every event type for every pathway/state. Therefore, in a worst case scenario, if there are 3 event types for every state, i.e., end of day, end of week, and end of month, and there are 50 pathways/states, then there would be 50 *3 or 150 total file events that would have to be entered. If BOE can handle file event wildcarding, then we need only one event.can we do that ???
Edited by: sanfrancisco on Nov 18, 2010 5:20 PMHi
As per my knowledge events will not Handle wildcards in the filename
Regards
Ashwini -
Drop Down List in ALV with Event handler
Hi All ,
I have created an ALV grid with a dropdown as one of the columns. This all works fine, except that I want to be able to react to a change in the value of each line's dropdown the next column values should change according to the user selection in the 1st column .
Is this possible?
As an example, I have a table of records with one column as a dropdown called " Replace Function Module " and in 2nd column i have call function of that Replace Function Module , If a change in " Replace Function Module " should change the call function of in the 2nd column .
I am using these objects lvc_t_drop , lvc_s_drop and the method " set_drop_down_table ",
Please Can any 1 tel me how to do this with any event handler ar any other way !Hi,
You need to use event handler for this. Check if the below link gives some direction.
[http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01]
I guess you should create a method inside which you call the FM using the FM name from the selected cell in ALV.
I have not tried it out, but its worth a try.
Hope this helps!
Regards,
Saumya -
Hi,
Products
OIM 11.1.1.5 BP02
OAM 11.1.1.5
OID 11.1.1.5
Problem
I have written a post-process event handler which fires when a role is assigned to a user. The event handler calls a plugin which uses the UserManager API to generate and change the user's password.
I've tested this by assigning a role to the user via the OIM web console. I can see my log messages indicating that the event handler has fired and that the password has been changed.
However, I expected that when UserManager.changePassword completed, a notification email would then be sent to the user informing them of the new password, but no notification email has been sent.
The email notifications have been set up correctly, because I have changed the same user's password via the OIM web console and successfully received a Reset Password email.
So, my questions are:
1) Am I right in thinking that when you call UserManager.changePassword(), an out-of-the-box ResetPassword email notification should be sent to the user?
2) Has anyone got this working in 11.1.1.5?
Some more detailed info
In my plugin class I'm calling the following from both execute methods (EventResult and BulkEventResult):
char newpasswd[] = new RandomPasswordGeneratorImpl().generatePassword(user);
getUserManager().changePassword(userKey, newpasswd, false, null, true);
logger.info(("Successfully changed password"));
plugin.xml
<oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
<plugin
pluginclass="oracle.iam.PostInsertPlugin"
version="1.0"
name="PostInsertPlugin">
</plugin>
</plugins>
</oimplugins>
$OIM_HOME/server/bin/weblogic.properties
wls_servername = oim_server1
app = OIMMetadata
metadata_from_loc=/home/oracle/eventhandlers
metadata_file=/metadata/roleuser/custom/EventHandlers.xml
/home/oracle/eventhandlers/import/metadata/roleuser/custom/EventHandlers.xml
<?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">
<action-handler
class="oracle.iam.PostInsertPlugin"
entity-type="RoleUser"
operation="CREATE"
name="PostInsertPlugin"
stage="postprocess"
order="1002"
sync="TRUE"/>
</eventhandlers>
There are no errors in the OIM out and diagnostic logs apart from the following which occur at OIM startup:
[2013-01-07T16:29:23.425+00:00] [oim_server1] [ERROR] [IAM-0080075] [oracle.iam.platform.kernel.impl] [tid: [ACTIVE].ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: oiminternal] [ecid: 2e903d7ef060ab65:66b2de91:13c15d6d9ce:-8000-0000000000000002,0] [APP: oim#11.1.1.3.0] XML schema validation failed for XML /metadata/iam-features-OIMMigration/EventHandlers.xml and it will not be loaded by kernel.
[2013-01-07T16:29:24.267+00:00] [oim_server1] [ERROR] [IAM-0080075] [oracle.iam.platform.kernel.impl] [tid: [ACTIVE].ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: oiminternal] [ecid: 2e903d7ef060ab65:66b2de91:13c15d6d9ce:-8000-0000000000000002,0] [APP: oim#11.1.1.3.0] XML schema validation failed for XML /metadata/iam-features-callbacks/event_configuration/EventHandlers.xml and it will not be loaded by kernel.
Thanks
dty
Edited by: oim_user on Jan 7, 2013 5:37 PMNo notification will be sent if you changepassword using the method from usermanager api.
You have to trigger the resetpassword event manullay in your code.
Here is a sample code to create an event for reset password. Once you create event, invoke it from notification service - notify method.
NotificationEvent event = new NotificationEvent();
String[] receiverUserIds= {userLogin};
event.setUserIds(receiverUserIds);
event.setTemplateName("ResetPasswordNotification");
event.setSender(null);
HashMap<String, Object> resolvedData = new HashMap<String, Object>();
resolvedData.put("userLoginId", userLogin);
event.setParams(resolvedData); -
I am trying to build a proof of concept where a WPF form is hosted in a seperate runspace and updates are handled from the primary shell/runspace. I have had some success thanks to a great article by Boe Prox, but I am having an issue I wanted to open up
to see if anyone had a suggestion.
My goals are as follows:
1.) Set control properties from the primary runspace (Completed)
2.) Get control properties from the primary runspace (Completed)
3.) Respond to WPF form events in the UI runspace from the primary runspace (Kind of broken).
I have the ability to read/write values to the form, but I am having difficulty with events. Specifically, I can fire and handle events, but the minute I try to reference the $SyncHash from within the event it appears to cause a blocking condition hanging both
runspaces. As a result, I am unable to update the form based on an event being fired by a control.
In the example below, the form is loaded and the following steps occur:
1.) Update-Combobox is called and it populates the combobox with a list of service names and selects the first item.
2.) update-textbox is called and sets the Text property of the textbox.
3.) The Text value of the textbox is read by the function read-textbox and output using write-host.
4.) An event handle is registered for the SelectionChanged event for the combobox to call the update-textbox function used earlier.
5.) If you change the selection on the combobox, the shell and UI hangs as soon as $SyncHash is referenced. I suspect this is causing some sort of blocking condition from multiple threads trying to access the synchronized nature of the hash table, but I am
unsure as to why / how to work around it. If you comment out the line "$SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})" within update-textbox the event handler will execute/complete.
$UI_JobScript =
try{
Function New-Form ([XML]$XAML_Form){
$XML_Node_Reader=(New-Object System.Xml.XmlNodeReader $XAML_Form)
[Windows.Markup.XamlReader]::Load($XML_Node_Reader)
try{
Add-Type –AssemblyName PresentationFramework
Add-Type –AssemblyName PresentationCore
Add-Type –AssemblyName WindowsBase
catch{
Throw "Unable to load the requisite Windows Presentation Foundation assemblies. Please verify that the .NET Framework 3.5 Service Pack 1 or later is installed on this system."
$Form = New-Form -XAML_Form $SyncHash.XAML_Form
$SyncHash.Form = $Form
$SyncHash.CMB_Services = $SyncHash.Form.FindName("CMB_Services")
$SyncHash.TXT_Output = $SyncHash.Form.FindName("TXT_Output")
$SyncHash.Form.ShowDialog() | Out-Null
$SyncHash.Error = $Error
catch{
write-host $_.Exception.Message
#End UI_JobScript
#Begin Main
add-type -AssemblyName WindowsBase
[XML]$XAML_Form = @"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.Resources>
<DataTemplate x:Key="DTMPL_Name">
<TextBlock Text="{Binding Path=Name}" />
</DataTemplate>
</Window.Resources>
<DockPanel LastChildFill="True">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<Label Name="LBL_Services" Content="Services:" />
<ComboBox Name="CMB_Services" ItemTemplate="{StaticResource DTMPL_Name}"/>
</StackPanel>
<TextBox Name="TXT_Output"/>
</DockPanel>
</Window>
$SyncHash = [hashtable]::Synchronized(@{})
$SyncHash.Add("XAML_Form",$XAML_Form)
$SyncHash.Add("InitialScript", $InitialScript)
$Normal = [System.Windows.Threading.DispatcherPriority]::Normal
$UI_Runspace =[RunspaceFactory]::CreateRunspace()
$UI_Runspace.ApartmentState = [System.Threading.ApartmentState]::STA
$UI_Runspace.ThreadOptions = [System.Management.Automation.Runspaces.PSThreadOptions]::ReuseThread
$UI_Runspace.Open()
$UI_Runspace.SessionStateProxy.SetVariable("SyncHash",$SyncHash)
$UI_Pipeline = [PowerShell]::Create()
$UI_Pipeline.Runspace=$UI_Runspace
$UI_Pipeline.AddScript($UI_JobScript) | out-Null
$Job = $UI_Pipeline.BeginInvoke()
$SyncHash.ServiceList = get-service | select name, status | Sort-Object -Property Name
Function Update-Combobox{
write-host "`nBegin Update-Combobox [$(get-date)]"
$SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.ItemsSource = $SyncHash.ServiceList})
$SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.SelectedIndex = 0})
write-host "`End Update-Combobox [$(get-date)]"
Function Update-Textbox([string]$Value){
write-host "`nBegin Update-Textbox [$(get-date)]"
$SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})
write-host "End Update-Textbox [$(get-date)]"
Function Read-Textbox(){
write-host "`nBegin Read-Textbox [$(get-date)]"
$SyncHash.TXT_Output.Dispatcher.Invoke($Normal,[action]{$Global:Return = $SyncHash.TXT_Output.Text})
$Global:Return
remove-variable -Name Return -scope Global
write-host "End Read-Textbox [$(get-date)]"
#Give the form some time to load in the other runspace
$MaxWaitCycles = 5
while (($SyncHash.Form.IsInitialized -eq $Null)-and ($MaxWaitCycles -gt 0)){
Start-Sleep -Milliseconds 200
$MaxWaitCycles--
Update-ComboBox
Update-Textbox -Value $("Initial Load: $(get-date)")
Write-Host "Value Read From Textbox: $(Read-TextBox)"
Register-ObjectEvent -InputObject $SyncHash.CMB_Services -EventName SelectionChanged -SourceIdentifier "CMB_Services.SelectionChanged" -action {Update-Textbox -Value $("From Selection Changed Event: $(get-date)")}Thanks again for the responses. This may not be possible, but I thought I would throw it out there. I appreciate your help in looking into this.
To clarify the "Respond to control events in the main runspace"... I'm would like to have an event generated by a form object in the UI runspace (ex: combo box selectionchanged event) trigger a delegate within the main runspace and have that delegate in
the main runspace update the form in the UI runspace.
ex:
1.) User changes selection on combo box generating form event
2.) Event calls delegate (which I have gotten to work)
3.) Delegate does some basic processing (works)
4.) Delegate attempts to update form in UI runspace (hangs)
As to the delegates / which runspace they are running in. I see the $synchash variable if I run get-var within a delegate, but I do not see the $Form variable so I am assuming that they are in the main runspace. Do you agree with that assumption?
Maybe you are looking for
-
Hello. We have a specific client (among many others) whose Outlook 2010 is working in cached exchange mode.This client while connecting to an intranet exchange infrastructure is getting synchronization errors in the form of: 80040109-50A-80040109-560
-
What to do when signing in after installing on an new computer when I get error message 400?
I have insatlled my Photoshop Elements and Premiere Elements on my new computer. When trying to sign in to the program, I get the following message: "Photoshop.com services are currently unavailable. Please try again later or check your network con
-
Hi all, I want to pass a parameter value as a column name in my where clause, like this: where table.(:parameter1)=:parameter2can this be done?? Thanks, Magnus
-
Boots up, powers down in a few seconds...HELP!!!
Hi, My iPod sounds like it's booting up for about 4 seconds, then it just cuts off. I see nothing on the display. HELP ME. It's a 3rd Gen 20GB with the touch wheel.
-
CAN YOU VECTORIZE IN PHOTOSHOP OR ISIT BETTER TO JUST DO IT WITH ILLUSTRATOR
CAN YOU VECTORIZE IN PHOTOSHOP OR ISIT BETTER TO JUST DO IT WITH ILLUSTRATOR