Entering content frame

Procedure documentation Implementing the Controller of the EMailEditor View Locate the document in its SAP Library structure

·        You must implement the following event handler methods:

·        Event handler of the EditorIn inbound plug:The value attributes are initialized using an e-mail address, which is available through parameter transfer.

This graphic is explained in the accompanying text

This example illustrates a simple alternative to context mapping that enables you to transfer parameter values between different views. When the outbound plug that belongs to the navigation link in the controller is triggered, the e-mail address is passed as a value to the Form view.

·        Event handler of the SendEMail action: A success message is displayed after the e-mail message has been sent and the navigation link back to the Form view has been triggered.

·        Event handler of the GoBack action: The navigation link back to the Form view is triggered without displaying a message.

Procedure

After triggering the SendEMailOut outbound plug in the controller of the Form view, the entered e-mail address is passed as a variable of the type string called eMailAddress to the inbound plug DisplayEditorIn. In this case, the use of a plug parameter is a simple alternative to context mapping, which would also require the declaration of a value attribute in the component controller.

...

       1.      Initialize the two value attributes EMailAddress and Greeting in the event handler of the DisplayEditorIn inbound plug.

EMailEditor.java

...

/** declared validating event handler */

public void onPlugDisplayEditorIn(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent

  wdEvent, java.lang.String eMailAddress )

{

  //@@begin onPlugDisplayEditorIn(ServerEvent)

  wdContext.currentContextElement().setEMailAddress(eMailAddress);

  wdContext.currentContextElement().setGreeting(

    "Please enter the e-mail for " + eMailAddress +"!");   

  //@@end

}

...

Navigation back to the Form view should trigger an appropriate success message when the user selects the Send E-Mail button. This is why the method reportSuccess(String message) of the IWDMessageManager interface is called. After selecting the link Go back to sample form, the Form view is displayed again.

EMailEditor.java

...

/** declared validating event handler */

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

{

  //@@begin onActionGoBack(ServerEvent)

  wdThis.wdFirePlugFinishOut();

  //@@end

}

 

/** declared validating event handler */

public void onActionSendEMail(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent

  wdEvent )

{

  //@@begin onActionSendEMail(ServerEvent)

  wdComponentAPI.getMessageManager().reportSuccess(

    "The mail was successfully sent to "

    + wdContext.currentContextElement().getEMailAddress());

  wdThis.wdFirePlugFinishOut();

  //@@end

}

...

 

View Lifetime

·        When specifying the project structure, you selected different values for the Lifespan property of the two view controllers. You selected framework_controled for the controller of the Form view and when_visible for the controller of the EMailEditor view. Both views are embedded in a single window so that only one single view is visible at any given time. When the user calls the application, the Form view is displayed because it is declared as the default view in the SimpleErrors window.

·        This graphic is explained in the accompanying text

·        This means that, at runtime, the controller of the Form view and its context remain after navigating to the EMailEditor view and back to the Form view. Therefore, the previously entered form data still exists in the input fields. If the Lifespan property of the Form view controller was when_visible, the controller would be newly created and initialized when the user navigates back from the EMailEditor view. In this case, the entered form data would not be available without context mapping to a superordinate controller context.

·        After entering an e-mail message in the EMailEditor view for the first time, return to this view for a second time using the navigation function. The TextEdit UI element will be empty because the corresponding view controller was newly created. Therefore, the EMailText value attribute also contains an empty string value.  

This graphic is explained in the accompanying text

An application example of the selection of the Lifespan property framework_controled is the embedding of views in multiple tabs of a Tabstrip UI element. We recommend that not every selection of a different tab automatically terminates the view controller lifecycle and begins the lifecycle of another view controller, as is the case when the Lifespan property when_visible is assigned to the corresponding views.

This graphic is explained in the accompanying text

  

  

 

Leaving content frame