Java Magazine, Sept/Oct 2018
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2018 35 the leading edge The controller is annotated with @ RequestScoped which means that a new instance of the controller is constructed with each request Therefore each time the index xhtml view is visited the controller is constructed and the getTeamRosterList method is invoked returning the full list of players A JAX RS client is employed to query the SportsTeamQueryService to populate the list of players The teamRoster field of the controller populates and constructs new players TeamRoster objects Clicking the Register button in the view Figure 1 calls on the registerPlayer controller method This method creates a new JAX RS client to initiate a call to the teamrosterregistrationservice addPlayer web service A new javax ws rs core Form is created and the appropriate fields for a TeamRoster object are populated from the data entered into the view The JAX RS response is returned from the service call to indicate success or failure Note that in a real world scenario a security API should be used to secure the web service employing technology such as JSON Web Tokens Figure 1 The user interface of the SportsTeamRegistrationService
You must have JavaScript enabled to view digital editions.