Java Reference
In-Depth Information
Finally, I need to send the resulting data to the view layer in a form it can understand, as
shown in figure 2.7 .
Figure 2.7. Building Groovy Baseball, part 3 —drive system and generate XML
During this stage, I'll cover
• Using a groovlet
• Generating XML
I'll begin the process with part 1 , creating POGOs and saving data in a database.
2.3.1. Database data and Plain Old Groovy Objects
Thegame results onthewebpagearecentered onthehomestadiums ofeach game. Google
Maps places markers based on the latitude and longitude of a given location. Because sta-
diums don't tend to move much, it's worth it to compute those locations ahead of time and
save them in some kind of persistence structure. In this case I used a MySQL database, but
any database would do.
I'll build a script here to collect the necessary info for each MLB stadium, compute its lat-
itude and longitude, and store them in a database table. I'll start with a class to represent a
stadium.
The Stadium POGO
In Java we would call this class a Plain Old Java Object, or POJO. In Groovy I'll use a
Plain Old Groovy Object, or POGO, instead. The following listing shows the Stadium
class.
Listing 2.2. Stadium.groovy : a POGO to hold stadium information
package beans
class Stadium {
int id
 
Search WWH ::




Custom Search