!--a11y-->
Initializing Top Level Value
Attributes 
There are four top level value attributes within the Quiz component: NextButtonVisibility, ShowAnswerButtonEnabled, TextMessage, and ExitButtonVisibility.
The value attributes TextMessage and ExitButtonVisibility can be initialized in the wdDoInit() method of theWelcome view controller. This method is called by the Web Dynpro runtime during the creation of the Welcome view.
Implementation in the Welcome view controller |
... //@@begin imports import com.sap.tc.webdynpro.progmodel.api.WDVisibility; import com.sap.tc.webdynpro.tutorials.quiz.wdp.IPrivateWelcome; //@@end ...
/** Hook method called to initialize controller. */ public void wdDoInit() { //@@begin wdDoInit() wdContext.currentContextElement().setTextMessage(welcomeMessage); wdContext.currentContextElement().setExitButtonVisibility(WDVisibility.NONE); //@@end · } |
The local member variable welcomeMessage is defined in the next chapter.

The only instance of the root node element can be accessed at runtime using the wdContext.currentContextElement() method. This instance contains the defined structure of value attributes and may contain the defined structure of value nodes. You receive the read and write accesses for the value attributes using the automatically generated Mutator methods, for example, wdContext.currentContextElement().setTextMessage(welcomeMessage).

The wdContext.wdDoInit() method in the Question view controller is only called when the Question view is added to current view group – that is, when the view is visible. The lifetime of the view controller is as long as its view is visible during subsequent view group changes. If a view is no longer in the current view group, its view controller in the Web Dynpro runtime is also deleted until it is requested again within a succeeding view group (another call of the wdDoInit() method).
Implement the following source code in the controller of the Question views:
Implementation in the Question view controller |
... //@@begin imports import com.sap.tc.webdynpro.progmodel.api.WDVisibility; import com.sap.tc.webdynpro.tutorials.quiz.wdp.IPrivateQuestion; //@@end ...
/** declared validating event handler */ public void onPlugShowQuestionIn(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ) { //@@begin onPlugShowQuestionIn(ServerEvent) wdContext.currentContextElement().setNextButtonVisibility(WDVisibility.VISIBLE); wdThis.wdGetShowAnswerPressedAction().setEnabled(true); wdContext.nodeQuizData().moveFirst(); //@@end · } |
In the last section of this example
application, different context state changes
are specified using implementation, for example, the setting of new values
in value attributes or the changing of the lead selection in the value node
QuizData to switch to another question.
