Raising exceptions in event handlers?
Hi
Is it possible to raise exceptions in event handler? As an example, I added a listener to a UnitOfWork, and implemented the preCommitUnitOfWork() method. In the method, I'm performing some operations, and if something goes wrong, I need to roll back the entire UnitOfWork. Is this possible to raison an exception, or is there some other way to acheive this?
Thanks
Regards
Eric
Hi
Is it possible to raise exceptions in event handler? As an example, I added a listener to a UnitOfWork, and implemented the preCommitUnitOfWork() method. In the method, I'm performing some operations, and if something goes wrong, I need to roll back the entire UnitOfWork. Is this possible to raison an exception, or is there some other way to acheive this?Eric,
I tried this and had some success with a simple test case. I created an exception that extends the oracle.toplink.exceptions.TopLinkException class. Then I added the throws clause to the preCommitUnitOfWork event handler. Throwing my custom exception (that extends TopLinkException) from the event handler works fine and should allow you to retry your update, etc. Note that as long as the exception is thrown at "preCommit" time you should not need to roll anything back as the updates were not applied to the cache or DB. Also, if you applied updates to your registered clones instead of the original objects, the original objects state should be unchanged.
Hope this helps,
Pete Farkas
Similar Messages
-
Proxies , Event handlers and exceptions
Hi All,
I am using an inbound proxy to communicate with CRM system via XI.
I have to raise event handlers and exception catch using Try,,.. Catch OOps concept in the Proxy. Could anyone have some examples of similar kind of scenarios mentioning step by step. I am expecting a scenario and source code.
thanks
DenoHI,
Please look at this thread on error handling:
http://help.sap.com/saphelp_nw04/helpdata/en/25/a45c3cff8ca92be10000000a114084/content.htm
Regards
Vijaya -
Re: Raising Exceptions Vs returning erro[Ref:C809787]
Hi Steve !
Probably the following explanation might help in resolving the issue raised by
you:
At a more abstract level, there is only one thing, i.e. the EVENT. According to
it's definition, an event is a relatively infrequent occurrence in one portion (lets
call it event raiser) of the application, which some other portion (or portions,
lets call them event handlers) (of the same application) are interested to respond
to it. Now there are two scenarios:
(A) Event raiser and Event handler(s) are being executed under different threads
of control (Asynchronous) and
(B) Event raiser and Event Handler(s) are being executed under same thread of
control (Synchronous).
So, Exception Handling belongs to scenario B where the method raising the
exception (Event Raiser or exception raiser) and the method handling it (Event
Handler or exception block) are under the same thread of control. More ever it has
to be insured that at a time only one handler (first the inner most one) receives
the message.
Forté provides a generic Event handling mechanism (Post Event and Event Loop) to
handle the scenario A (which is the more generic one). But it also provides a
specialized Event Handling mechanism (Raise Exception and Exception block) to
efficiently handle the relatively simple scenario B. Why I am saying that the later
is efficient because it won't be needing to register the event queue address of the
interested task (after all there is only one task involved) and put the event
message in queue.
Finally let me mentioned that it is just my view based on the understanding I
have and it may not be true. Only a person from forté can confirm it. I will really
appreciate if somebody correct and or refine it.
Wish a Very Very Happy New Year to all Forté Users
Regard,
Kailash.
[email protected] wrote:
I would agree with Eric entirely. Exceptions seem to me to be a much more
complete solution to the problem of error handling. A little bit of effort up
front in making clear the strategy for exception handling and specifying the
exceptions that can be raised by a class\method will provide an excellent method
for error handling.
In the case of ensuring exceptions are always handled, a top level handler for
GenericException will usually do the job, allowing you to write error
information out to logs, screen, etc, and then shut down gracefully.
The only issue I would raise with exceptions is that they are not propagated
outside an asynchronous task. If an exception is not handled within an
asynchronous, it will not propagate to the task that started that asynchronous
task. Forte provides return and exception events when starting asynchronous
tasks to cope with this, but it seems a shame to have one method of dealing with
errors (exceptions) for synchronous behaviour, and another (events) for
asynchronous behaviour.
Steve Elvin
Systems Developer
Frontline Ltd.
UK
Mark,
The problem with return codes is that there is an underlying assumption
that the receiver will always catch and interpret that error code. This
may or may not be good thing, depending on how you architect your
application. If, on the other hand, you want to ensure that an error is
always handled, if not by the receiver then by the Forte, Exceptions are
the way to go. To extend this mechanism further, I would subclass
GenericException and created my own error code attribute on that
subclass. That way the receiver has the choice of interpreting the
exception based on that error code, and wrapping it in a
MessageDialog/window or do the usual 'errormgr.showerrors()'.
Exceptions seem a more flexible approach to me. That is, if you can live
with the fact that by using it, you're violating the 'exceptions for
behavioral anomalies' software engineering principle !
Best wishes.
Eric Pereira
Forte Consultant
----Original Message Follows----
From: "Kallambella, Ajith" <[email protected]>
To: "'Mark Sundsten'" <[email protected]>, [email protected]
Cc: [email protected]
Subject: RE: Raising Exceptions Vs returning error codes
Date: Wed, 30 Dec 1998 08:52:39 -0500
Reply-To: "Kallambella, Ajith" <[email protected]>
Mark,
Identifying conditions where you would rather use an exception
to an error_code ( and vice-versa ) normally depends on
your application design. Usually exceptions
are used to handle behavioral anomalies which are
not expected during the normal course of execution of
the program, and which would affect the continuity of
your algorithm if ignored. Examples would be a fatal
error, a semantically invalid( but syntactically-valid
token ) etc.
Error_codes and return status's can be used to handle
anticipated and recoverable errors. Example would
be presentation layer validations. In any normal
UI system, the user is expected to make errors and it
would be annoying to throw an exception( and to handle
it ), every time user enters wrong data. A well
modeled client layer should not only handle
data-validation errors , but should be smart enough
to encourage users to input correct or
"near-correct" data. Examples could be
making use of look-up windows etc. Interestingly,
Express uses exceptions to handle data-validations.
As you see, exceptions fit well into your processing
logic where severity of damage caused by an error
is more. Where as error_codes fit well into presentation
logic( and some not-so-critical processing logic ) where
errors are usually recoverable and normal path of
execution can be easily restored.
Hope this helps. I would be very interested to hear
what others have to say.
Ajith Kallambella. M
Forte Systems Engineer,
International Business Corporation.
-----Original Message-----
From: Mark Sundsten [mailto:[email protected]]
Sent: Tuesday, December 29, 1998 2:10 PM
To: [email protected]
Cc: [email protected]
Subject: Raising Exceptions vs returning error codes
When dealing with error handling, I find myself struggling with the
choice
of
raising exceptions (and handling them) from the caller
vs returning an error code of somekind.
When would you want to use one over the other?
Should you always use exception handling?
Any discussion would be appreciated.
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
Get Your Private, Free Email at http://www.hotmail.com
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>-
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>Hi Steve !
Probably the following explanation might help in resolving the issue raised by
you:
At a more abstract level, there is only one thing, i.e. the EVENT. According to
it's definition, an event is a relatively infrequent occurrence in one portion (lets
call it event raiser) of the application, which some other portion (or portions,
lets call them event handlers) (of the same application) are interested to respond
to it. Now there are two scenarios:
(A) Event raiser and Event handler(s) are being executed under different threads
of control (Asynchronous) and
(B) Event raiser and Event Handler(s) are being executed under same thread of
control (Synchronous).
So, Exception Handling belongs to scenario B where the method raising the
exception (Event Raiser or exception raiser) and the method handling it (Event
Handler or exception block) are under the same thread of control. More ever it has
to be insured that at a time only one handler (first the inner most one) receives
the message.
Forté provides a generic Event handling mechanism (Post Event and Event Loop) to
handle the scenario A (which is the more generic one). But it also provides a
specialized Event Handling mechanism (Raise Exception and Exception block) to
efficiently handle the relatively simple scenario B. Why I am saying that the later
is efficient because it won't be needing to register the event queue address of the
interested task (after all there is only one task involved) and put the event
message in queue.
Finally let me mentioned that it is just my view based on the understanding I
have and it may not be true. Only a person from forté can confirm it. I will really
appreciate if somebody correct and or refine it.
Wish a Very Very Happy New Year to all Forté Users
Regard,
Kailash.
[email protected] wrote:
I would agree with Eric entirely. Exceptions seem to me to be a much more
complete solution to the problem of error handling. A little bit of effort up
front in making clear the strategy for exception handling and specifying the
exceptions that can be raised by a class\method will provide an excellent method
for error handling.
In the case of ensuring exceptions are always handled, a top level handler for
GenericException will usually do the job, allowing you to write error
information out to logs, screen, etc, and then shut down gracefully.
The only issue I would raise with exceptions is that they are not propagated
outside an asynchronous task. If an exception is not handled within an
asynchronous, it will not propagate to the task that started that asynchronous
task. Forte provides return and exception events when starting asynchronous
tasks to cope with this, but it seems a shame to have one method of dealing with
errors (exceptions) for synchronous behaviour, and another (events) for
asynchronous behaviour.
Steve Elvin
Systems Developer
Frontline Ltd.
UK
Mark,
The problem with return codes is that there is an underlying assumption
that the receiver will always catch and interpret that error code. This
may or may not be good thing, depending on how you architect your
application. If, on the other hand, you want to ensure that an error is
always handled, if not by the receiver then by the Forte, Exceptions are
the way to go. To extend this mechanism further, I would subclass
GenericException and created my own error code attribute on that
subclass. That way the receiver has the choice of interpreting the
exception based on that error code, and wrapping it in a
MessageDialog/window or do the usual 'errormgr.showerrors()'.
Exceptions seem a more flexible approach to me. That is, if you can live
with the fact that by using it, you're violating the 'exceptions for
behavioral anomalies' software engineering principle !
Best wishes.
Eric Pereira
Forte Consultant
----Original Message Follows----
From: "Kallambella, Ajith" <[email protected]>
To: "'Mark Sundsten'" <[email protected]>, [email protected]
Cc: [email protected]
Subject: RE: Raising Exceptions Vs returning error codes
Date: Wed, 30 Dec 1998 08:52:39 -0500
Reply-To: "Kallambella, Ajith" <[email protected]>
Mark,
Identifying conditions where you would rather use an exception
to an error_code ( and vice-versa ) normally depends on
your application design. Usually exceptions
are used to handle behavioral anomalies which are
not expected during the normal course of execution of
the program, and which would affect the continuity of
your algorithm if ignored. Examples would be a fatal
error, a semantically invalid( but syntactically-valid
token ) etc.
Error_codes and return status's can be used to handle
anticipated and recoverable errors. Example would
be presentation layer validations. In any normal
UI system, the user is expected to make errors and it
would be annoying to throw an exception( and to handle
it ), every time user enters wrong data. A well
modeled client layer should not only handle
data-validation errors , but should be smart enough
to encourage users to input correct or
"near-correct" data. Examples could be
making use of look-up windows etc. Interestingly,
Express uses exceptions to handle data-validations.
As you see, exceptions fit well into your processing
logic where severity of damage caused by an error
is more. Where as error_codes fit well into presentation
logic( and some not-so-critical processing logic ) where
errors are usually recoverable and normal path of
execution can be easily restored.
Hope this helps. I would be very interested to hear
what others have to say.
Ajith Kallambella. M
Forte Systems Engineer,
International Business Corporation.
-----Original Message-----
From: Mark Sundsten [mailto:[email protected]]
Sent: Tuesday, December 29, 1998 2:10 PM
To: [email protected]
Cc: [email protected]
Subject: Raising Exceptions vs returning error codes
When dealing with error handling, I find myself struggling with the
choice
of
raising exceptions (and handling them) from the caller
vs returning an error code of somekind.
When would you want to use one over the other?
Should you always use exception handling?
Any discussion would be appreciated.
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
Get Your Private, Free Email at http://www.hotmail.com
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>-
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/> -
Hello Friends;
I have a problem with event handlers. I have defined events for double_click, data_change and hotspot_click. At first run of the program everything runs fine but when I make a change at the screen (like pressing Enter or entering a value at a screen field) the handlers seem to be called a couple of times. For example at a hotspot click I call an accounting document display and when I want to return with back button the program seems to be stuck at document display. Actually it calls event handler over and over again. How can I solve this problem? Can refreshing grid be a solution?
Thx in advance
AliHello Ali
The problem is that after handling the hotspot event the current cell is still on the field with the hotspot. Thus, when you push ENTER the ALV grid checks the current cell which has a hotspot defined which, in turn, raises event HOTSPOT_CLICK.
Therefore, you have to move the current cell to another cell that has no hotspot defined. Have a look at the implementation of the event handler method. The hotspot is on field KUNNR. After calling transaction XD03 I shift the current cell to field BUKRS.
If you comment these lines you will see the same behaviour of the report as you described.
*& Report ZUS_SDN_TWO_ALV_GRIDS
REPORT ZUS_SDN_ALVGRID_EVENTS.
DATA:
gd_okcode TYPE ui_func,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '1000' OBLIGATORY.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_col_id type lvc_s_col.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
* Set active cell to field BUKRS otherwise the focus is still on
* field KUNNR which will always raise event HOTSPOT_CLICK
ls_col_id-fieldname = 'BUKRS'.
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
IS_ROW_ID = e_row_id
IS_COLUMN_ID = ls_col_id.
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
* 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 ALV grid
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking
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.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid1.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
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.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
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.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_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.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'KUNNR'.
IF ( syst-subrc = 0 ).
ls_fcat-hotspot = abap_true.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDIF.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
Regards
Uwe -
Help with Event Handlers with Scope
I have a question of how I must implement the event handlers with scope, I have problems in the execution of processes BPEL (they are generating exceptions in the dehydration)
I have two models for event handlers and I need to know which is the best way to implement event handlers.
Another question is, in what it influences the "variableAccessSerializable" attribute.
Thanks!
1) Event Handlers with PartnerLink invocation OUTSIDE Scope
<invoke name="Invoke_1" partnerLink="PartnerLink1"/>
<scope name="Scope_1" variableAccessSerializable="yes">
<eventHandlers>
<onMessage partnerLink="PartnerLink1"/>
<onAlarm/>
</eventHandlers>
<sequence name="Sequence_1">
</sequence>
</scope>
2) Event Handler with PartnerLink invocation INSIDE scope
<scope name="Scope_1" variableAccessSerializable="yes">
<eventHandlers>
<onMessage partnerLink="PartnerLink1"/>
<onAlarm/>
</eventHandlers>
<sequence name="Sequence_1">
<invoke name="Invoke_1" partnerLink="PartnerLink1"/>
</sequence>
</scope>Thanks -- indeed a crucial call might be missing. I was doing
this until 3 yesterday morning.
Would this be the correct sample code to use? :
http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm ?context=Flash_MX_2004&file=00000846.html
It seems to work (although someone cautions in the page
comments that it doesn't).
Part of my trouble in working with AS 2.0 is that I feel I
shouldn't have to do such complicated things (Delegate classes,
etc) in order to get simple things done (loading XML files). This
is not a complaint per se -- rather I feel that I must be missing
something, that it is my inexperience that is causing me to bend
through so many hoops: programming "should" be elegant and simple.
So, any links helpful. Thanks. -
Catching errors in Web Dynpro for Java when thrown from RFC Raise Exception
Hello Developers,
I'm looking for information that explains how a Web Dynpro for Java application responds and processes errors that are thrown from a Raise Exception event within an RFC.
The Exceptions do not appear to be part of the Model and I can't identify how they get processed.
When rfc HRXSS_CAT_WD_RECORD raises exception PERNR_NOT_LOCKED this exception is passed back to the calling webdynpro CAT DC that displays the exception on the web page along with the log.
I would like to display a friendlier message and without the log. Any information on how to customize the handling of this error would be greatly appreciated.
Thank you,
Terry[see here|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=%2flibrary%2fuser-interface-technology%2fwdJava%2FHowtoHandleExceptionsEffectivelyWhileWorkingwithWebDynproJava%28WDJ%29.pdf]
-
10g: Data Binding in event handlers?
I'm trying to use data binding in my event handlers so that I can have a definitive source for the Strings that name things like this. I can see that the page is getting generated with the proper names on the elements in the page, but I always get an UnhandledEventException when I trigger the event. The idea is something like this:
<submitButton text="Refresh" event="${ pageBean.controlRefreshEventName }" >
</submitButton>
<submitButton text="Hide Controls" event="${ pageBean.controlHideEventName }" >
</submitButton>
<handlers>
<event name="${ pageBean.controlRefreshEventName }">
<method class="com.avega.portlets.view.EventHandler"
method="handleControlFormSubmit"/>
</event>
<event name="${ pageBean.controlHideEventName }">
<method class="com.avega.portlets.view.EventHandler"
method="handleControlFormSubmit"/>
</event>
</handlers>
...Now in my EventHandler I would be able to use the getXXXName methods when checking for which submit button was hit. Except I'm getting an exception instead.
(BTW, I only have the two event tags because I wasn't sure how to concatenate the el expressions with a space...)No, there's no indication that anything is wrong until I cause the event and get the UnhandledEventException.
However, I did the an experiment with the following tags, the first in a plain JSP, the second in a UIX page, and it seems that this is the normal way of handling a non-existant bean reference. Both cases printed 'text' in the page and did not complain that 'noBean' didn't exist. It seems you get an error when you reference a non-existant property on an existing bean, but no error if the bean itself doesn't exist. Anyway, UIX doesn't appear to be any different from JSP in this regard.
<c:out value="${ noBean.noProperty } text" />
<styledText text="${ noBean.noProperty } text" /> -
How to expose event handlers of the TextBox in a NumericUpDown?
The NumericUpDown control contains a TextBox object that I have exposed by creating a class that inherits from NUD and references the TextBox as the second control in the Base class, like this:
Public Class clsNumericUpDownExt
Inherits NumericUpDown
Private TheTextBox As TextBox = MyBase.Controls(1)
Event NewLeave()
Public ReadOnly Property TextBox As TextBox
Get
Return TheTextBox
End Get
End Property
End Class
In the form, I instantiate an object from this class and display it in a tab control on the form, like this:
Public WithEvents dynNudTime As clsNumericUpDownExt = New clsNumericUpDownExt
'In the form's Load event:
Dim loc As System.Drawing.Point = New System.Drawing.Point(177, 19)
Dim fnt As System.Drawing.Font = New System.Drawing.Font("Microsoft Sans Serif", 30)
tabTimer.Controls.Add(dynNudTime)
With dynNudTime
.Width = 240
.Location = loc
.Font = fnt
.Maximum = 86399
.Visible = True
End With
Since it was declared WithEvents, I can see the event handlers of the NUD base class of the object in the form, so I can code an action for, let's say, the ValueChanged event. Is there a way to see the event handlers of the TextBox, so that I can code an
action for, say, the TextChanged event?
Thanks!Well, you could add a public event to the NUD class and raise the event when the text of the textbox is changed. You would need to do this for each event you want to handle from the textbox.
In this example i added a custom event that will pass the NUD control as the sender and the Text as the 2nd argument.
Public Class Form1
Private WithEvents nud As New clsNumericUpDownExt
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Controls.Add(nud)
End Sub
Private Sub nud_TBoxTextChanged(ByVal sender As Object, ByVal TheText As String) Handles nud.TBoxTextChanged
Me.Text = TheText
End Sub
End Class
Public Class clsNumericUpDownExt
Inherits NumericUpDown
Public Event TBoxTextChanged(ByVal sender As Object, ByVal TheText As String)
Private WithEvents TheTextBox As TextBox = CType(MyBase.Controls(1), Windows.Forms.TextBox)
Private Sub TheTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TheTextBox.TextChanged
RaiseEvent TBoxTextChanged(Me, TheTextBox.Text)
End Sub
End Class
If you say it can`t be done then i`ll try it -
How to remove event handlers for a content type currently in use?
Hi,
We had a SP 2007 solution that managed event handlers as described in
Brian Wilson's blog regarding event handlers. We then did a in-place upgrade to SP 2010. It so happend that we wanted to remove some of our old event handlers and this is where our problem started. We managed to delete event handlers
(SPEventReceiverDefinitions) for
Site and List by using the ui from Brian Wilsons feature "Manage Event Handlers" (ref the link above), but not anyone at all for
Content Types... It simply wouldn't be deleted
(remove was grayed out in the ui).
We then tried to do it by code. Below is a code snippet illustrating how we tried to delete the event handlers for content types:
using (SPWeb web = properties.Feature.Parent as SPWeb)
string targetClassName = "targetClassName.";
web.AllowUnsafeUpdates = true;
// Removing Content Type event handlers
foreach (SPContentType ct in web.ContentTypes)
for (int i = ct.EventReceivers.Count - 1; i >= 0; i--)
if (ct.EventReceivers[i].Class.StartsWith(targetClassName))
ct.EventReceivers[i].Delete();
ct.Update(true);
web.Update();
The Content Types are not sealed and are
not readonly. When debugging, we can see that the
Delete() method are called on one of the Content Types we wanted to delete event handlers for. We noted that the
ct.EventReceivers.Count remains the same, before and after Delete() is called. We did not get any exceptions when running this code.
When running the code a second time and debugging again, we see that the very same Content Type still has the very same event handler attached... As in, it wasn't deleted....
We also tried to delete the event handlers through PowerShell as described
here in the post by Per Jakobsen. However, the script did not really seem to find any EventReceivers... We tried to write the
$site.AllWebs | % {$_.Lists} | % {$_.ContentTypes} | % {$_.EventReceivers} list to file, but it was empty.. We did however get a long list when writing $site.AllWebs | % {$_.Lists} | % {$_.ContentTypes} to file. We could then in
that file see the event handler references we want to remove registered to our Content Types, as we did during code debugging earlier on. So PowerShell might still be the way to go here...
So, does anyone know if there is a way to force this delete through, either by code, PowerShell or some other means? Any help regarding this matter would be very much appreciated :)Hi,
For your information, there's two versions (at least) exists for each content types. One is Site Content Type - exists in Root web and another is list content type. Once you add a content type to a list, a copy of the site content type is taken and stored
in the list. If you update the site content type, it may or may not affect the list conten type. So make sure you are updating the both - site content and list content type. Once you update site content type with passing paramater true to 'ct.Update(true)',
the list content types are supposed to updated too.
Thanks,
Sohel Rana
http://ranaictiu-technicalblog.blogspot.com -
Event Handlers Invoked Everytime for update on User Profile.(OIM 11g)
Hi,
We had Custom event handlers for generating some fields on user form.
Everytime there is update on user profile on any field, All the event handlers fired, (As seen from logs).
I want to fire particular event handlers on particular update. Like if first name is updated then only display name event handler should fire. (not all)
How can i achieve this???Here is my code..it is working fine for creation of the user. but when i am updating the user i am getting all null values except the updated one.
Example if there are 5 fields in that i am updating 2 .apart from those 2 fields the other 3 are coming as null which is making validation to fail.
package flatfilevalidation;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
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.BulkOrchestration;
import oracle.iam.platform.kernel.vo.Orchestration;
import oracle.iam.identity.usermgmt.api.UserManagerConstants.AttributeName;
import Thor.API.*;
import Thor.API.Exceptions.tcAPIException;
import Thor.API.Operations.*;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import oracle.iam.identity.usermgmt.api.UserManagerConstants;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.passwordmgmt.utils.MLSUtils;
import oracle.iam.platform.Platform;
import oracle.iam.platform.kernel.vo.OrchestrationTarget;
import oracle.iam.upgrade.changes.jaxb.Entity;
public class FFValidation implements ValidationHandler {
int count;
tcUserOperationsIntf userOperationsService;
Entity ent = null;
@Override
public void validate(long arg0, long arg1, Orchestration orchestration)
throws ValidationException, ValidationFailedException {
System.out.println("entered the Validation methode");
HashMap<String, Serializable> parameters = orchestration.getParameters();
System.out.println("****************************************************************");
User user = getUser(orchestration);
Object passwdOrchParam = parameters.get(UserManagerConstants.AttributeName.EMPLOYEE_NUMBER.getId());
System.out.println("***************************"+passwdOrchParam+"*************************************");
System.out.println("orch.getParameters() ============================ " + parameters);
String ceo="CEO";
String trainee="Trainee";
String Emp="EMP";
String Contractor="Contractor";
//int Skypecount,Empcount,phonecount;
String Role= getParameterValue(parameters, "Role");
String Designation = getParameterValue(parameters, "Designation");
Long Manager =getManagerid(parameters, "USR_MANAGER_KEY");
Date EndDate =getDate(parameters, "End Date");
String EmpNo=getParameterValue(parameters, "Employee Number");
String skypeid=getParameterValue(parameters, "SkypeId");
String Mobile=getParameterValue(parameters, "Mobile");
String skypeidDb="usr_udf_skypeid";
String MobileDb="usr_mobile";
String EmpDB="usr_emp_no";
//validating SkypeID
uniquevalidate(skypeid,skypeidDb);
//Validating Employee Number
uniquevalidate(EmpNo,EmpDB);
//Validating Employee Number
uniquevalidate(Mobile,MobileDb);
//CEO Validation
if(Designation.equals(ceo)){
if(Manager!=null){
String msg="ManagerID not required";
System.out.println("ManagerID not required ");
throw new ValidationFailedException(msg);
//Cotractor Validation
if(Role.equals(Contractor) && Designation.equals(ceo)) {
System.out.println(Designation.equals(ceo));
String msg="Contractor Cannot be CEO";
System.out.println("Contractor Cannot be CEO");
throw new ValidationFailedException(msg);
if(Role.equals(Contractor)&& EndDate==null) {
String msg="Contractor Endate is not provided";
System.out.println("Contractor Endate is not provided");
throw new ValidationFailedException(msg);
//Trainee Validation
if(Role.equals(trainee) && Designation.equals(ceo)) {
System.out.println(Designation.equals(ceo));
if(Designation.equals(ceo)) {
String msg="Trainee Cannot be CEO";
System.out.println("Trainee Cannot be CEO");
throw new ValidationFailedException(msg);
//manager validation
if(!Designation.equals(ceo)){
if(Manager==null){
String msg="ManagerID Can not be Null";
System.out.println("ManagerID Can not be Null");
throw new ValidationFailedException(msg);
//Employee Validation
if(Role.equals(Emp)){
if(EndDate!=null) {
String msg="Employee End Date Should be empty";
System.out.println("Employee End Date Should be empty");
throw new ValidationFailedException(msg);
@Override
public void validate(long arg0, long arg1, BulkOrchestration arg2)
throws ValidationException, ValidationFailedException {
System.out.println("**************Inside BulkOrchestration****************");
HashMap<String, Serializable> parameters = arg2.getParameters();
System.out.println("orch.getParameters() ============================ " + parameters);
@Override
public void initialize(HashMap<String, String> arg0) {
private String getParameterValue(HashMap<String, Serializable> parameters,
String key) {
String value = (parameters.get(key) instanceof ContextAware) ? (String) ((ContextAware) parameters
.get(key)).getObjectValue()
: (String) parameters.get(key);
System.out.println("VALUE::" + value);
return value;
private boolean isNullOrEmpty(String str) {
return str == null || str.isEmpty();
private Long getManagerid(HashMap<String, Serializable> parameters,
String key) {
System.out.println(parameters);
Long managerLogin = (parameters.get(AttributeName.MANAGER_KEY.getId()) instanceof ContextAware)
? (Long) ((ContextAware) parameters.get(AttributeName.MANAGER_KEY.getId())).getObjectValue()
: (Long) parameters.get(AttributeName.MANAGER_KEY.getId());
System.out.println("managerLogin "+managerLogin);
return managerLogin;
private Date getDate(HashMap<String, Serializable> parameters,
String key) {
System.out.println("date "+ parameters);
Date date = (parameters.get(AttributeName.ACCOUNT_END_DATE.getId()) instanceof ContextAware)
? (Date) ((ContextAware) parameters.get(AttributeName.ACCOUNT_END_DATE.getId())).getObjectValue()
: (Date) parameters.get(AttributeName.ACCOUNT_END_DATE.getId());
System.out.println("EndDate "+date);
return date;
void uniquevalidate(String idvalue,String idDbvalue){
userOperationsService = Platform.getService(tcUserOperationsIntf.class);
HashMap<String, String> UMAttr = new HashMap<String, String>();
String msg="Entered Value is not unique" + idvalue;
System.out.println("idvalue="+ idvalue);
System.out.println("idDbvalue="+ idDbvalue);
if(idvalue!=null){
try {
System.out.println("in try block");
UMAttr.put(idDbvalue, idvalue);
tcResultSet USAttr = userOperationsService.findUsers(UMAttr);
System.out.println(USAttr);
System.out.println("User set count ========================= " + USAttr.getRowCount());
count=USAttr.getRowCount();
if(count>0)
throw new ValidationFailedException(msg);
catch (tcAPIException e) {
e.printStackTrace();
private User getUser(Orchestration orchestration)
if(orchestration.getTarget() != null && orchestration.getTarget().getEntityId() != null)
return new User(orchestration.getTarget().getEntityId());
HashMap orchParams = orchestration.getParameters();
User user = new User(null);
Set orchParamNames = orchParams.keySet();
String orchParamName;
for(Iterator i$ = orchParamNames.iterator(); i$.hasNext(); user.setAttribute(orchParamName, orchParams.get(orchParamName)))
orchParamName = (String)i$.next();
MLSUtils.setStringValuesForMLSAttributes(user);
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"+user);
return user;
} -
UiXML event handlers - how to define once across pages
I have a number of event handlers which will be used by several of my pages. Is there a way of including the definitions in each of those pages having only defined them once?
Cheers
IanThe simplest approach is to override AbstractPageBroker.getEventHandler() - but
that requires that the page broker have global knowledge of all your pages.
So, what follows is a way to add a single element to any of your pages that will
add event handlers (in this case, a single handler).
It's a little less trivial than I'd assumed, but I've included here actual functional
source code to implement the whole thing. This is a very, very silly example;
it lets you add a single element to a page:
<page xmlns="http://xmlns.oracle.com/uix/controller">
<scream xmlns="http://www.example.org/scream"/>
...With this element, the "scream" event will be handled by, well, screaming.
Silly, yes; but it demonstrates the technique. Exactly the same technique
would also let you execute code immediately before and/or immediately after
a page renders (e.g., automatically register data providers). Here's the code;
it's four classes, but they're all small.
ScreamUIExtension[b]
package scream;
import oracle.cabo.ui.UIExtension;
import oracle.cabo.ui.laf.LookAndFeel;
import oracle.cabo.share.xml.ParserManager;
public class ScreamUIExtension implements UIExtension
public void registerSelf(ParserManager manager)
manager.registerExtension("http://www.example.org/scream",
new ScreamParserExtension());
public void registerSelf(LookAndFeel laf)
}[b]ScreamParserExtension
package scream;
import java.util.Dictionary;
import org.xml.sax.Attributes;
import oracle.cabo.share.xml.BaseParserExtension;
import oracle.cabo.share.xml.LeafNodeParser;
import oracle.cabo.share.xml.NodeParser;
import oracle.cabo.share.xml.ParseContext;
import oracle.cabo.servlet.ui.UINodePageDescription;
public class ScreamParserExtension extends BaseParserExtension
public NodeParser startExtensionElement(
ParseContext context,
String namespaceURI,
String localName,
Attributes attrs)
if ("scream".equals(localName))
return new LeafNodeParser()
protected Object getNodeValue(
ParseContext context,
String namespaceURI,
String localName,
Attributes attrs)
return "This doesn't matter in this example...";
return null;
public Object elementEnded(
ParseContext context,
String namespaceURI,
String localName,
Object parsed,
Dictionary attributes)
Object value = attributes.get("scream");
if (value == null)
return parsed;
if (!(parsed instanceof UINodePageDescription))
logWarning(context,
"The \"scream\" elements may only be used inside of <page>");
return parsed;
return new ScreamPageDescription((UINodePageDescription) parsed);
ScreamPageDescription
package scream;
import oracle.cabo.servlet.ui.UINodePageDescription;
import oracle.cabo.servlet.ui.UINodePageDescriptionProxy;
import oracle.cabo.servlet.BajaContext;
import oracle.cabo.servlet.event.EventHandler;
import oracle.cabo.servlet.event.TableEventHandler;
public class ScreamPageDescription extends UINodePageDescriptionProxy
public ScreamPageDescription(UINodePageDescription uinpd)
_uinpd = uinpd;
public EventHandler getEventHandler(BajaContext context)
TableEventHandler teh = new TableEventHandler();
teh.registerEventHandler("scream", new ScreamEventHandler());
teh.setDefaultEventHandler(getPageDescription().getEventHandler(context));
return teh;
protected UINodePageDescription getPageDescription()
return _uinpd;
private final UINodePageDescription _uinpd;
ScreamEventHandler
package scream;
import oracle.cabo.servlet.BajaContext;
import oracle.cabo.servlet.Page;
import oracle.cabo.servlet.event.EventHandler;
import oracle.cabo.servlet.event.EventResult;
import oracle.cabo.servlet.event.PageEvent;
public class ScreamEventHandler implements EventHandler
public EventResult handleEvent(
BajaContext context,
Page page,
PageEvent event)
System.out.println("SCREAM!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
return null;
}Now, to register these, you'll want a WEB-INF/uix-config.xml like so:
<configurations xmlns="http://xmlns.oracle.com/uix/config">
<application-configuration>
<ui-extensions>
<extension-class>scream.ScreamUIExtension</extension-class>
</ui-extensions>
</application-configuration>
</configurations>If you did want to add pre- or post-rendering code, just override
different methods inside your PageDescription class.
Final note: all of this should work unmodified in 9.0.2 except for
the uix-config.xml; you'd have to use the older, deprecated WEB-INF/web.xml
UIX configuration parameters in 9.0.2. -
Deactivate Event Handlers within an EH Set
We're using EH Sets consisting of shipment and delivery Event Handlers. We deactivate them by configuring an Expected Event that, when overdue, calls the "EHSET_SET_INACTIVE" activity. Unfortunately this process is not working correctly so we now have tens of thousands of active Event Handlers that need to be deactivated. We tried running the "/SAPTRX/ARCHIVE_EH_DEACTIVATE" program but the message "No archiving-relevant data found for selection criteria; check criteria" is returned as the program checks to see if the EH is part of an EH Set.
Does anyone know of a way to deactivate these EHs?Hi Steven,
This is what I can see "You archive an event handler that belongs to one or more event handler sets by deactivating and archiving the entire event handler set" and check in this link Archiving Event Handlers (SCM-EM) - Archiving in SAP Event Management - SAP Library.
It will have some implications, if we deactivate particular event handler in event handler set then subsequent event message may fail for other event handler in EH set, SAP EM Web UI doesn't retrieve event handler data as other event handler deactivated in EH set etc. You can raise SAP OSS message to SAP to get the list of causes deactivating event handlers in EH set.
Regards
GGOPII -
Do I need to worry about these event handlers in a grid from a memory leak perspective?
I'm pretty new to Flex and coudn't figure out how to add event handlers to inline item renderer components from the containing file script so I attached the listnerers simply as part of the components themselves (eg <mx:Checkbox ... chnage="outerDocument.doSomething(event)"../>):
<mx:DataGrid id="targetsGrid" width="100%" height="100%" doubleClickEnabled="true" styleName="itemCell"
headerStyleName="headerRow" dataProvider="{targets}"
rowHeight="19" fontSize="11" paddingBottom="0" paddingTop="1">
<mx:columns>
<mx:DataGridColumn width="78" dataField="@isSelected" headerText="">
<mx:itemRenderer>
<mx:Component>
<mx:HBox width="100%" height="100%" horizontalAlign="center">
<mx:CheckBox id="targetCheckBox" selected="{data.@isSelected == 'true'}"
change="outerDocument.checkChangeHandler(event);"/>
<mx:Image horizontalAlign="center" toolTip="Delete" source="@Embed('/assets/icons/delete.png')" useHandCursor="true" buttonMode="true"
click="outerDocument.deleteHandler(event);"/>
<mx:Image id="editButton" horizontalAlign="center" toolTip="Edit" source="@Embed('/assets/icons/edit-icon.png')" useHandCursor="true" buttonMode="true"
click="outerDocument.editHandler(event);"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn id="Name" dataField="@collectionDesc" headerText="Name" itemRenderer="com.foobar.integrated.media.ui.component.CellStyleForTargetName"/>
<mx:DataGridColumn id="Created" width="140" dataField="@createDateTime" headerText="Created" labelFunction="UiHelper.gridDateFormat" />
</mx:columns>
</mx:DataGrid>
This grid is part of a view that will get destroyed and recreated potentially many times during a user's session within the application (there's a large dynamic nature to the app and views are created at run-time.) By destroyed I mean that the view that holds the above datagrid will no longer be referenced under certain circumstances and an entire new view object is created (meaning the old datagrid is no longer refernced and a new one is created.)
I heard you should clean up event handlers when they are no longer used, and I know at what point the view is destroyed, but I don't know how to clean up the event handlers added to the item renderer components? Is it something that the Flex garbage collector will handle efficiently?
Also, on a somewhat related note, how could I push the item renderer to an external component since in my event handlers for the item renderer buttons I need a reference to the datagrid.selectedIndex which, as an external item renderer I wouldn't have access to this containing grid?No. You don't need explicit cleanup in this case: if your outerDocument is going away, you have nothing to worry about. The event handler leak can happen in sort of the reverse situation: suppose you have a long-lived MyView that contains a custom DataGrid like the one below. Now suppose that MyView frequently destroys and re-creates the grid. And suppose that on its creationComplete event, the grid registers a listener for outerDocument's (MyView's) enterFrame Event. Unless you explicitly remove this listener, MyView will still have a reference to it even after the grid that registered the listener is destroyed (and garbage collected).
This is a pretty contrived example, but it sort of illustrates the potential for leaks: a certain component is elligible for garbage collection, but some longer-lived component holds a reference to it (or part of it, such as a listener function). If the longer-lived component is elligible for GC as well, you don't really need to worry about proper cleanup. That's what you're paying the GC processor cycles for. -
Unable to Create Event handlers , Plugs
Hello everyone,
We've just moved to a new development environment and had our existing WebUI enhancements transported from an old one (which was CRM 7.0 EHP1). The new system was also already in EHP1.
The problem is we couldn't create any new Event Handlers and Inbound and Outbound plugs in an enhanced component via BSP_WD_CMPWB. Even though the component has already been enhanced, the system keeps on asking for an Access Key to edit SAP Standard objects and behaving as though the component hasn't been enhanced at all.
Has anyone encountered this before? Any SAP OSS Note to fix the problem?Hello,
Thanks for your replies, the issue has been solved. When the enhancements were transported into the new system the database entries used by the enhancement wizards weren't included into the transport. Basically we had to update the ff tables:
BSP_WD_GEN -> Table with generated classes
BSP_WD_EXT_HIST -> Mapping Table source controller class to Z controller class, and source context class to Z context class -
How to expose and code the event handlers of a base class?
I have created a class that inherits NumericUpDown. When I instantiate an object from that class, I can make it visible and have it appear on my form just like any other NUD. How can I get that instantiated object to expose the event handlers of its base
class, the NUD in this case, so that, for example, I can tell the client what action to take when the value of the instantiated object changes?
Thanks for your help.I am not sure exactly what you mean. Are you adding your NUD controls to the Form at design time from the toolbox or adding them in code at run time? If you are adding them to the form from the toolbox then you access the events the same way
you would a standart NUD control. If it is at runtime and you have a fixed amount of them you are going to add then you can declare them Class Scoped using the
WithEvents keyword which will let you access all their events.
Public Class Form1
Private WithEvents Nud1 As New NUD
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Controls.Add(Nud1)
End Sub
Private Sub Nud1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Nud1.ValueChanged
Me.Text = Nud1.Value.ToString
End Sub
End Class
Public Class NUD
Inherits NumericUpDown
'Your custom code to make it work how you want...
End Class
If this is not what you are doing then you may need to explain a bit more and show the code you are using so we understand better.
If you say it can`t be done then i`ll try it
Maybe you are looking for
-
Arch Linux Weekly Newsletter *Jason Chu and Ben Mazer* Opening Welcome to the Arch Linux Newsletter. This attempts to give you an ``at a glance'' look at the world of Arch Linux. News Front Page News 1. srcpac to support source building: I
-
Elements 7 print selected area only
Have just upgraded from Elements 4 to 7. Under old version I could easily print a small rectangular selection from a possible A3 print for evaluation before printing the whole thing. There was an option after File>Print to 'Print selected area', afte
-
We currently have a SRM --> XI --> HTTPS scenario which sends purchase orders to outside vendors. We now have a need to configure a HTTPS --> XI --> R/3 scenario which will consist of vendors sending XML invoices via HTTPS to XI which in turn will ma
-
Need to strip the leading ZERO using ABAP code.
Hi Friends, I got a situation where i got customer number called 011. I need to write an ABAP in Transformation to strip the leading ZERO , 11 should be posted to the master data attribute. could you help me in the logic pls. Thanks in advance,
-
I got a virus, how do i remove it?
I just got a virus a week ago. I had the spyware sweeper asking to sweep it up. It said it had detected 3 virus'. how can i remove the virus?