03 Wednesdays Stuff - learn-struts-fast/struts-tutorials GitHub Wiki
It's now lab time. Three labs are on the docket:
- Lab 4: Passing the model to the view
- Lab 5: Select fields
- Lab 6: Selecting CDs
If you are really courageous, tackle Lab 7 as well. We cover i18n in more detail tomorrow, but with knowledge of custom tags you can complete it.
Let me know if you have any questions. We'll kick things off tomorrow at 9:30 am!
Today is all about view components. And I'd like to really push you this morning.
Take a look at this page:
https://github.com/cameronmcnz/struts-tutorials/blob/master/roshambo/src/main/webapp/rps.jsp
How confusing is it? Can you make sense of it? Do you see how it can act as the view of a rock-paper-scissors game?
Let's try and implement the logic to support it.
Here's a start to the Action class I'd like to create today. Look at the validator and the @Results annotations. Can you make sense of it?
Let's start off with this. Then we'll take up some of the finer points of Lab 3 and do some discussion and lectures on creating view components
We are towards the self-study end of day two.
There are two labs for you to tackle
- The Simple Struts App (Lab 3)
- The model and view Struts App (Lab 4)
Let me know if you have any questions. I'm monitoring the chat window and I've configured a speaker so I should be able to hear any questions that come through your microphone if you're not muted. You can always text me too, especially if you decide to tackle the labs in the evening:
289 314 5715 [email protected]
Have fun! See you at 9:30am tomorrow!
Welcome back to day two. We'll kick things off at 9:30, as always.
I'd like to hit the ground running today. I'd like to start off by creating a new Struts application with **Maven **and Annotations.
Please watch this video, because this is exactly what we're going to do. The video is fast. We will take our time creating the app together. But watch the video to see where we are going:
Note that for this exercise the following components are required:
- The Maven POM - This is all configuration
- The web.xml file to configure struts
- The index.jsp to get input
- The Action class to process the request
- The results.jsp to act as the view
struts-app
|
| pom.xml
|
\ - src \ - main \ - webapp
+ index.jsp
+ results.jsp
\ - src \ - main \ - webapp \ - WEB-INF
+ web.xml
\ - src \ - main \ - java \ - com \ - mcnz \ - struts
+ HelloAction.java
From there, our day will look something like this:
- Struts 2 Architecture
- Struts 2 Components Overview
- Creating an application
- Configuring the web.xml
- Implementing Actions
- Basic view components
- Custom tags and struts tags
The day will end with the following labs:
- The Simple Struts App
- The model and view Struts App
Comment out these lines in the JspCalendar
//import javax.inject.Named;
//@Named("clock")
Add this to the the date.jsp file. The code goes below the </head>
and <body>
tags.
<%
trivera.jee.web.jsp.tutorial.JspCalendar clock = new trivera.jee.web.jsp.tutorial.JspCalendar();
request.setAttribute("clock", clock);
%>
Then re-run the app and it should work.
All the lecture and demo is done for the day. Now it's time for you to concentrate on the two labs in the book:
- Review of Servlets and JSPs on Page 20 of the Lab Guide
- MVC and Struts on Page 27 of the Lab Guide
We will recap and review when we kick off class tomorrow morning at 9:30
Before class tomorrow I would like you to take a look at the following tutorial:
I would like to do that example with out some time tomorrow. The video goes over all the steps, although I do go quickly, so feel free to pause the video to absorb what is being coded.