4. Name: Submit Name: Submit Name: Submit Mohammad Mohammad Fill Form's Field Trigger the action Mohammad
5. Name: Submit Incorrect name Name: Submit Incorrect name Hamed Correct the name & trigger the action Mohammad Welcome ……………… Hamed
6.
7.
8.
9.
10. Name: Submit Name: Submit Name: Submit Mohammad Mohammad Fill Form's Field Trigger the action name =“ ” Mohammad 1 <%@ taglib prefix="s" uri="/struts-tags"%> <s:textfield name=” name ”... entrance.jsp Find the name’s field name 2 field=“ ”
11. <s:form action = “ ” . . . <action name = “ ” class = “ ” method = “ ”> . . . Find the action name from “entrance.jsp” file Find the action class and method from "struts.xml" 1.name=“Mohammad” 2.action class=“ “ 3.action method=“ “ 1 3 5 2.action=“ “ 4 submit Entrance signIn submit Entrance signIn entrance.jsp struts.xml submit 1.field=“name” 2
12. Value Stack An object of action class will be created if there is not any of that in value stack object maker Entrance entrance entrance name = “ Mohammad” There wasn't any object so make new one entrance_o Name = “ Mohammad” entrance Entrance.setName(“Mohammad”) entrance name = “ Mohammad” Entrance.setName(“Mohammad”) void call the setter name=“Mohammad” action class=“Entrance“ 3.action method=“signIn“ 1 3 5 2.action=“submit“ 4 3 1 2 field=“name” 2 3
13. Call the action method Return the return value entrance name = “ Mohammad” Entrance.signIn() entrance name = “ Mohammad” Entrance.signIn() “ No” name=“Mohammad” action class=“Entrance“ action method=“signIn“ 1 3 5 2.action=“submit“ 4 3 5 return value= 6 “ No” field=“name” 2
14. entrance name = “ Mohammad” Value Stack Push the object on top of value stack name=“Mohammad” action class=“Entrance“ action method=“signIn“ 1 3 5 2.action=“submit“ 4 return value=“No” 6 field=“name” 2
15. <action name=“submit”> <result name = “ No ”> main.jsp?msg = “Incorrect name” </result> . . . </action> Find the target page corresponding to return value from “struts.xml” Name: Submit Go to the result page Incorrect name name=“Mohammad” action class=“Entrance“ action method=“signIn“ 1 2 3 action=“submit“ 4 return value=“No” 5 4 5 struts.xml field=“ ” 6 <%@ taglib prefix="s" uri="/struts-tags"%> Name: <s:textfield name=” name ”... entrance.jsp Find the name’s field name
16. Value Stack Find the object from the top of value stack to initialize the result page (first object that has “name” property) entrance_o Name = “ Mohammad” entrance entrance name = “ Mohammad” Entrance.getName() entrance name = “ Mohammad” Entrance.getName() “ Mohammad” Name: Submit Incorrect name Mohammad Name: Submit Incorrect name Hamed Correct the name & trigger the action name=“ ” action class=“Entrance“ action method=“signIn“ 5 2 3 action=“submit“ 4 Hamed 2 1 field=“name” 1 Retrieve name property from action object
17. 1.name=“Hamed” 1 field=“ ” 2 <%@ taglib prefix="s" uri="/struts-tags"%> Name: <s:textfield name=” name ”... entrance.jsp name Find the name’s field
18. <s:form action = “ ” . . . <action name = “ ” class = “ ” method = “ ”> . . . Find the action name from “entrance.jsp” file Find the action class and method from "struts.xml" 1.name=“Hamed” 2.action class=“ “ 3.action method=“ “ 1 3 5 2.action=“ “ 4 submit Entrance signIn submit Entrance signIn entrance.jsp struts.xml submit field=“name” 2
19. Value Stack New Request So, new value stack object maker Entrance entrance entrance name = “ Hamed” There wasn't any object so make new one entrance_o Name = “ Mohammad” entrance Entrance.setName(“Hamed”) entrance name = “ Hamed” Entrance.setName(“Hamed”) void call the setter name=“Hamed” action class=“Entrance“ 3.action method=“signIn“ 1 3 5 2.action=“submit“ 4 3 1 2 field=“name” 2 3
20. Call the action method Return the return value entrance name = “ Hamed” Entrance.signIn() entrance name = “ Hamed” Entrance.signIn() “ Yes” 1.name=“Hamed” action class=“Entrance“ action method=“signIn“ 1 3 5 action=“submit“ 4 return value= 6 “ Yes” 3 5 field=“name” 2
21. entrance name = “ Hamed ” Value Stack Push the new object name=“Hamed” action class=“Entrance“ action method=“signIn“ 1 3 5 action=“submit“ 4 return value=“Yes” 6 on top of value stack field=“name” 2
22. <action name=“submit”> <result name = “No”> … </result> <result name = “ Yes ”> welcome.jsp </result> </action> Find the target page corresponding to return value from “struts.xml” Go to the result page Welcome ……………… 5 name =“Hamed” action class=“Entrance“ action method=“signIn“ 1 2 3 action=“submit“ 4 return value=“Yes” 5 4 struts.xml <%@ taglib prefix="s" uri="/struts-tags"%> Welcome <s:property value=” name ”... welcome.jsp name field=“ ” 6
23. Value Stack Find the object from the top of value stack to initialize the result page (first object that has “name” property) entrance_o Name = “ Mohammad” entrance entrance name = “ Hamed” Entrance.getName() entrance name = “ Hamed” Entrance.getName() “ Hamed” Welcome ……………… Hamed 1.name=“Hamed” action class=“Entrance“ action method=“signIn“ 1 2 3 action=“submit“ 4 2 field=“name” 5 5 Retrieve name property from action object