cancel
Showing results for 
Search instead for 
Did you mean: 

How to activate an event handler manually?

Former Member
0 Kudos

Hello,

I have a dropdown box which has an event handler for it's onSelect. How can I activate this event handler manually somewhere at the code without the user actually activating it when selecting a value from the box?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Roy,

If you just need to call an event handler, you can call it just like calling any other method, having a null value for the event parameter. Identify the eventhandler for the event you have assigned for the 'onSelect' property. If you have named your event as 'MyEvent' by default the eventhandler created would be something like 'onActionMyEvent(wdEvent event)'. Now you can call this eventhandler anywhere explicitly like 'onActionMyEvent(null)'.

If this is not what you were looking for, pls ignore this post.

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Well, a problem.

When simply call onActionMyEvent(null) I receive an Iternet Explorer error: "Internet Explorer cannot open the internet site..."

The onActionMyEvent I'm calling opens another window and I suppose the null value cannot be accepted...

Any ideas...?

Former Member
0 Kudos

Refactor the functionality from the action handler into a method and call that method from wherever you need to.

Armin

Former Member
0 Kudos

Roy,

<i>The onActionMyEvent I'm calling opens another window</i>

AFAIK, opening new window should be the latest operation for request / response cycle -- at least I saw this references in API docs.

So it seems this is indeed latest operation <b>in error handler</b>, but code that manually invokes this handler has some post-processing, that conflicts with opening window.

Just a guess...

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hi Roy,

Whenever we try to open a new wndow or confirmation in the wdDoInit(), we get this error. I myself had wanted to ask the forum abt this.

Valery,

If we have a requirement to show a dialog initially when the application loads, where else do we have to write the code? If possible, can you please give us a more detailed picture about why this is happening?

Thanks & regards,

Nibu.

Former Member
0 Kudos

Nibu,

Here is a cut from IWDWindow.open() API docs:

<i>Method opens the window. In the current request/response- cycle, <b>no further manipulations are allowed</b></i>

Actually, I do not know why this happens, but you may use simple workaround for your task -- use Timer UI element with minimal (1 second) delay, in event handler disable timer and show your confirmation window.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hey Valery,

Could you please elaborate this with some code example? I am not much familiar with the Timer UI element...

Former Member
0 Kudos

Roy,

1. Place TimedTrigger UI element on view ("Layout" tab)

2. Create attribute Delay in context (type integer)

3. Bind "delay" property of UI control to this attribute

4. Create action handler for "onAction" and assign it to UI control event

5. Do the following in action handler:

-- a. wdContext.currentContextElement().setDelay(0) -- this disables trigger

-- b. open confirmation dialog / other internal window

6. In wdDoInit write wdContext.currentContextElement().setDelay(1) -- to activate trigger

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

It's working 10X

Very nice workaround Valery, Well done!

Former Member
0 Kudos

I faced the exact same problem. Valery ur solution is a perfect workaround for this.

Thanks a million !!!

Wish i could award u points...

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Create another event and use the same eventhandler for this event also.

In your code whenever you want to activate this eventhandler, raise this custom event.. !

But why do u need this ? instead .. u can check some condition in the onselect event handler and call another function appropriately.

Regards

Bharathwaj

Former Member
0 Kudos

Hey Bharathwaj,

Thank you for your response, but why do I need to create another event handler, can't I simply use that one that was created for the onSelect already?

The reason I need this is because onSelect of combo1 I change the values on combo2 and on Init I would like that combo2 will contain already values when I set combo1 it's default value from the list...

Roy

Former Member
0 Kudos

Hi ,

In my previous post i have said,

<i>"Create another event and use the same eventhandler for this event also."</i>

We are creating a EVENT here(which is handled by onSelect's event handler ). The event handler is the same

Regards

Bharathwaj

Former Member
0 Kudos

And how do I create another event...?

Former Member
0 Kudos

Hi,

In the view, we have layout,implementation,action, etc.,

Select action -> New -> action .

While creating the action , it will by default have "use default" event handler selected.

Instead select "use existing" and select the event handler used for dropdown.

Now in your code call this action. Or in case of events.. u have to go the controller.. create a event ,move from controller to view and make it overtly complex manner.. !

Regards

Bharathwaj

Former Member
0 Kudos

Sounds logical, but how do I call the custom even I've created? What is the syntax to do that?

Former Member
0 Kudos

you got ur answer already !

Former Member
0 Kudos

Yes I did. Thank you very much to both of you, points are on their way...