Just started doing some code porting from .Net CF to Blackberry JDE 4.6.1. But haven't found how to implement custom events.
I have a custom syncManager that raise events in .Net CF so I can update the UI (sort of the observer patron).
Any pointers or help where I can start?
I can recommend the j2me-observer project. It has a liberal license and will give you an implementation of the observer pattern which isn't included in J2ME. It can be used to allow UI changes to happen based on fired events.
you can send custom event using.
//you can use any int value for CUSTOM_EVENT
fieldChangeNotify(CUSTOM_EVENT);
and you can handle that event using
public void fieldChanged(Field field, int context) {
if(cotext == CUSTOM_EVENT){
Dialog.alert("custom event");
}
}
I can recommend the open source project javaEventing. It's available at http://code.google.com/p/javaeventing , and makes it easy to define, register for and trigger custom events, much like in C#.
An example:
Class MyEvent extends EventManager.EventObject {}
EventManager.registerEventListener(new EventManager.GenericEventListener(){
public void eventTriggered(Object sender, Event event) {
// <-- The event is triggered, do something.
}
}, new MyEvent());
EventManager.triggerEvent(this, new MyEvent()); // <-- Trigger the event
bob
Related
I have a basic implementation of a custom render I will be using for handling Long Press.. It's all really based from this code http://arteksoftware.com/gesture-recognizers-with-xamarin-forms/
In my "GestureContainerView" I have an event that I called "OnHeldDown",
How do I raise this "OnHeldDown" event if (in my Android) detected a "LongPress" ?
I tried looking up in google but couldn't find an example.
----------- UPDATE ------- (found a solution)
in PCL
in Android
Just create a method which checks if anyone is subscribes to the event handler and invoke it, if anyone is.
For example, create a methode like this:
private void RaiseOnHeldDown()
{
if (OnHeldDown != null)
OnHeldDown(this, EventArgs.Empty);
// Or even do the null propagation way
// OnHeldDown?.Invoke(this, EventArgs.Empty);
}
Of course if you'd like you can supply EventArgs.
Now in the event where you detect the LongPress you just call this method.
How to check in Vaadin 7 if scrollbar is visible or not for a certain component, for example for Panel
Any implementation of AbstractClientConnector can be extended with AbstractExtension: https://vaadin.com/api/com/vaadin/server/AbstractExtension.html
An extension is a possible way to extend the functionality of your component: https://vaadin.com/docs/-/part/framework/gwt/gwt-extension.html
Adding features to existing components by extending them by inheritance creates a problem when you want to combine such features. For example, one add-on could add spell-check to a TextField, while another could add client-side validation. Combining such add-on features would be difficult if not impossible. You might also want to add a feature to several or even to all components, but extending all of them by inheritance is not really an option. Vaadin includes a component plug-in mechanism for these purposes. Such plug-ins are simply called extensions.
In the client-side extension implementation you can write your custom GWT code like following (pseudo code):
#Override
protected void extend(ServerConnector target) {
// Get the extended widget
final Widget widget = ((ComponentConnector) target).getWidget();
// register RPCs
YourServerRpcImplementation serverRpc = getRpcProxy(YourServerRpcImplementation.class); // client to server
registerRpc(YourClientRpcImplementation.class, this); // server to client, unused in this example
// add listener and update server state
Window.addResizeHandler(new ResizeHandler() {
#Override
public void onResize(ResizeEvent event) {
boolean scrollbarVisible = widget.getElement().getScrollHeight() > widget.getElement().getClientHeight();
serverRpc.yourEventMethod(scrollbarVisible);
}
});
}
Passing events between server and client: https://vaadin.com/docs/-/part/framework/gwt/gwt-rpc.html
I'm a rookie Dartisan. I've pushed test project on https://github.com/mackristof/DartWebComponentCommunication .
I want to find the best implementation for communication between 2 web components.If user click button on webComponent 1, how can counter webcomponent 2 can be informed ? Stream ? Bus-Event ?
Thxs for pull request with best solution.
Christophe.
For this type of communication I have implemented an event bus, and it has been quite useful for me.
If the event bus is defined at the app level, your event can look something like this;
void increment() {
eventBus.fire(clickEvent, 1)
}
And your counter component can be backed by a model object something like;
class CounterComponent extends WebComponent {
int get count => viewModel.count;
ViewModel viewModel;
}
and the ViewModel can look something like
class ViewModel{
int count;
ViewModel(){
eventBus.on(clickEvent).listen((msg){
count = count + msg;
});
}
}
I think web components can talk to each other through the parent/host DOM using events. When one web component will trigger some event, host/parent DOM should catch it and inform the other web components by changing their attribute values.
This way I think web components can communicate.
I need to run one of my macro when a page is published. I there any way to do this in umbraco
There are some events you can hook into. In your case you might use the Document_AfterPublish() event.
static void Document_AfterPublish(Document sender,
umbraco.cms.businesslogic.PublishEventArgs e)
{
// your code
}
// hook into the event
Document.AfterPublish +=
new Document.PublishEventHandler(Document_AfterPublish);
Also look at this and this links which could be helpful.
When writing a custom IPipelineContributor it isn't clear how to get a reference to the selected Handler. The purpose of the custom contributor is to dispose any handlers that implement IDisposable once they have returned a result.
Given the following code sample:
public class DisposerPipelineContributor : IPipelineContributor
{
public void Initialize(IPipeline pipelineRunner)
{
pipelineRunner.Notify(MyMethod).After<KnownStages.IOperationExecution>();
}
PipelineContinuation MyMethod(ICommunicationContext arg)
{
return PipelineContinuation.Continue;
}
}
The ICommunicationContext gives us access to OpenRasta's own type system and reveals the type of selected handler: [OpenRasta.TypeSystem.ReflectionBased.ReflectionBasedType] = {CLR Type: MySelectedHandler}. However, it isn't clear how to get the instance of the handler that was actually used to satisfy the request.
Iain,
first tings first, if you want features such as disposing of objects, you should use your own IoC container, most of those frameworks implement that functionality.
We're going to add disposing to the contract we have with containers in the next major version, as it is now more or less ok to do this, it wasn't when we built 2.0.
If you want to call IDisposable on a handler yourself and you cannot switch to a full-fledged IoC container, you'll find the handler instance in ICommunicationContext.PipelineData.