cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass parameters /values through plugs.

konchada_saikrishna
Active Participant
0 Kudos

Hi All,

How can we pass parameter from one view to another through fire plugs,

In view1 I created a out bound plug with a parameter, and I am firing it as

wdThis.wdFirePlugTo_View2("XXX");

How can I receive this value in the view2.

Thanks in advance,

Regards,

Sai Krishna.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

At the time of declaring your plug in method u need to declare param and you capture the second View.

When you create the param the method will automatically diplays the param .

thanks,

Lohi.

konchada_saikrishna
Active Participant
0 Kudos

Hi Lohi,

My Action method is like this,

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

{

//@@begin onActionClick(ServerEvent)

wdThis.wdGetEHS_WSOCustController().Getfileds("XYZ");

wdThis.wdFirePlugTo_View2("ZZZ"); //here the parameter name is FormType.

//@@end

}

How/where to catch this FormType Variable in view two.

Regards,

Sai Krishna.

arun_srinivasan
Contributor
0 Kudos

Hi

check whether u have input plug Event handler in the View 2

as mentioned in above post

Regards,

Arun S

konchada_saikrishna
Active Participant
0 Kudos

HI Arun,

Yes I Do have an Inbound plug in view2,

prior to the requirement of passing a value through the fire plug, I could sucessfully navigate to the View2.

Regards,

Sai.k.k

arun_srinivasan
Contributor
0 Kudos

hi

in the second view

public void onPlugin(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String param )

{

//@@begin onPlugin(ServerEvent)

//@@end

}

param is the value u pass

regards,

Arun

konchada_saikrishna
Active Participant
0 Kudos

Hi Arun,

I added a Public variable in the view, I added the method as you have shown, Assigned the param value to this public variable.

when I save the meta data the method is present, when I rebuild the project the method and the variable are removed, and all the dependent code gives an error.

Regards,

Sai Krishna.

arun_srinivasan
Contributor
0 Kudos

hi

check whether u r declare the Parameter in correct way

One the ways to declare parameter

1)click the plug tab

2)Select the corresponding outbound plug/inpound and create the parameter by selecting new button near to parameter dialog

Hope this helps,

Regards,

Arun S

konchada_saikrishna
Active Participant
0 Kudos

Hi Arun,

I already added the parameter to the out bound plug as you specified,

this is the code I have in the view2.

public String inboundparam =" ";

public void onPlugin(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String param )

{

// @@begin onPlugin(ServerEvent)

inboundparam = param;

// @@end

}

When I save the meta data the code is present, but when I rebuild the project the added code is vanished.

Regards,

Sai.k.k

arun_srinivasan
Contributor
0 Kudos

hi

check whether u declare this code between this begin and end which is at bottom it is for global declaration within view

<b> //@@begin others

public String inboundparam =" ";

//@@end</b>

regards,

Arun

konchada_saikrishna
Active Participant
0 Kudos

Hi,

Previously I had it out side the "others" block, but Now I placed in this block.

The code resists there, but the code in this method is not executed or I dont know wether the code in this method is being executed or not,

Here is the code.

//@@begin others

public String FormType =" ";

public void onPlugin(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String param )

{

// @@begin onPlugin(ServerEvent)

IWDMessageManager mgr = wdThis.wdGetAPI().getComponent().getMessageManager();

FormType = param;

wdContext.currentContextElement().setFormHeader(param);

mgr.reportSuccess(param);

mgr.reportSuccess(wdContext.currentContextElement().getFormHeader());

// @@end

}

//@@end

Regards,

Sai.k.k

Former Member
0 Kudos

Hi,

public void onPlugin(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String param )

{

// @@begin onPlugin(ServerEvent)

IWDMessageManager mgr = wdThis.wdGetAPI().getComponent().getMessageManager();

wdContext.currentContextElement().setFormHeader(param);

mgr.reportSuccess(param);

mgr.reportSuccess(wdContext.currentContextElement().getFormHeader());

// @@end

}

it will work like this no need to declare once again param .

Thanks,

Lohi.

konchada_saikrishna
Active Participant
0 Kudos

Hi,

The statement "wdContext.currentContextElement().setFormHeader(param);" the form header value is not been set,

And also, I need this param value at several other places, so I am passing it to another variable.

Is that this method is executed before Init().

Regards,

Sai.k.k

former_member185029
Active Contributor
0 Kudos

Hi,

Switch to the view from which you are firing O/B plug.

Select Plugs tab.

Select the desired O/B plug from the list.

See whether you get the parameter in the Parameters list.

If not, add the desired parameter.

Also repeat the same excercise for I/b plug of the other view.

Let me know the results.

Ashutosh

arun_srinivasan
Contributor
0 Kudos

hi

Dont place the Onplugin code in others

1)only place FormType in others

//@@begin others

public String FormType =" ";

//@@end

2)The eventhandler onPlugin is Automatically generated

The Onplugin Eventhandler will reside seperately like doinit(),doexit()

public void onPlugin(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String param )

{

// @@begin onPlugin(ServerEvent)

IWDMessageManager mgr = wdThis.wdGetAPI().getComponent().getMessageManager();

FormType = param;

wdContext.currentContextElement().setFormHeader(param);

mgr.reportSuccess(param);

mgr.reportSuccess(wdContext.currentContextElement().getFormHeader());

// @@end

}

Regards,

Arun S

konchada_saikrishna
Active Participant
0 Kudos

Hi Ashutosh,

I have already added the parameter to both inbound & outbound plug.

Regards,

Sai.k.k

konchada_saikrishna
Active Participant
0 Kudos

Hi Arun,

I placed the variable in the others block as you said i.e.,

//@@begin others

public String FormType =" ";

//@@end

but I could not see the Onplugin Eventhandler any where in the view2 code.

Regards,

Sai.k.k

arun_srinivasan
Contributor
0 Kudos

hi

In the Second View u check whether u having the inbound plug

1)click the plug tab in view 2 and check for inbounf plug

2)click the implementation tab and check whether u having eventhandler for that.U can also check by selecting the implementation Tab and switch over to OUTLINE View.There u check for ur event handler onplugin

Regards,

Arun S

konchada_saikrishna
Active Participant
0 Kudos

Hi Arun,

yes I could get that inbount plug event handler,

but the value assigned from the inbound plug paramater to the FormType variable which declared in the others block, is not getting. so now I created a value attribute in the custom controller and assigning the value to this attribute, and fetching this value in the view2.

Actually my requirement is, there is a menu with three Linktoaction (employee, vendor, contractor) when the user clicks a link from the three, view2 is to be triggered and a parameter is to be passed, with this parameter I would decide which details to be shown on the view2.

The problem I am facing is :

If for the first time a user clicks employee, employee details are shown in the view2.

and if he clicks vendor later, it triggers to view2 but shows employee details only.

and similarly for vendor.

i.e, which ever the link the user clicks for the first time, it remains for the entire application.

Regards,

Sai.k.k

arun_srinivasan
Contributor
0 Kudos

hi

Try this out

Set the value of the ValueAttribute to Null while u go back to view1 again.

write this code in onactionback or some thing u using wdContext.currentContextElement().set<ValueAttribute>(null);

Please post u code or explain me in detail if the issued is not solved

Regards,

Arun S

konchada_saikrishna
Active Participant
0 Kudos

Hi Arun,

In my application, I used a frame set, there will be Header view on top, there will be a menu view on left, and there would be a welcome message on right.

when the user clicks the link from left menu, the respective form is to be displayed on the right side.

as you said, I am writing this code in the Exit() of view2, but the value everything remain same as I said in the previous post.

wdContext.nodeF4Output().invalidate();

wdContext.currentContextElement().setTransaction(" ");

wdContext.nodeFieldsList().invalidate();

Is this what you want me to do ...

Regards,

Sai.k.k

konchada_saikrishna
Active Participant
0 Kudos

Hi,

I could pass parameter from one view to another,

Thanks for all your sugessions,

Here I am Giving you the full points,

Regards,

Sai Krishna.

arun_srinivasan
Contributor
0 Kudos

hi

please let me know what mistake u have down

regards,

Arun S

konchada_saikrishna
Active Participant
0 Kudos

Hi Arun,

Your solution is perfectly right, I am un aware of the OnINBoundPlug() method, and I thought We need to create a new method to catch the in bound plug.

But there is a small problem with the variables declared by us, and using them in the oninboundplug() method, how ever I created a new value attribute in the custom controller and binded it to the respective views. And this helped me in the application.

And Arun, I have 2 more small doubts, please help me ...

1) I Installed Sneak Preview in my local system, It is not displaying the detailed error list, it is just saying "Failed to process request. Please contact your system administrator." where and how to configure for this.

2) In view1 there is a button, on click of this, I am calling a method in custom controller, In the custom controller the code is like this

IWDMessageManager msg = wdThis.wdGetAPI().getComponent().getMessageManager();

msg.reportSuccess("yes");

IWDWindowInfo windowInfo = (IWDWindowInfo)wdComponentAPI.getComponentInfo().findInWindows("Witness_Window");

IWDWindow window = wdComponentAPI.getWindowManager().createWindow(windowInfo,true);

window.setWindowPosition(150,150);

window.open();

wdContext.currentWindowElement().setWindowInstance(window);

When I am trying to open a new window on click of a button, there is a error message like this

com.sap.tc.webdynpro.services.exceptions.InvalidUrlRuntimeException: Invalid URL=../../../resources/local/EHS_WSO/Components/com.sap.tc.projects.ehswso.EHS_WSOComp/<>

Regards,

Sai.k.k