Code in event handlers
Hi,
I have a JForm with a button and a label on it. I set an event handler for the button like this:
button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) {*foo()*;}});
This is how foo() looks:
public void foo()
this.label.setText("Please wait...");
for(int i=0;i<1000;i++)
for(int j=0;j<1000;j++)
for(int k=0;k<1000;k++)
for(int l=0;l<10;l++)
this.label.setText("Finished");
I expect this to happen:
1. Label text changes to "Please wait..."
2. Frame freezes for a while
3. Label text changes to "Finished"
Instead, what happens is this:
1. Frame freezes for a while
2. Label text changes to "Please wait..."
3. Label text changes to "Finished"
Why does the label text change not before the delay but after it and how do I avoid it?
Thanks
Please read the "Welcome to the new home" posting at the start of the forum to learn how to use the "code tags" so posted code is formatted and readable.
Similar Messages
-
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 -
OIM11 event handlers: How to avoid firing the same code in both pre+post
Hi everyone,
I have a question around event handlers. My experiments so far have gleaned the following:
Manual updates of user form in admin interface -> Fires: pre-insert + Post-insert
Reconciliation trusted creates -> Fires: Post-insert
Reconciliation trusted updates -> Fires: pre-insert + Post-insert
Now I have various handlers that trigger to update fields coming in from trusted recon. Formatting telephone numbers, setting custom user attributes.. etc. I am using the same code in both the post and pre handlers as wherever the update comes from it needs to be processed in the same way. Problem is if a handler fires twice I can't be sure exactly how the system is going to behave (updating the same field again etc), never mind it is unneeded processing.
We have to keep the pre handlers because otherwise changes completed via the admin interface won't be seen until you refresh.
Can anyone please advice how to go about ensuring a handler is only fired once? i.e. if pre fires don't fire post. Have I missed something key here?
Edit: I know I've worded this badly. They will always fire as that's how OIM behaves, what I want is some way to work out in the underlying code if a field has already been modified in pre process... or something like it.
Thanks,
Wayne.
Edited by: wblacklock on 27-Feb-2012 05:38I am sorry but I am not agree with your design.
However there is no chance to avoid this according to my knowledge. As both class has separate thread under different process, so there is no way to implement thread lock on entity operation.
Alternate way to acheive your requirement:
You can have hidden UDFs. Update hidden UDFs in prepost handler with some data (hardcoded).
"You can have the value this hidden filed like :- "NAME_UPDATE|EMAIL_UPDATED|MANGER_UPDATE"
Now in Post - Process handler check the value of hidden UDF.
Get the value of hidden UDF, tokenize with String Tokenizer. Check which filed is not updated in Pre handler.
*If it is already updated - do not update.* else Update.
Thanks,
Kuldeep -
Event handlers execute code from a seperate class
i am having difficulties linking my event handlers to another piece of code in a seperate class. basically i want my event handler to execute a code which is in another class. how do i do this?
while adding listener to the component for which u want to handle event add listener with the name of class where u r going to write the event handling code and declare that class as implementing the type of listener and handle the event in that class by implementing the definitions for the methods in the interface
-
Hello All,
Wish You Happy New Year to All in advance.
while accessing the share point site i got the error message
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The element <forms> may only appear once in this section.
Source Error:
Line 104: <!--<forms loginUrl="/_layouts/log-in.aspx" />-->
Line 105: <forms loginUrl="/_layouts/log-in.aspx" />
Line 106: <forms loginUrl="/_layouts/log-in.aspx" />
Line 107: <forms loginUrl="/_layouts/log-in.aspx" />
Line 108: </authentication>
Source File: C:\Inetpub\wwwroot\wss\VirtualDirectories\4545\web.config Line:
106
Version Information: Microsoft .NET Framework Version:2.0.50727.3662; ASP.NET Version:2.0.50727.3658
i have found event message in the event log
Event code: 3008
Event message: A configuration error has occurred.
Event ID: 523cefee6a0943948cf01b4e9f476fff
Event sequence: 77
Event occurrence: 76
Event detail code: 0
Exception information:
Exception type: ConfigurationErrorsException
Exception message: The element <forms> may only appear once in this section. (C:\Inetpub\wwwroot\wss\VirtualDirectories\4545\web.config line 106)
Request information:
Request URL: http://beesppesxapp70:4545/_vti_bin/sitedata.asmx
Request path: /_vti_bin/sitedata.asmx
User host address: 172.16.20.80
User:
Is authenticated: False
Authentication Type:
Thread account name: abc\wss_setup
Thread information:
Thread ID: 1
Thread account name: abc\wss_setup
Is impersonating: False
Stack trace: at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Web.Configuration.RuntimeConfig.GetSectionObject(String sectionName)
at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName, Type type, ResultsIndex index)
at System.Web.Configuration.RuntimeConfig.get_Authentication()
at System.Web.Security.FormsAuthenticationModule.Init(HttpApplication app)
at System.Web.HttpApplication.InitModulesCommon()
at System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers)
at System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context)
at System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context)
at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
kindly advise me
Thank a lot in advanceHi,
As per the error logs it seems you have the Form element twice in your web config file. Just take one or the other one out. if you did any changes in web. config file please share and elaborate little more about the changes if you have made recently before
the error.
Krishana Kumar http://www.mosstechnet-kk.com
Please mark the replies and Proposed as answer if they help and solve your issue -
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. -
Multiple event handlers registered for the same event and error when adding users to sec groups
Project Server 2013 CU April (May) 2014
I've created and installed two event handlers (separate dll:s) and both are triggering on Project Published - initially, both are working fine.
After an IISReset, trying to create a new security group (or add a user to an existing group) will result in an error on the page and a corresponding error in the ULS log - the latter indicating an error in the method security.creategroups, and specifically
a problem 'An item with the same key has already been added.'
An SQL trace reveals a break in execution after executing the proc 'pub.MSP_ADMIN_ReadEventReceivers' which returns all registered event handlers.
In my case, the result of that proc execution shows that there are two event handlers registered with an EVENT_ID of 53 (Project Published) and with ORDER_FIRED set to 1 and 2 respectively.
I tried removing one of the event receivers using the Central Admin PWA interface and then everything worked just fine - I added the event receiver back again, and everything STILL worked! IISReset and I got the error back again. :-(
Since there's obviously some problem with reading multiple entries from that table regardless of the ORDER_FIRED differentiation, I tried temporarily modifying one of the '53' entries in the table directly and then the sec group was created just fine!
I would like to know if anyone else has seen this? I've seen this on three separate installations now after deploying a second event listener onto those systems.
/Lars Hammarberg
//Lars Hammarberg www.connecta.seHi Lars,
yes I have seen the same issue. It is not related to April CU. I had the error before with SP1.
It is not only an issue with the security groups. At least in our case nothing worked at all. No custom field editing, all Queue Jobs failing.
For your case I suggest you consolidate your code in one eventhandler.
Theory says that you can have more than 1 (up to 999) eventhandlers for one Event (http://msdn.microsoft.com/en-us/library/ms481079(v=office.12).aspx) but that seems not to
work. Not sure, if it worked in earlier versions.
Kind regards
Christoph
Christoph Muelder | Senior Consultant, MCTS, MCSE, MCT | SOLVIN information management GmbH, Germany -
Event Handlers and Callbacks: Best way to handle?
I'm writing an actionscript class. I'm wondering how to deal
with call backs and event handlers within my class. In particular,
I'm wondering how I might structure my class so that developers
using it can choose which arguments get passed to the callback
function as they code. I've been googling and haven't found any
particularly useful information on this.
As far as I can tell, it would appear that the parameters
passed to any callback function are determined at the time I write
my class as this anonymous function example illustrates.
var myObj:Object = new MyClass('foo', 'bar');
myObj.onLoad = function(arg) {
// the args passed to this anonymous function are dictated
by the actionscript defnining MyClass
I have also seen an approach using named functions and a
class method for setting the event handler which allows a developer
to pass some object to be used for scoping the named function but
this also results in the parameters for the callback being
predetermined by the actionscript that defines the class
function myLoad(arg) {
// the args passed to this function are also dictated by the
actionscript defining MyClass
var myObj:Object = new MyClass('foo', 'bar');
myObj.setOnLoadHandler(this, 'myLoad');
As far as I can tell, neither approach would let a developer
specify any parameters for the callback functions (onLoad() in the
first example, myLoad() in the second example). Which of these
approaches is considered 'best practice'? Also, what would I do if
I wanted to specify that the callback should operate on a
particular movieclip on my timeline? How can I pass that
movieclip's parameter to the callback function?You can download the Library from this link. Inside is an example that shows how to handle windows messages/events.
http://zone.ni.com/devzone/cda/epd/p/id/4394 -
Multiple event handlers for one button
I'm trying to create a button with 2 event handlers, such
that when you roll-over the button, a submenu pops up, and when you
click the button, you go to a certain frame. I feel like this
shouldn't be hard at all, but it's not working. Below is the
actionscript I have tried. Both event handlers work as I want them
to if alone, but the on(release) functionality does not work when I
try to put them together.(I have Flash 8). Thanks for your help!
on (release) {
_root.gotoAndStop("one1");
tellTarget (_root.navigation) {
gotoAndStop (1);
on (rollOver) {
this.gotoAndPlay("links");
tellTarget (_root.navigation.introduction) {
gotoAndStop (1);
tellTarget (_root.navigation.overview) {
gotoAndStop (16);
tellTarget (_root.navigation.coronary) {
gotoAndStop (1);this code is ok, it seems that when u rollover on the button,
the event is fired and it keeps on running the time u r on it. i
think just add
delete this.onRollOver inside rollOver event. -
OIM 11g: Event Handlers/Plugins Classpath
We have a number of custom utility libraries that we use for OIM development which are currently uploaded to the OIM database OIMHOME_JARS table.
Ideally, we'd like to reference classes from these JARs in our plugins/event handlers. During initial testing, it looks like the plugin code doesn't consider the uploaded JARs and we get a bunch of NoClassDefFoundError errors.
Is there no way to get the plugin code to be able to use the uploaded utilities? or is the solution to also deploy the utility JARs within the plugin zip file itself (not ideal).
Thanks.Not always true. In most of the cases you would find that it reads the helper jars from within the lib directory inside the plugin but in some special cases it does't behave that simple.
UploadJars definitely doesn't work. I had to put the jar in the weblogic startup script to set classpath for this to work. This script is *<domain_home\bin\setDomainEnv.cmd\>*
So its a bit dubious. -
Acrobat SDK: How to get events and write event handlers in c#
I am trying out to get events from a pdf doc and handle it in my c# code with the samples that come with Acrobat-SDK.
I am yet to understand how I can do it. I am yet to discover the class that provides me the events. All the classes currently expose methods only. It might be that I am missing something for sure.
Can somebody help?
My use case is:
the user will open a pdf doc and my application (or my app can trigger opening the pdf doc)
when the user selects some text from the pdf doc, my app should get the event
My event can handle the selection and get the selected text.
Put a bookmark on the selection in the pdf doc (with additional attributes)
the pdf doc retains such bookmarks when the pdf is saved.
bookmarks in the pdf should be available for edit.
A different app/code should be able to parse and retrieve these bookmarks along with the additional attributes of the bookmark.
I hope, I have not asked too much.There are no “event handlers” for C# in the Acrobat SDK. You will have to “poll” for things such as selected text.
Also, I don’t know what sort of “additional attributes” you are thinking about, but that may or may not be possible from C#. -
How to Deploy the Event Handlers OIM 11g
Hi
I have developed the code for post process event handler using OIM 11 G API. The OIM not invoking the EventHandlers while updating the users attribute or creating the users attribute.
I have done the following task to develop and deploy the OIM 11g Event handlers. They are
1) Implementing the PostProcessHandler interface and provide the implementation of execute method.
Sample Class
public class SamplePostProcessEventHandler implements PostProcessHandler {
private Logger logger=Logger.getLogger("TEST-LOGGER");
public SfsuPostProcessEventHandler()
logger.debug("Invoking Event Handler Plugin");
@Override
public boolean cancel(long arg0, long arg1,
AbstractGenericOrchestration arg2) {
// TODO Auto-generated method stub
return false;
@Override
public void compensate(long arg0, long arg1,
AbstractGenericOrchestration arg2) {
// TODO Auto-generated method stub
@Override
public EventResult execute(long processid, long eventid, Orchestration orchestration) {
// TODO Auto-generated method stub
logger.debug("Operation "+orchestration.getOperation());
logger.debug("Parameters "+orchestration.getInterEventData());
logger.debug("Parameters "+orchestration.getParameters());
EventResult result=new EventResult();
return result;
@Override
public BulkEventResult execute(long arg0, long arg1, BulkOrchestration arg2) {
// TODO Auto-generated method stub
return null;
@Override
public void initialize(HashMap<String, String> arg0) {
// TODO Auto-generated method stub
2) Create the Jar File SamplePostProcessEventHandler.jar
3) Create the Plugin.xml file
Sample File
<?xml version="1.0" encoding="UTF-8"?>
<oimplugins>
<plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
<plugin pluginclass="test.eventhandlers.SamplePostProcessEventHandler" version="1.0" name="SamplePostProcessEventHandler">
</plugin>
</plugins>
</oimplugins>
4) Create the directory lib and copy the SamplePostProcessEventHandler.jar file into this directory
5) Creating the Zip file with the following directory structure.
plugin.xml
lib/SamplePostProcessEventHandler.jar
6) Register the plugin
ant -f pluginregistration.xml register
7) Creating the Custom Events xml file called EventHandlers.xml
<?xml version='1.0' encoding='UTF-8'?>
<eventhandlers>
<action-handler class="test.eventhandlers.SamplePostProcessEventHandler" entity-type="User" operation="CREATE" name="SamplePostProcessEventHandler" stage="postprocess" order="LAST" sync="TRUE"/>
<action-handler class="test.eventhandlers.SamplePostProcessEventHandler" entity-type="User" operation="MODIFY" name="SamplePostProcessEventHandler" stage="postprocess" order="LAST" sync="TRUE"/>
</eventhandlers>
8) Importing the Above XML into the MDS Schema Using the weblogicImportMetadata.sh file
Directory Structure of the Event Handler Schema File
/home/oracle/eventhandler/db/EventHandlers.xml
weblogic.properties file parameters
wls_servername=oim_server1
application_name=oim
metadata_from_loc=/home/oracle/eventhandler
9) Finnally Running the PurgeCache.sh All
10) Restarted the OIM Server.
11) Testing
I have logged into the OIM Admin Console >> Search the User > Update the First Name. The event handlers are not invoked any create or update operation. I am not able to see the log entries into the log file.
My Log Entry Configuration.
log File Configuration :
/u01/app/wl-10.3.5.0/Oracle/Middleware/user_projects/domains/oim_domain/config/fmwconfig/servers/oim_server1/logging.xml
<log_handler name='test-handler' level='FINEST' class='oracle.core.ojdl.logging.ODLHandlerFactory'>
<property name='logreader:' value='off'/>
<property name='path' value='/u01/app/wl-10.3.5.0/Oracle/Middleware/user_projects/domains/oim_domain/servers/oim_server1/logs/test-event.log'/>
<property name='format' value='ODL-Text'/>
<property name='useThreadName' value='true'/>
<property name='locale' value='en'/>
<property name='maxFileSize' value='5242880'/>
<property name='maxLogSize' value='52428800'/>
<property name='encoding' value='UTF-8'/>
<logger name="TEST-LOGGER" level="FINEST" useParentHandlers="false">
<handler name="test-handler"/>
<handler name="console-handler"/>
</logger>
Is there anything is missing while deploying the event handlers.
Help is Greatly appreciated.Change as per the following :
1. Put the event hander in the /home/oracle/eventhandler /metadata/metadata directory and
2. Change the following in the weblogic properties
application_name=OIMMetadata
metadata_from_loc to =/home/oracle/eventhandler/metadata
This will work. -
Multiple menu items != multiple event handlers?
I'm developing a program whereby a user can rate how much they like certain images when displayed on screen. The bulk of the work is done, but my rating mechanism (first attempt at one) is currently a right-click pop-up menu with the values 1-10 in ten menu items - naff I know, but its early design stages ;)
This brings obvious problems, and I don't want to have to code event handlers for each and every Menu item just to set the same parameter to a different value depending on which menu item the user clicked (i.e. I don't want to have to create an event for the first menu item that simply sets and int variable to 1, and do the same for #2 through 10). What I was wondering was, is there any simpler way of implementing this? I.e. can I use the same event for the whole popup menu and detect the value of the option clicked and set the value accordingly? This would also mean, should I need to extend the rating scale above ten, say perhaps to twenty, then there would be no further coding necessary (which is nice! Lol!).
Can anyone offer any suggestions? I did search, but tbh didn't have a clue what to search for. Your advice is appreciated.Implement the ActionListner that allows the constructor to take an argument as to the rating of the menu item, and then set the required rating variable to this when called. For example
class MyRatingSystem
int rating = 0;
public void createMenus()
JMenu ratings = new JMenu("Ratings");
for(int i = 0; i < 10; i++)
JMenuItem rating = new JMenuItem("Vote: " + i);
rating.addActionListener(new RatingListener(i));
ratings.add(rating);
class RatingListener imlpements ActionListener{
final int rate;
public RatingListener(int rate)
this.rate = rate;
public void actionPerformed(ActionEvent ae)
rating = this.rate;
}The above code is inefficient and is only there to serve the purpose of an example(look at the loop, although I would think the compiler could do some loop unrolling?)
HTH -
Portal Forms (9ias) JavaScript Event Handlers
For each form field it is possible to write event handlers in Javascript e.g OnFocus
//On BLUR effectively prevents the field from ever gaining
//focus.
this.blur();
There are no PL/SQL event handlers at field level. Is there any way that we can call PL/SQL code from the Javascript event?
Thanks in Advance.In case of do_event(), you can do a view source of the form's runtime page and lookup the code. It's a simple javascript that set values to some hidden variables.
When you do a view source , you will find some javascripts like :-
<SCRIPT TYPE="text/javascript" SRC="<some-url>">
Copy the url and paste it on a new browser window and try to access it. In case of IE, it will prompt you for a file download. Download the file as a text file and you will get to see the code. -
OIM entity adapters vs event handlers
Hi everyone
What is the difference between running code in a pre-insert entity adapters and pre-insert event handler?
I have an adapter that generates and emails random user password but it has some undesirable actions such as running multiple times even though trusted reconciliation has failed. Are event handlers more suitable for this task?
Thanks in advanceevent handler:A resource object's provisioning process contains tasks that must be completed automatically. When this occurs, you must assign an event handler or an adapter to the resource object. An event handler is a software routine that provides the processing of this specialized information
adapter :An adapter is a specialized type of event handler that generates Java code, which enables Oracle Identity Manager to communicate and interact with external resources.
Edited by: sk on Sep 9, 2010 2:53 AM
Maybe you are looking for
-
How to get the outline of a "bordered" polygon
Hi all, I wonder if it's possible with the standard APIs to get the outer shape of a polygon painted with a thick pen. In other words, I would like to get the shape that outlines my polygon when I draw it using a thick BasicStroke. Using the createSt
-
Modifying existing mail rules now even worse with Mavericks 10.9.1
Mail nightmares continue with Mavericks update 10.9.1 installed. In fact, the nightmare gets bigger. The story goes like this. Prior to Mavericks, I created a stack of rules to move Mail messages from the Inbox to designated Mailboxes, e.g. messages
-
Hi all, I'm running into this odd behaviour. I serialize java.util.Date objects to cache and when I read them back from cache, they appear to be java.sql.Timestamp types. I've isolated a junit test for that. Do you know why Coherence changes the type
-
Excise values not flowing in J1IS
Hi., I have done return delivery of a material document with 122 movement type....In this 122 material document ..No Excise Entry is selected. While doing J1IS with reference to 122 material document,excise values are not flowing . If i do create & p
-
Setting the duration of imported .png files
I have just upgraded from IMovie to FCP I am making a movie of hundreds of sequenced .png (or.jpg) images produced by an scientific application I want each image to have a duration in the movie of .1 secs. Whatever I do, each image is impoorted with