We9 Struts 2.0

1,719 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,719
On SlideShare
0
From Embeds
0
Number of Embeds
26
Actions
Shares
0
Downloads
27
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

We9 Struts 2.0

  1. 1. Struts 2.0 Don Brown
  2. 2. Web, Circa 2000
  3. 3. Web, Circa 2006
  4. 18. Struts 2 Architecture
  5. 19. <ul><li>Struts 1 </li></ul><ul><li>Action  </li></ul><ul><li>ActionForm  </li></ul><ul><li>ActionForward  </li></ul><ul><li>struts-config.xml  </li></ul><ul><li>ActionServlet  </li></ul><ul><li>RequestProcessor  </li></ul><ul><li>Struts 2 </li></ul><ul><li>Action </li></ul><ul><li>Action or POJO’s </li></ul><ul><li>Result </li></ul><ul><li>struts.xml </li></ul><ul><li>FilterDispatcher </li></ul><ul><li>Interceptors </li></ul>
  6. 20. Struts Plugins
  7. 21. Simple Example
  8. 22. Struts 1 < html:errors /> < html:form action = &quot;/SaveMeeting&quot; > < table border = &quot;0&quot; width = &quot;100%&quot; > < tr > < th align = &quot;right&quot; > Name: </ th > < td align = &quot;left&quot; > < html:text property = &quot;name&quot; size = ”50” /> </ td > </ tr > < tr > < th align = &quot;right&quot; > Date:
  9. 23. </ th > < td align = &quot;left&quot; > < html:text property = &quot;date&quot; size = &quot;50&quot; /> </ td > </ tr > < tr > < th align = &quot;right&quot; > Invitees: </ th > < td align = &quot;left&quot; > < html:select property = &quot;invitees&quot; multiple = &quot;true&quot; > < html:options collection = &quot;employees&quot; property = &quot;value&quot; labelProperty = &quot;label&quot; /> </ html:select >
  10. 24. </ tr > < tr > < th align = &quot;right&quot; > Description: </ th > < td align = &quot;left&quot; > < html:textarea property = &quot;description&quot; rows = &quot;4&quot; cols = &quot;50&quot; /> </ td > </ tr > < tr > < td align = &quot;right&quot; > &nbsp; </ td >
  11. 25. ... Only four pages! < td align = &quot;left&quot; > < html:submit property = &quot;DO_SUBMIT&quot; > Save </ html:submit > </ td > </ tr > </ table > </ html:form >
  12. 26. Struts 2 < s:form action = &quot;Meeting&quot; validate = &quot;true&quot; > < s:token /> < s:textfield label = ”Name” name = “name” /> < s:textfield label = ”Date&quot; name = &quot;date&quot; /> < s:select label = ”Invitees” name = &quot;invitees&quot; list = &quot;employees&quot; /> < s:textarea label = ”Description” n ame = &quot;description&quot; rows = &quot;4&quot; cols = &quot;50&quot; /> < s:submit value = ”Save&quot; method = &quot;save&quot; /> </ s:form >
  13. 27. Example Revisited
  14. 28. <s:textfield label=&quot;Name&quot; name=&quot;name&quot; tooltip = &quot;Meeting name&quot; />
  15. 29. < s:datepicker label=&quot;Date&quot; name=&quot;date&quot;/>
  16. 30. < s:optiontransferselect ... />
  17. 31. < jsp:include page = &quot;/ajax/commonInclude.jsp&quot; /> ... <s:textarea theme = &quot;ajax&quot; label=&quot;Description&quot; name=&quot;description&quot; rows=&quot;4&quot; cols=&quot;50&quot; />
  18. 32. But there's more . . .
  19. 33. Brian Kernighan Law of Debugging Difficulty Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
  20. 34. Prevention and Cure
  21. 35. struts.devMode = true
  22. 38. Built-in Testing Support public class MyActionTest extends StrutsTestCase { public void testExecute() throws Exception { assertTrue(true); } }
  23. 39. any.action?debug=console
  24. 40. any.action?profiling=yes
  25. 41. Time to Upgrade?
  26. 42. Tutorials, Guides, and FAQs
  27. 43. Struts 2 Training Course
  28. 44. < action name = &quot;editGangster&quot; class = &quot;org.apache.struts2.s1.Struts1Action&quot; > < param name = &quot;className&quot; > com.mycompany.gangstas.EditGangsterAction </ param > < result > gangsterForm.jsp </ result > </ action > Run Struts 1 Actions as Is
  29. 45. How do I get started?
  30. 46. Where We are Going

×