cancel
Showing results for 
Search instead for 
Did you mean: 

New to Web Dynpro

Former Member
0 Kudos

Hi Everyone: I am attempting to build a first, very simple Web Dypro application that goes beyond the tutorial materials. I have a web service (that I've tested!) that resides on the same Web AS, and I want to display the rows of the table in a Web Dynpro Table object. I have so far:

1) Connected the Controller Context to the Model, and dragged all of the items below the 'response' node of the Web Service to create an tree in the context

2) I connected the View Context to the Controller Context.

Nothing happens when I load the Web Dynpro page. I suspect I need to add some code to the wdDoInit method, but I'm not sure what object I use to invoke the Web Service.

Anyone point me in the right direction to move forward?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

If you are new to WebDynpro then make use of the available teamplates in WebDynpro which will take care of generating the required code for intializing as well as executing the webservice.

1. In the component Controller, create Context using "ServiceController" template.

Right Click on the componentController and you can select this template.

This template will generate the code for intialization of the modelnodes and it will generate a method with "executeXXX()" to call the webservice.

2. In the view, create a button using the "Button Template" and this will call the ".executeXXx()" method in the componentController .

Check this tooo

/people/anilkumar.vippagunta2/blog/2005/07/20/developing-web-application-without-writing-single-line-of-code-my-first-web-log

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta

Former Member
0 Kudos

Hello Anilkumar:

Thank you for your post...when I try to use the Service Controller template (which is a great suggestion, by the way!) I get the following error in the 'executeXXX' method:

IWDMessageManager cannot be resolved or is not a type

Any thoughts on that?

Very Kind Regards, Ian.

Former Member
0 Kudos

Press CTRL-Shift-O (Organize Imports).

Armin

Former Member
0 Kudos

Hey Armin: did that...any thoughts on a next step? Thanks!

Former Member
0 Kudos

Ok: total weirdness. It doesn't leave a error in my task list, but it does mark the error in the left margin of the code editor. Strange. Maybe it will work now!?!?

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi lan,

First of all, you need to bind your component controller context to model.

Map only request model into controller. No need to map response model.

You will get response under request model, when you execute this model.

Then write following code in controller's wdinit method to initialize your model.

ipublic<controller name>.i<model name> model = new <model name>();

wdcontext.node<model node>().bind(model);

If this web service requires some input parameters then set those parameters here as follows.

model.set<parameter>(<value>);

Now, when you execute your webservice write following code.

wdcontext.current<model>element().modelobject().execute();

wdcontext.node<response node>().invalidate();

Regards,

Bhavik

Former Member
0 Kudos

Bhavik: thank you for your post. I did try your recommendations, but had an error, namely that the Objects ipublic...couldn't be found. I did try to "Organize Imports" but that didn't help. I switched to the strategy of trying the Controller Template. Very Kind Regards, Ian.

Former Member
0 Kudos

Hi McCallum,

Replace following code:

ipublic<controller name>.i<model name> model = new <model name>();

with:

<Model name> model = new <model name>();

Regards,

Bhavik

Former Member
0 Kudos

Hello Bhavik!

when I put in

Response_SEManagerServiceViDocument_viewAllSEs

which is the name of my model, the compiler returns:

<b>Response_SEManagerServiceViDocument_viewAllSEs cannot be resolved or is not a type</b>

So then I fully qualified the type, and it works, except that I can't then call the bind method!

I think I am very close to getting this to work, but I am stymied!

Thanks, Ian.

Former Member
0 Kudos

Hi McCallum,

I guess you have mapped Response_SEManagerServiceViDocument_viewAllSEs node instead of Request_SEManagerServiceViDocument_viewAllSEs.

You need to map Request_SEManagerServiceViDocument_viewAllSEs node and execute this node. Under this node you will get response node. This response node will contain result data.

No need to use Response_SEManagerServiceViDocument_viewAllSEs node.

Regards,

Bhavik

former_member335005
Participant
0 Kudos

Hi Ian,

This tutorial might by of help:

http://help.sap.com/saphelp_nw04/helpdata/en/91/9c2226df76f64fa7783dcaa4534395/content.htm

To invoke the webservice you can add this in component controller's wdDoInit() method:

public void wdDoInit() {

//@@begin wdDoInit()

// create a new instance of the Web Service ModelClass

Request_SendEmailPortType_sendEmail req =

new Request_SendEmailPortType_sendEmail();

// bind new instance of the Web Service ModelClass to the

// independent Model Node ¢WebServiceEmail¢

wdContext.nodeWebServiceEmail().bind(req);

//@@end

}

Imports required:

...//@@begin imports

import com.sap.tc.webdynpro.tutorials.emailws

.model.Request_SendEmailPortType_sendEmail;

import com.sap.tc.webdynpro.tutorials.emailws.wdp.IPrivateEmailWSComponent;

//@@end

You can then add the following code directly in the wdDoInit() method or in an action handler:

public void sendEmail() {

//@@begin onActionSendEmail(ServerEvent)

IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

try {

// call Email Web Service and update dependent model node ¢Response¢

wdContext.currentWebServiceEmailElement().modelObject().execute();

wdContext.nodeResponse().invalidate();

...

} catch(Exception ex) {

msgMgr.reportException(ex.getLocalizedMessage(),true);

}

//@@end

}

Bind the Context elements in the view controller to the Table uielement in the View.

You should be able to retrieve teh table returns by the Web Service.

Regards,

Sangeeta

Former Member
0 Kudos

Have you created a view with a Table UI element?

Have you bound the table properties (dataSource etc.) to the view context?

Have you embedded the view in a window?

You can either call your web service in the component controller's wdDoInit() method or provide some action trigger (e.g. a button) and call it from the buttons action handler.

Armin

Former Member
0 Kudos

Hi again Armin: the problem that I'm having now is what prevented me from taking the third step you mention below [namely adding the code to wdInit()]. Thanks! Very Kind Regard, Ian.