Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
Continuing from where we left on {code:html}Using Flex DateField and DataGrid elements in WebDynpro Java with FlashIslands - Part 1{code} , in this part of the blog, I will explain the webdynpro project needed for our application to work.* *

 

I will explain the Webdynpro part considering that you are already familiar with basic webdynpro java concepts. If you are not, it would be a good idea to try out some of the webdynpro tutorials {code:html}Tutorials & Samples for Web Dynpro Java{code}. Even though these are for Netweaver 7.0, you should get a hang of things, and will easily be able to adapt to NWCE 7.1

This is what I am doing in my webdynpro project:

1. I have created a model for a custom BAPI. This BAPI takes fromDate, toDate and username as input, and returns the records corresponding to the selection. I added this model as a Used Model.

 

2. I created a Custom controller to call this model. I used Apply template -> service controller and added the necessary input and output parameters.

 

3. Mapped the context of Component controller to the custom controller, which in turn is mapped to the model.

 

4. Mapped the context of the view controller to the component controller.

 

5. In the component controller, I created a node "SearchParams" with Collection Cardinality 1..1, and within this I have added 3 attributes: fromDate (of Type date), toDate (of Type date) and userName (of Type string). This will hold the value we enter in the runtime.

 

6. Mapped this node to both the custom controller and view controller. This is what my component looks like:

 

This is what the Context for all the controllers looks like:

Custom Controller:

 

Component Controller:

 

View Controller:

 

7. I create a method "executeCUSTfuie" in the Component controller to call the execute method in Custom controller.

*public* *void* executeCUSTfuie( )  {     //@@begin executeCUSTfuie()             wdThis.wdGetCUSTfuieController().executeZ_Get_User_Reqs_Input();     //@@end   } 8. This is what the execute method in the Custom Controller looks like: *public* *void* executeZ_Get_User_Reqs_Input( )  {     //@@begin executeZ_Get_User_Reqs_Input()     //$$begin Service Controller(-1052249833)               Z_Get_User_Reqs_Input input = *new* Z_Get_User_Reqs_Input();               wdContext.nodeZ_Get_User_Reqs_Input().bind(input);               input.setUser(wdContext.nodeSearchParams().currentSearchParamsElement().getUserName().toUpperCase());               input.setDate_From(wdContext.nodeSearchParams().currentSearchParamsElement().getFromDate());               input.setDate_To(wdContext.nodeSearchParams().currentSearchParamsElement().getToDate()); *try*     {           input.execute();       wdContext.nodeOutput().invalidate();     } *catch*(Exception e)  *public* *void* wdDoModifyView(com.sap.tc.webdynpro.progmodel.api.IWDView view, *boolean* firstTime)   {     //@@begin wdDoModifyView *if* (firstTime)             {                      IWDGACDataSource ds = (IWDGACDataSource)view.getElement("records");                      java.util.Iterator i = wdContext.nodeRequisitions().getNodeInfo().iterateAttributes(); *while* (i.hasNext())                      {                                IWDGACProperty prop = view.createElement(IWDGACProperty.*class*);                                IWDAttributeInfo attrInfo = (IWDAttributeInfo) i.next();                                String s = attrInfo.getName();                                prop.bindValue(attrInfo);                                prop.setName(s);                                ds.addProperty(prop);                      }             }     //@@end   } Insert Event Id: getrecords Name: getrecords onAction: GetRecords   When you create an event, you need to assign it to an Action. In here I have created a new action "GetRecords". This has the following code: *public* *void* onActionGetRecords(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )   {     //@@begin onActionGetRecords(ServerEvent)             wdThis.wdGetCOMPfuieController().executeCUSTfuie();     //@@end   } *Now before we forget:*                                                 dataProvider="{records}">*Deploy and Run:* Finally create a WebDynpro Application for your WebDynpro component, then Deploy and Run your WebDynpro application.   I enter the from date, to date and username, click on Get Records button. The data from the backend BAPI is correctly displayed in the Flex screen.

2 Comments