cancel
Showing results for 
Search instead for 
Did you mean: 

Calling action method inside an event

Former Member
0 Kudos

Dear Experts,

I am calling action method inside the event. Is i OK in Webdynpro Java. Please find the below details-

public void onActiononConfirm(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActiononConfirm(ServerEvent)

opening Confirmation Dialog box with Yes or No buttons

//@@End

}

In YesHandle---Again i am calling above onActionConfirm() method for the requirement

public void okTenderHandle(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin okTenderHandle(ServerEvent)

wdThis.onActiononConfirm(wdEvent);

//@@end

}

It is successfully working and executing the code. My question is- is there any problem while calling action method inside event?

Thanks in Advance.

Regars,

Vijay.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can do other way,

Define a method with the code as in your Action Block. Then call this method from your action and event handler.

Regards

Saravanan K

Former Member
0 Kudos

Dear Sarvanan,

Tahnsk a lot for your fast responce. Here my problem is, I don't want to change or remove the code from button action. Because in that button action so much code is there and entire project depends on that button action code. (morethan 2000 lines).

That's why i am, planning to call that button action again from OKHandle of the confirmation box. Because if the user clicks on the YES then only the remaining code of the button action should execute.

My doubt is , is there any problem to call like taht. Till now i haven't foound any error and all the code is executing perfectly.

Thanks in Advance.

Regards,

Vijay.

Former Member
0 Kudos

Hi,

According to me, there is no problem in this but if a piece of code is called in more than one place, it is nice to define it in a common place say in method and call this method from the required places. Still you can write the confirmation code in a separate method and call this method from action and event handler.

Regards

Saravanan K

Former Member
0 Kudos

Hi Sarvana,

Yes, you are correct. But the client will not agree to remove the code from confirm button. That's why i thought, again i have to execute the Confrim button code from OKHandle of the confirmation dialog. Pease find the below code i have written in OKHandle.

//@@begin javadoc:okTenderHandle(ServerEvent)

/** Declared validating event handler. */

//@@end

public void okTenderHandle(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin okTenderHandle(ServerEvent)

tenderReason=false;

wdThis.onActiononConfirm(wdEvent);

//@@end

}

In the above code, i have written-- wdThis.onActiononConfirm(wdEvent);

Here i have passed the parameter "wdEvent" of the okTenderHandle().

And please help me, the code is correct?(wdThis.onActiononConfirm(wdEvent);)

Thanks in advance

Regards,

Vijay.

Former Member
0 Kudos

Hi Vijay,

An action is a method which can be triggered by an event. Hence calling it the way you are doing would perform your task.

But the actual way of doing it is to create a method and call it on n number of actions as required. Writing the logic in action or writing it in a method and calling it in action is same. hence client shouldnt create any problem on this coding.

In fact if you should create the method in component controller instead of view controller which can be reused by other components as well if required.

thanks n regards

Deepak

Former Member
0 Kudos

Dear Deepak,

Thanks a lot. Its already exixting project and i don't have a autherization to change the exisiting code. That's why i don't want to touch the existing code. Just i have created event and again i am calling this action method under the event.

Thanks in Advance.

Regards,

Vijay.

Former Member
0 Kudos

Hi,

if you cant change any code then you have no option but to use it. it would work.

Regards

Deepak

Former Member
0 Kudos

Hi,

If you are not able to do the changes, just leave it as it is and it will work

Regards

Saravanan K

Answers (0)