w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I pass the event handler to a custom trigger handler
Like this: $(window).keydown(function(e){ $(document).trigger({ type:"start", userEvent:e }); }); function moveWorldStart(e) { console.log(e.userEvent) } Have a look at JSFiddle: http://jsfiddle.net/qyL56/ Have a look at documentation: http://api.jquery.com/trigger/

Categories : Javascript

Trigger event handler with custom event object
You can try with .trigger() it accepts an event object as the argument $('#Element1').trigger(event); Demo: Fiddle

Categories : Javascript

JPA schema validation - how to raise an informative error message on discrepancies in column definitions and keys?
With EclipseLink you can enable the integrity checker to validate the schema. http://wiki.eclipse.org/EclipseLink/Examples/JPA/IntegrityChecker

Categories : Validation

Raise django admin validation error from a custom view
Not sure I understood what you want well: You have a view, by definition a public page. You want it to display an error message in the admin pages (by definition privates page) ? It's odd. But if you want so. To display an error in the admin pages, use the Django Message Framework. It's what is in use to display the yellow rows with errors/notifications on the top of the pages. from django.contrib import messages messages.error(request, "Something goes wrong sending transaction mail"); Indeed, validation errors an only displayed with forms. And thus, they are to be raised only in the clean() method of a form, a formset, or a field.

Categories : Django

Global event handler has no detail if the object that threw the exeception was created in an event handler
In the Release mode, many methods are inlined, so the call stack contains less methods than in the Debug mode. This is where your classes and methods disappear to in the exception. However, if you include all necessary PDB files, the stack traces of the exceptions should be retained, including line number information. So, make sure that when you run the application, the PDB file of the assembly which contains Page classes exists and is accessible.

Categories : Dotnet

Custom event handler is repeating itself
Make sure that you are removing the event handler from the same object that you are subscribing to. It looks like you are creating new object to un-subscribe from that event. SignIn signIn = new SignIn(); signIn.Login_Complete += new SignIn.EventHandler(recieveLoginResult); SignIn signin = new SignIn(); // this could be the problem...*** signin.Login_Complete -= recieveLoginResult;

Categories : C#

Umbraco - error when using umbraco.library:NiceUrl(...)
Ok I found a solution: I added an extra check to this part: <!-- Return the url --> <xsl:if test="$i = $max"> <xsl:if test="$id != '' "> <xsl:value-of select="umbraco.library:NiceUrl($id)" /> </xsl:if> </xsl:if> this fixed my problem.

Categories : Xslt

Setting a custom cookie in the HTTP headers inside a SOAP Message handler
We also needed to get a JSESSIONID recent - and to pass it back in subsequent requests. Using various different answers (mostly from StackOverflow and an example of an SSO client on the IBM site) we extended SOAPHandler to do it: import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.List; import javax.xml.ws.handler.MessageContext; import javax.xml.ws.handler.soap.SOAPHandler; import javax.xml.ws.handler.soap.SOAPMessageContext; import com.sun.istack.internal.Nullable; public class SoapMessageHandler implements SOAPHandler<SOAPMessageContext> { private String sessionCookie = ""; @Override public void close(MessageContext arg0) { } @SuppressWarnings({ "rawtypes", "unchecked" }) @Override publi

Categories : Java

How to trigger inner class event handler inside an event handler (JAVA)
Just attach the ActionListener directly to the JTextField. It will be triggered when ENTER is pressed. This is build-in behavior of the JTextField. For further reference: Do not attach a KeyListener to a JTextComponent. Use DocumentListener and/or DocumentFilter You should have used (new handler()).actionPerformed( new ActionEvent( ... ) ); to make your code 'work'

Categories : Java

(Why) does raise reset the signal handler?
Apparently, the behavior of signal + raise is specified as such. From Wikipedia's article on sigaction: ... replacement of the unreliable and deprecated signal() function. Signal handlers installed by the signal() interface will be uninstalled immediately prior to execution of the handler. Permanent handlers must therefore be reinstalled by a call to signal() during the handler's execution, causing ... So it seems this is expected behavior. (Of course, the MSDN docs seem to completely fail to mention this.) Question here on SO: What is the difference between sigaction and signal?

Categories : Visual C++

How do you attach an event handler to a nested custom user control? VB.net
You need to cast user control to the specific one explicitly, because regular UserControl doesn't have TaskChanged event. Something like this - Dim Uc = TryCast(e.Row.FindControl("TaskResourceAssignment"), TaskResourceAssignment)

Categories : Asp Net

INotifyDataErrorInfo Entity-Level Validation. How to raise a Validation.Error event?
Event Validation.Error is an RoutedEvent and its always raised once your validation returns false in a binding. <StackPanel Validation.Error="OnError"> <TextBox Text="{Binding PropertyName, ValidatesOnNotifyDataErrors=True, NotifyOnValidationError=True}" /> </StackPanel> Inside your code behind of MainWindow you will need something like this: public void OnError(object sender, ....) { .... }

Categories : C#

how to catch php E_PARSE error with custom error handler?
here is a snippet from the documentations The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called. E_PARSE stops the execution immediately so it will have no way to call any other function

Categories : PHP

Check, at Runtime, for a Custom PHP Error Handler
You can set your own error handler, and get return value of set_error_handler - if it is null there was no error handler defined: $last_error_handler = set_error_handler(function(){}); if ($last_error_handler === null) { restore_error_handler(); } else { // Set it back to what was defined set_error_handler($last_error_handler); echo "Found"; }

Categories : PHP

An internal error occurred during: "JPA Facet File Change Event Handler"
I faced the same issue. Based on this bug report on Eclipse - NoClassDefFoundError with JPA projects I had to uninstall the Hibernate Tools plugin to fix the error. Looks like the base Eclipse doesn't have an issue, but if you have installed JBoss Tools plugins, they provide a non-compatible version of JPA classes, and that causes the issue.

Categories : Java

python raise KeyError message with color
These Exceptions' behavior are different. KeyError does following action with message passed If args is a tuple of exactly one item, apply repr to args[0]. This is done so that e.g. the exception raised by {}[''] prints KeyError: '' rather than the confusing KeyError alone. The downside is that if KeyError is raised with an explanatory string, that string will be displayed in quotes. Too bad. If args is anything else, use the default BaseException__str__(). One can use following workaround for this: Create own class with repr overrided: for example class X(str): def __repr__(self): return "'%s'" % self raise KeyError(X('x1b[31m ERROR x1b[0m')) but I realy don't understand Why this can be needed... I think @BorrajaX comment is better solutio

Categories : Python

Is it smelly to raise an event from within another event?
While I have seen it, I would recommend against it and raise the event in methods that it would occur in, like your UnitCount setter. Since you have the virtual access modifier keyword, someone could override the method and if they don't call the base object it wouldn't work as expected. I'm not a fan of making it more complicated to use my code.

Categories : C#

symfony 2 how to display the error after login with custom authentication handler
You probably want to display a message to the user. You can display a flash message and redirect the user. $request->getSession()->setFlash('error', $exception->getMessage()); If you look at the FosUserBundle they display a message direcly in the template https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/views/Security/login.html.twig https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Controller/SecurityController.php Hope it's helpful Best regard

Categories : Authentication

C# and VB.NET raise event differences
acceptClient() would call a method acceptClient with no arguments and return a result. What you want is to add the method as an event handler: mAcceptor.OnAccepted += acceptClient; Note the lack of parentheses; you're using the method instead of calling it.

Categories : C#

When I raise event it is always null
Try starting the background worker after execute: var uc = new MyUserControl(); uc.ViewModel.ValueTypeChangedEvent += OnValueTypeChanged; And also be sure that the instace of view model you are raising the event is your user control view model. Hope this tips helps... EDIT Had you tried to execute the action that raise the event in the other thread using a SynchronizationContext? Like this: //Register the events var currentSyncContext = SynchronizationContext.Current; var backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += (_,__) => { //some action in background currentSyncContext.Send((t) =>

Categories : C#

"Handler for Request not found" error after attempting to implement custom ServiceStackHttpHandlerFactory
Does adding this to the LoginAppHost Configure method correct your issue? Public Overrides Sub Configure(container As Funq.Container) 'Set JSON web services to return idiomatic JSON camelCase properties ServiceStack.Text.JsConfig.EmitCamelCaseNames = True 'code in the config options SetConfig(New EndpointHostConfig With { .ServiceStackHandlerFactoryPath = "api", 'path where ServiceStack is hosted .MetadataRedirectPath = "api/metadata" 'redirect path for /api to show meta data }) End Sub I'm not quite sure why the 'config' elements wouldn't get picked up from the web.config file but this should explicitly handle the location/path issue. Also, not sure about your environment but this should work using Visual

Categories : Asp Net

Python - Handler doesn't detect the custom handler class
Your sys.path needs to contain the project/confs directory, otherwise you won't be able to import the custom_handler module. Try again after ensuring that is the case. Update: I'm not sure log.py is the place to set your path. There is no one right way to do this - there are various tutorials for how to set up Python projects.

Categories : Python

in vb.net how do I raise a click event for a label
Let's say your label is named Label1. This Sub is the Sub that will be executed when you click on the label. Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub To raise a label click, you just need to call that event. Label1_Click(Label1, Nothing) That's it :)

Categories : Vb.Net

Why we should use temprary object to raise event?
You're not creating a temporary object. You're using a local variable to avoid a race condition. In this code: if (PropertyChanged != null) { PropertyChanged(...); } it's possible for PropertyChanged to become null (due to the last subscriber unsubscribing) after the nullity check, which will mean you get a NullReferenceException. When you use a local variable, you ensure that the reference you check for nullity is the same reference that you use to raise the event - so you won't get the exception. There's still a race condition in that you may end up calling subscribers who have just unsubscribed, but that's unavoidable.

Categories : C#

Raise event if any control has been changed WPF
<TextBox HorizontalAlignment="Left" LostFocus="OnLostFocus"/> Here's an easy way. Validate using the LostFocus Event in WPF private void TextBox_LostFocus_1(object sender, RoutedEventArgs e) { var thisTextBox = (TextBox)sender; if (thisTextBox.Text == "") { MessageBox.Show("Validate!"); } }

Categories : C#

Raise event upon population of DataTable
Add the declaration of the Event inside the ExcelReader class and call it at the end of your code using the RaiseEvent Public Class ExcelReader Public Event DataTableLoaded(ByVal dt As DataTable) ....... Using cn = New System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.12.0;.......") Using cmd = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", cn) cn.Open() cmd.Fill(DT) RaiseEvent DataTableLoaded(DT) End Using End Using .... End Class Then the calling code declares (globally) an instance of the ExcelReader class with the keyword WithEvents Public Dim WithEvents readerTableFromExcel = New ExcelReader() Finally the declaration of the methods that handle the event (the event sink) P

Categories : C#

Can exception handler get access to globals and locals variables at exception raise?
The stack trace is a linked sequence of frame objects; each frame object has a reference to the globals and locals for that frame. The traceback object has a tb_frame attribute, this is the 'current' frame. The object also has a tb_next attribute, the link to the next traceback object in the stack. Each frame object has f_globals and f_locals attributes, both are dictionaries. The inspect module documentation has a handy overview of the attributes found on traceback and frame objects. You may want to look over the traceback module; it provides a higher-level API to manipulate and display tracebacks.

Categories : Python

How to run a program to monitor a directory 24/7 and raise an event
Not sure which version of Visual Studio you are using. Choose the Project Template "Windows Service". Windows service is a computer program that operates in the background similar to Unix Daemons.

Categories : Windows

Raise event when any of class method called
You should use AOP to do that. A simple approach would be to inherit from ContextBoundObject, check this article for detailed information.

Categories : C#

Can I raise an exception from within OnTerminate event of a TThread?
I don't know why you want to raise the exception in the main thread, but I will assume it is to do minimal exception handling - which I would consider to be something like displaying the ClassName and Message of the Exception object in a nice way on the UI. If this is all you want to do then how about if you catch the exception in your thread, then save the Exception.ClassName and Exception.Message strings to private variables on the main thread. I know it's not the most advanced method, but I've done this and I know it works. Once the thread terminates because of the exception you can display those 2 strings on the UI. All you need now is a mechanism for notifying the main thread that the worker thread has terminated. I've achieved this in the past using Messages but I can't remember the

Categories : Delphi

Why the Process Exited event raise automatic all the time?
zipFileDirectoryProcess.StartInfo.FileName = "explorer.exe"; Trying to start Windows Explorer again when it is already running, and it is always running, will have a disappointing outcome. It is a "heavy" process and it intentionally tries the minimize the number of running copies. Otherwise known as a "single-instance app". There are lots like that, the Microsoft Office programs are single instance apps for example. So what really happens is that explorer.exe actually starts up, but sees that another instance is already running. And uses process interop to ask that first instance to do the job that you asked it to do. Since you didn't ask it to do anything, you just get another window, displayed by the first instance. The one that you started immediately quits, it doesn't have

Categories : C#

How to implement custom controllers in Umbraco 6
Do you really mean you want a custom controller, or do you actually just want to create a form in Umbraco using MVC? If it's the latter then you need to use a surface controller ie. ensure your controller inherits from Umbraco.Web.Mvc.SurfaceController and has the suffix 'SurfaceController'. public class MySurfaceController : Umbraco.Web.Mvc.SurfaceController { public ActionResult Index() { return Content("hello world"); } } You then need to use the custom Umbraco Html helper to create your form tags: @using(Html.BeginUmbracoForm("CreateComment", "BlogPostSurface")) { // } See http://our.umbraco.org/documentation/Reference/Mvc/forms

Categories : C#

In Umbraco 6.1.1 MVC 4, how can I do a form post back to a surface controller using a model that inherits from Umbraco's RenderModel?
Ok, I've had no responses to this question but am now in a position to answer it myself. Maybe it was a fundamental oversight, but not that obvious imho, and information on the Umbraco forum etc about inheriting from RenderModel is fairly limited. Essentially the answer, as was my first instinct, is to solve the original exception "No parameterless constructor defined for this object" by providing a paramaterless constructor. The difficulty is working out what to put inside the parameterless constructor for my model, since it inherits from the Umbraco RenderModel which requires an IPublishedContent instance passed to it's constructor. Luckily while browsing around I happened across this post on the Umbraco forum: http://our.umbraco.org/forum/developers/api-questions/40754-Getting-Curre

Categories : Asp Net Mvc

signal handler vs event handler
I found that user have to write event handler function in order to capture events while default signal handlers are provided by kernel for the program. Event handlers take care of the events external to the program like keyboard interrupt, mouse click etc. Event handlers would be polling continuously on a particular slot for the event to happen. So here it might consume the CPU life cycles. Signal handlers also used for interprocess communication between two process. User can define their own signal handler for the process to handle particular signals. In signal handling mechanism I don't think any CPU c

Categories : C++

How to raise a jquery event when an element with some class is created dynamically
The word you may be looking for is observables. In essence, when the DOM (or in this situation a span element) is updated you'd like to trigger an event. For that answer I'd like to direct your attention to this response, http://stackoverflow.com/a/240663/191006 Ken illustrates that capturing all DOM changes at the top will allow you to pick and choose what do to on certain inner elements. $('body').change(function(event){ if( $(event.target).hasClass("lotoDateTime") ) processDateTimes(); }); You could certainly clean this up... you don't need to check for the class like I am... but I hope that helps you get going in the right direction.

Categories : Javascript

jQuery - raise event when focus leaves a group of controls
I would consider using a timer to solve this tricky dilemma. When focus is lost, start the timer. Then you can cancel the timer if focus is then set upon another "safe" input. Something like this: var timeoutID; $("#TheSafeZone input").focus(function () { if (timeoutID) { clearTimeout(timeoutID); timeoutID = null; } }); $("#TheSafeZone input").blur(function () { releaseTheHounds(); }); function releaseTheHounds() { timeoutID = setTimeout(function () { alert("You're all going to die down here"); }, 1); } Here is a working example NOTE: I have set the timeout to just 1ms, this seems to work reliably for me but it may be worth doing a few tests in other browsers (I am using Chrome). I guess it is down to how the JS engine handles events

Categories : Javascript

knockout, set property value changes view, which doesn't raise change event
Instead of using change, use the Knockout subscribe function. Observables Documentation viewModel.email.subscribe(function(newValue) { // Called whenever the value is updated doSomethingWithNewValue(newValue); });

Categories : Javascript

Custom error message using WiX setup
You can do this using properties. Use the Bitmap control to set the icon. <Binary Id="RightClick" SourceFile="ResourcesRight.jpg" /> <Binary Id="WrongClick" SourceFile="ResourcesWrong.jpg" /> Use SetProperty or CustomAction to set the property value based on a condition and pass the value to the Bitmap control. <PropertyRef Id="NETFRAMEWORK40FULL" /> <Property Id="NETFramework_Icon" Value="WrongClick" /> <SetProperty Id="NETFramework_Icon" Value="RightClick" After="AppSearch">NETFRAMEWORK40FULL</SetProperty> In dialog, <Control Type="Bitmap" Id="NETFramewor40ico" Width="20" Height="20" X="240" Y="70" Text="[NETFramework_Icon]" /> Regarding the second query, disable the next button if any prerequisites are not installed or throw a cu

Categories : Wix

Custom error message with DataAnnotationsExtensions
I ended up using a mix of System.ComponentModel.DataAnnotations and DataAnnotationsExtensions. I found out out that most of the time data annotations will also make client side validation. The only time where is no client side validation, is when I check if the phone number is the correct length. public class NpRequest { [DisplayName("Phone number")] [MinLengthAttribute(8, ErrorMessage = "Phone number must be 8 digits")] [MaxLengthAttribute(8, ErrorMessage = "Phone number must be 8 digits")] [DigitsAttribute(ErrorMessage = "Phone number must be 8 digits")] [Required(ErrorMessage = "Phone number is required")] public string PhoneNumber { get; set; } [DisplayName("Modtagers email adresse")] [EmailAddressAttribute(ErrorMessage = "Invalid email")] [Requi

Categories : Validation

Umbraco MVC Implementation - View does not depend on Umbraco implementations
No you can't. Simply because all requests pass through a single action. In order to retrieve a path to a CMS-managed page, you need to use the node/content traversal the @Model provides. See here for more details on this. Edit To clarify, the author of the article is suggesting that the Umbraco implementation should be more in line with a traditional MVC implementation with little or no logic in the views. Therefore, any querying of node data should happen prior to the view (e.g. in the Mappers). So this is where you would have to retrieve the links. Umbraco's default MVC implementation forces all requests to go via a single action on a single controller. The author's implementation allows the requests to be shared across one controller per document type - which is better IMO. But it st

Categories : Asp Net Mvc



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.