http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/conversion/showOperations.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/conversion/showOperations.jsp b/apps/showcase/src/main/webapp/WEB-INF/conversion/showOperations.jsp new file mode 100644 index 0000000..4cb6679 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/conversion/showOperations.jsp @@ -0,0 +1,21 @@ +<%@taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Conversion - Tiger 5 Enum + + + + +
+
+
+ +
+
+
+
+
+ + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/conversion/showPersonInfo.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/conversion/showPersonInfo.jsp b/apps/showcase/src/main/webapp/WEB-INF/conversion/showPersonInfo.jsp new file mode 100644 index 0000000..24f9760 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/conversion/showPersonInfo.jsp @@ -0,0 +1,24 @@ +<%@taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Conversion - Populate Object into Struts' action List + + + + +
+
+
+ + +
+
+
+
+
+
+ + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/customTemplateDir/customTheme/ftlCustomTemplate.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/customTemplateDir/customTheme/ftlCustomTemplate.ftl b/apps/showcase/src/main/webapp/WEB-INF/customTemplateDir/customTheme/ftlCustomTemplate.ftl new file mode 100644 index 0000000..4152334 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/customTemplateDir/customTheme/ftlCustomTemplate.ftl @@ -0,0 +1,7 @@ +
+

+Freemarker Custom Template - +parameter 'paramName' - ${parameters.paramName} +

+
+ http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/customTemplateDir/customTheme/jspCustomTemplate.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/customTemplateDir/customTheme/jspCustomTemplate.jsp b/apps/showcase/src/main/webapp/WEB-INF/customTemplateDir/customTheme/jspCustomTemplate.jsp new file mode 100644 index 0000000..311c329 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/customTemplateDir/customTheme/jspCustomTemplate.jsp @@ -0,0 +1,8 @@ +<%@taglib prefix="s" uri="/struts-tags" %> + +
+

+JSP Custom Template - +parameter 'paramName' - +

+
http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/date.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/date.jsp b/apps/showcase/src/main/webapp/WEB-INF/date.jsp new file mode 100644 index 0000000..400cd6d --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/date.jsp @@ -0,0 +1,2 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/empmanager/editEmployee.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/empmanager/editEmployee.jsp b/apps/showcase/src/main/webapp/WEB-INF/empmanager/editEmployee.jsp new file mode 100644 index 0000000..aff2c3e --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/empmanager/editEmployee.jsp @@ -0,0 +1,56 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sx" uri="/struts-dojo-tags" %> + + + + + + + + + Struts2 Showcase - CRUD Example - <s:property value="#title"/> + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+
+
+ + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/empmanager/editSkill.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/empmanager/editSkill.jsp b/apps/showcase/src/main/webapp/WEB-INF/empmanager/editSkill.jsp new file mode 100644 index 0000000..f47390e --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/empmanager/editSkill.jsp @@ -0,0 +1,42 @@ +<%@taglib prefix="s" uri="/struts-tags" %> + + + + + + + + + + + Struts2 Showcase - CRUD Example - <s:property value="#title"/> + + + + +
+
+
+ +
+
+ + + + + <%--s:submit name="%{#submitType}" value="%{getText('save')}" /--%> + + + +
+
+
+ + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/empmanager/index.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/empmanager/index.jsp b/apps/showcase/src/main/webapp/WEB-INF/empmanager/index.jsp new file mode 100644 index 0000000..0da9091 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/empmanager/index.jsp @@ -0,0 +1 @@ +<% response.sendRedirect("../employee/list.action"); %> http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/empmanager/listEmployees.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/empmanager/listEmployees.jsp b/apps/showcase/src/main/webapp/WEB-INF/empmanager/listEmployees.jsp new file mode 100644 index 0000000..1991924 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/empmanager/listEmployees.jsp @@ -0,0 +1,43 @@ +<%@taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - CRUD Example + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + +
IdFirst NameLast Name
">
+ " class="btn btn-primary">Create new Employee +
+
+
+ + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/empmanager/listSkills.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/empmanager/listSkills.jsp b/apps/showcase/src/main/webapp/WEB-INF/empmanager/listSkills.jsp new file mode 100644 index 0000000..1c20253 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/empmanager/listSkills.jsp @@ -0,0 +1,41 @@ +<%@taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - CRUD Example + + + + +
+
+
+ +
+
+ + + + + + + + + + + +
NameDescription
">
+ + " class="btn btn-primary">Create new Skill +
+
+
+ + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/filedownload/index.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/filedownload/index.jsp b/apps/showcase/src/main/webapp/WEB-INF/filedownload/index.jsp new file mode 100644 index 0000000..a8b7ef8 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/filedownload/index.jsp @@ -0,0 +1,36 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - File Download + + + + + + + +
+
+
+
+ The browser should display the Struts logo. +
+ + + Download image file. +
+
+
+ The browser should prompt for a location to save the ZIP file. +
+ + + Download ZIP file. +
+
+
+ + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/fileupload/multipleUploadUsingArray.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/fileupload/multipleUploadUsingArray.jsp b/apps/showcase/src/main/webapp/WEB-INF/fileupload/multipleUploadUsingArray.jsp new file mode 100644 index 0000000..4c8167c --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/fileupload/multipleUploadUsingArray.jsp @@ -0,0 +1,32 @@ +<%@ page + language="java" + contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Fileupload sample - Multiple fileupload using Array + + + + + +
+
+
+ + + + + + + + +
+
+
+ + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/fileupload/multipleUploadUsingList.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/fileupload/multipleUploadUsingList.jsp b/apps/showcase/src/main/webapp/WEB-INF/fileupload/multipleUploadUsingList.jsp new file mode 100644 index 0000000..a84ef6c --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/fileupload/multipleUploadUsingList.jsp @@ -0,0 +1,32 @@ +<%@ page + language="java" + contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Fileupload sample - Multiple fileupload using List + + + + + +
+
+
+ + + + + + + + +
+
+
+ + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload-success.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload-success.jsp b/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload-success.jsp new file mode 100644 index 0000000..6073d2a --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload-success.jsp @@ -0,0 +1,31 @@ +<%@ page + language="java" + contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Fileupload sample + + + + + +
+
+
+
    +
  • ContentType:
  • +
  • FileName:
  • +
  • File:
  • +
  • Caption:
  • +
+
+
+
+ + + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload.jsp b/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload.jsp new file mode 100644 index 0000000..cc770c4 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload.jsp @@ -0,0 +1,27 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Fileupload sample + + + + + +
+
+
+ + + + + + + +
+
+
+ + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/freemarker/customFreemarkerManagerUsage.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/freemarker/customFreemarkerManagerUsage.ftl b/apps/showcase/src/main/webapp/WEB-INF/freemarker/customFreemarkerManagerUsage.ftl new file mode 100644 index 0000000..a1e14cf --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/freemarker/customFreemarkerManagerUsage.ftl @@ -0,0 +1,34 @@ + + + Struts2 Showcase - Freemarker - CustomFreemarkerManager Usage + + + + + +
+
+
+ +

+ This page shows a simple example of using a custom freemarker manager. + The custom freemarker manager put into freemarker model an util classed + under the name 'customFreemarkerManagerUtil'. so one could use +

+

    +
  • $ { customFreemarkerManagerUtil.getTodayDate() } - to get today's date
  • +
  • $ { customFreemarkerManagerUtil.todayDate } - to get today's date
  • +
  • $ { customFreemarkerManagerUtil.getTimeNow() } - to get the time now
  • +
  • $ { customFreemarkerManagerUtil.timeNow } - to get the time now
  • +
+ + Today's Date = ${customFreemarkerManagerUtil.todayDate}
+ Time now = ${customFreemarkerManagerUtil.getTimeNow()}
+
+
+
+ + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/freemarker/index.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/freemarker/index.jsp b/apps/showcase/src/main/webapp/WEB-INF/freemarker/index.jsp new file mode 100644 index 0000000..360c6cb --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/freemarker/index.jsp @@ -0,0 +1,3 @@ +<% response.sendRedirect("/freemarker/customFreemarkerManagerDemo.action"); %> + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/freemarker/standardTags.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/freemarker/standardTags.ftl b/apps/showcase/src/main/webapp/WEB-INF/freemarker/standardTags.ftl new file mode 100644 index 0000000..016e189 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/freemarker/standardTags.ftl @@ -0,0 +1,24 @@ + + + Struts2 Showcase - Freemarker - Standard Struts Freemarker Tags + + + + + +
+
+
+ + <@s.form action="test"> + <@s.textfield label="Name" name="name"/> + <@s.select label="Birth Month" headerValue="Select Month" list="months" /> + + +
+
+
+ + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/hangman/blank.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/hangman/blank.ftl b/apps/showcase/src/main/webapp/WEB-INF/hangman/blank.ftl new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanAjax.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanAjax.ftl b/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanAjax.ftl new file mode 100644 index 0000000..e433290 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanAjax.ftl @@ -0,0 +1,247 @@ + + + Struts2 Showcase - Hangman (AJAX) +<@sx.head /> + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ <@s.url id="url" value="/hangman/images/hangman.png" /> + Hangman" + width="197" height="50" border="0"/> + + <#-- Guesses Left --> +
+ <@s.set name="guessLeftImageName" value="%{'Chalkboard_'+hangman.guessLeft()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#guessLeftImageName}" /> + No. Guesses Left" width="20" height="20" border="0"/> +
+
+ <@s.url id="url" value="/hangman/images/guesses-left.png" /> + Guesses Left" width="164" height="11" border="0"/> +
+ <#-- Display Scaffold --> +
+ <@s.set name="scaffoldImageName" value="%{'scaffold_'+hangman.guessLeft()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#scaffoldImageName}" /> + " border="0"/> +
+
+

+ <@s.url id="url" value="/hangman/images/guess.png" /> + Current Guess" + align="MIDDLE" width="127" height="20" border="0"/>

+
+ <#-- Display Vacab --> +
+ <@s.iterator id="currentCharacter" value="%{hangman.vocab.inCharacters()}" stat="stat"> + <#if hangman.characterGuessedBefore(currentCharacter)> + <@s.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter.toString()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#chalkboardImageName}" /> + <@s.property value=" + src="<@s.property value="%{#url}" />" width="36" border="0"/> + <#else> + <@s.url id="url" value="/hangman/images/Chalkboard_underscroll.png" /> + _" width="36" border="0"/> + + +
+
+

+ <@s.url id="url" value="/hangman/images/choose.png" /> + Choose" + height="20" width="151" border="0"/> +

+
+ + <#-- Show Characters Available --> +
+ <@s.iterator id="currentCharacter" value="%{hangman.charactersAvailable}" status="stat"> + <@s.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter+'.png'}" /> + <@s.url id="chalkboardImageUrl" value="%{'/hangman/images/'+#chalkboardImageName}" /> + <@s.url id="spacerUrl" value="/hangman/images/letter-spacer.png" /> + + <@s.url id="blankUrl" value="ajax/blank.action" includeContext="false" /> + <@sx.a id="%{#currentCharacter}" + beforeNotifyTopics="topicGuessMade" + showErrorTransportText="true"> + " width="36" border="0"/> + + +
+ + +
+ +
+
+
+
+ + + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl b/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl new file mode 100644 index 0000000..6bfd8ea --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl @@ -0,0 +1,144 @@ + + + Struts2 Showcase - Hangman + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ <@s.url id="url" value="/hangman/images/hangman.png" /> + Hangman" + width="197" height="50" border="0"/> + + <#-- Guesses Left --> +
+ <#if (hangman.guessLeft() >= 0)> + <@s.set name="guessLeftImageName" value="%{'Chalkboard_'+hangman.guessLeft()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#guessLeftImageName}" /> + No. Guesses Left" width="20" height="20" border="0" /> + +
+
+ <@s.url id="url" value="/hangman/images/guesses-left.png" /> + Guesses Left" width="164" height="11" border="0"/> +
+ <#-- Display Scaffold --> +
+ <@s.set name="scaffoldImageName" value="%{'scaffold_'+hangman.guessLeft()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#scaffoldImageName}" /> + " border="0"/> +
+
+

+ <@s.url id="url" value="/hangman/images/guess.png" /> + Current Guess" + align="MIDDLE" width="127" height="20" border="0"/>

+
+ <#-- Display Vacab --> +
+ <#if hangman.gameEnded()> + <@s.iterator id="currentCharacter" value="%{hangman.vocab.inCharacters()}" stat="stat"> + <@s.url id="url" value="%{'/hangman/images/Chalkboard_'+#currentCharacter.toString()+'.png'}" /> + <@s.property value=" + src="<@s.property value="%{#url}" />" width="36" border="0" /> + + <#else> + <@s.iterator id="currentCharacter" value="%{hangman.vocab.inCharacters()}" stat="stat"> + <#if hangman.characterGuessedBefore(currentCharacter)> + <@s.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter.toString()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#chalkboardImageName}" /> + <@s.property value=" + src="<@s.property value="%{#url}" />" width="36" border="0"/> + <#else> + <@s.url id="url" value="/hangman/images/Chalkboard_underscroll.png" /> + _" width="36" border="0"/> + + + +
+
+

+ <@s.url id="url" value="/hangman/images/choose.png" /> + Choose" + height="20" width="151" border="0"/> +

+
+ + <#-- Show Characters Available --> +
+ <#if hangman.gameEnded()> + <@s.set name="winImageName" value="%{'you-win.png'}" /> + <@s.set name="looseImageName" value="%{'you-lose.png'}" /> + <@s.set name="startImageName" value="%{'start.png'}" /> + <@s.url id="winImageUrl" value="%{'/hangman/images/'+#winImageName}" /> + <@s.url id="looseImageUrl" value="%{'/hangman/images/'+#looseImageName}" /> + <@s.url id="startImageUrl" value="%{'/hangman/images/'+#startImageName}" /> + <@s.url id="startHref" action="hangmanNonAjax" namespace="/hangman" /> + + <#if hangman.isWin()> + " width="341" height="44" /> + <#else> + " width="381" height="44" /> + + <@s.a href="%{#startHref}"> + " width="250" height="43" /> + + <#else> + <@s.iterator id="currentCharacter" value="%{hangman.charactersAvailable}" status="stat"> + <@s.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter+'.png'}" /> + <@s.url id="chalkboardImageUrl" value="%{'/hangman/images/'+#chalkboardImageName}" /> + <@s.url id="spacerUrl" value="/hangman/images/letter-spacer.png" /> + <@s.url id="url" action="guessCharacterNonAjax" namespace="/hangman"> + <@s.param name="character" value="%{#currentCharacter}" /> + + + <@s.a href="%{#url}" + id="%{#currentCharacter}" + > + " width="36" border="0" /> + + + +
+ + +
+ +
+
+
+
+ + + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/hangman/updateCharacterAvailable.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/hangman/updateCharacterAvailable.ftl b/apps/showcase/src/main/webapp/WEB-INF/hangman/updateCharacterAvailable.ftl new file mode 100644 index 0000000..84281d0 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/hangman/updateCharacterAvailable.ftl @@ -0,0 +1,45 @@ +<#if hangman.gameEnded()> + <@s.set name="winImageName" value="%{'you-win.png'}" /> + <@s.set name="looseImageName" value="%{'you-lose.png'}" /> + <@s.set name="startImageName" value="%{'start.png'}" /> + <@s.url id="winImageUrl" value="%{'/hangman/images/'+#winImageName}" /> + <@s.url id="looseImageUrl" value="%{'/hangman/images/'+#looseImageName}" /> + <@s.url id="startImageUrl" value="%{'/hangman/images/'+#startImageName}" /> + <@s.url id="startHref" action="hangmanAjax" namespace="/hangman" /> + + <#if hangman.isWin()> + " width="341" height="44" /> + <#else> + " width="381" height="44" /> + + <@s.a href="%{#startHref}"> + " width="250" height="43" /> + +<#else> +<@s.iterator id="currentCharacter" value="%{hangman.charactersAvailable}" status="stat"> + <@s.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter+'.png'}" /> + <@s.url id="chalkboardImageUrl" value="%{'/hangman/images/'+#chalkboardImageName}" /> + <@s.url id="spacerUrl" value="/hangman/images/letter-spacer.png" /> + <@s.url id="blankUrl" value="ajax/blank.action" includeContext="false" /> + + <@sx.a id="%{#currentCharacter}" + afterNotifyTopics="topicGuessMade" + showErrorTransportText="true"> + " width="36" border="0" /> + + + <#-- + " > + " width="36" border="0" /> + + + + --> + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/hangman/updateGuessLeft.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/hangman/updateGuessLeft.ftl b/apps/showcase/src/main/webapp/WEB-INF/hangman/updateGuessLeft.ftl new file mode 100644 index 0000000..8b5ef4e --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/hangman/updateGuessLeft.ftl @@ -0,0 +1,7 @@ +<#if (hangman.guessLeft() >= 0)> + <@s.set name="guessLeftImageName" value="%{'Chalkboard_'+hangman.guessLeft()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#guessLeftImageName}" /> + No. Guesses Left" width="20" height="20" border="0" /> + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/hangman/updateScaffold.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/hangman/updateScaffold.ftl b/apps/showcase/src/main/webapp/WEB-INF/hangman/updateScaffold.ftl new file mode 100644 index 0000000..afd11b6 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/hangman/updateScaffold.ftl @@ -0,0 +1,3 @@ + <@s.set name="scaffoldImageName" value="%{'scaffold_'+hangman.guessLeft()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#scaffoldImageName}" /> + " border="0"/> http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/hangman/updateVocabCharacters.ftl ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/hangman/updateVocabCharacters.ftl b/apps/showcase/src/main/webapp/WEB-INF/hangman/updateVocabCharacters.ftl new file mode 100644 index 0000000..d4b370b --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/hangman/updateVocabCharacters.ftl @@ -0,0 +1,20 @@ +<#if hangman.gameEnded()> +<@s.iterator id="currentCharacter" value="%{hangman.vocab.inCharacters()}" stat="stat"> + <@s.url id="url" value="%{'/hangman/images/Chalkboard_'+#currentCharacter.toString()+'.png'}" /> + <@s.property value=" + src="<@s.property value="%{#url}" />" width="36" border="0" /> + +<#else> +<@s.iterator id="currentCharacter" value="%{hangman.vocab.inCharacters()}" stat="stat"> + <#if hangman.characterGuessedBefore(currentCharacter)> + <@s.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter.toString()+'.png'}" /> + <@s.url id="url" value="%{'/hangman/images/'+#chalkboardImageName}" /> + <@s.property value=" + src="<@s.property value="%{#url}" />" width="36" border="0"/> + <#else> + <@s.url id="url" value="/hangman/images/Chalkboard_underscroll.png" /> + _" width="36" border="0"/> + + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/help.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/help.jsp b/apps/showcase/src/main/webapp/WEB-INF/help.jsp new file mode 100644 index 0000000..08d84ac --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/help.jsp @@ -0,0 +1,32 @@ +<%@taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase . Getting Support + + + + + + +
+
+
+ Struts Logo +
+
+
+ Use this mailing list if you encounter problems while developing and using with Struts. +
+ User List +
+
+
+ The Struts 2 website. +
+ Struts 2 +
+
+ + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/integration/modelDriven.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/integration/modelDriven.jsp b/apps/showcase/src/main/webapp/WEB-INF/integration/modelDriven.jsp new file mode 100644 index 0000000..dc0b1f4 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/integration/modelDriven.jsp @@ -0,0 +1,44 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Struts1 Integration + + + + + + + +
+
+
+ + + + + + + + + + + + + +
+
+
+ + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/integration/modelDrivenResult.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/integration/modelDrivenResult.jsp b/apps/showcase/src/main/webapp/WEB-INF/integration/modelDrivenResult.jsp new file mode 100644 index 0000000..7d11f4c --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/integration/modelDrivenResult.jsp @@ -0,0 +1,43 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Struts1 Integration - Result + + + + + + + +
+
+
+ + +
+
+
+
+ +
+
+
+ + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/demo.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/demo.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/demo.jsp new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/example-action.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/example-action.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/example-action.jsp new file mode 100644 index 0000000..aaf5ce9 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/example-action.jsp @@ -0,0 +1,76 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +
+package org.apache.struts2.showcase.action;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class ExampleAction extends ActionSupport {
+    public static final String CONSTANT = "Struts Rocks!";
+        
+    public static Date getCurrentDate() {
+        return new Date();
+    }
+    
+    public String getName() {
+        return "John Galt";
+    }
+
+    public String[] getBands() {
+        return new String[] { "Pink Floyd", "Metallica", "Guns & Roses" };
+    }
+
+    public List<String> getMovies() {
+        return Arrays.asList("Lord of the Rings", "Matrix");
+    }
+
+    public Book getBook() {
+        return new Book("Iliad", "Homer");
+    }
+
+    public Map<String, Book> getBooks() {
+        Map<String, Book> books = new HashMap<String, Book>();
+        books.put("Iliad", new Book("Iliad", "Homer"));
+        books.put("The Republic", new Book("The Replublic", "Plato"));
+        books.put("Thus Spake Zarathustra", new Book("Thus Spake Zarathustra",
+            "Friedrich Nietzsche"));
+        return books;
+    }
+}
+
+class Book {
+    private String title;
+    private String author;
+
+    public Book(String title, String author) {
+        this.title = title;
+        this.author = author;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(String author) {
+        this.author = author;
+    }
+}
+
\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/index.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/index.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/index.jsp new file mode 100644 index 0000000..987a39a --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/index.jsp @@ -0,0 +1,241 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sx" uri="/struts-dojo-tags" %> + + + + OGNL and tags demo + + + + + + + + + + + + + + + + + + +
+
+
+ Welcome to the OGNL console! +
+ :-> +
+ + OGNL Expression +
+
+
+ + + + + + +
+
+ + + +
+
+ JSP Eval Result +
+
+
+
+
+ +
+
+
+
+

+ + + + http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_0.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_0.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_0.jsp new file mode 100644 index 0000000..b6787d4 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_0.jsp @@ -0,0 +1,62 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ String Attributes +

+

+ Some tag attributes are expected to be Strings in which case String literals + can be passed as the value, like the href attribute in the a tag. +

+

+ + <s:a href="http://struts.apache.org/" /> + +

+

+ If the value that you want to use in one of these string literal attributes is stored on the Value Stack, + then the %{#name} syntax (alternative syntax) needs to be used. Assuming there is a value + with the name "url" stored on the stack: +

+

+ + <s:a href="%{#url}" /> + +

+

+ will create an anchor and use the value of "url" for the href attribute. +

+

+ Value Attributes +

+

+ Other attributes expect an object as their value(not an string literal). In these attributes you can specify + the name of a variable stored on the Value Stack, and the tag will look it up and use it. Like the + value attribute in the property tag. Assuming there is an object stored on the Value Stack with + the name "movie", then: +

+

+ + <s:property value="movie" /> + +

+

+ will print the value to the page. To pass an String literal to an attribute that expects a value use the %{'string'} + notation. +

+

+ If you don't remember if an attribute expects an string literal or a value, you can always use the %{value} notation: +

+

+ + <s:a href="%{'http://struts.apache.org/'}" /> +
+ <s:property value="%{#movie}" /> +
+

+

+ [More details] +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_1.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_1.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_1.jsp new file mode 100644 index 0000000..a96ab7a --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_1.jsp @@ -0,0 +1,52 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ Print property value, using the property tag +

+

+ On the OGNL demo you learned how to access values from the Value Stack using OGNL expressions. + The property tag is used to print to the page the result of an OGNL expression. The expression + is specified in the value attribute. +

+

To print the value of the expression name to the page type: +

+ + <s:property value="name" /> + +

+

+ on the JSP console and hit enter. Do it for me +

+

+ As you saw in the OGNL demo, to print a property of an object that is not on top of the stack, + use the #object.property notation. +

+

To print the value for the key "struts.view_uri" in request to the page type: +

+ + <s:property value="#request['struts.view_uri']" /> + +

+

+ on the JSP console and hit enter. Do it for me +

+

+ Print property value, using the $ operator +

+

Use the ${name} notation to print values from the Value Stack to the page. +

To print the value of the expression name to the page type: +

+ + ${name} + +

+

+ on the JSP console and hit enter. Do it for me +

+

+ [More details] +

http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_2.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_2.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_2.jsp new file mode 100644 index 0000000..565a7ec --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_2.jsp @@ -0,0 +1,54 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ if tag +

+

+ The if tag allows you to optionally execute a JSP section. Multiple elseif tags + and one else tag can be associated to an if tag. +

+

+ To say hello to John Galt type: +

+

+

+        <s:if test="name == 'John Galt'">
+            Hi John
+        </s:if>
+        <s:else>
+            I don't know you!
+        </s:else>
+    
+

+

+ on the JSP console and hit enter. Do it for me +

+

+ iterator tag +

+

+ The iterator tag loops over an Iterable object one object at a time into + the Value Stack (the value will be on top of the stack). +

+

+ To print the all the elements in the "bands" property type: +

+

+

+        <s:iterator value="bands">
+            <s:property />
+            <br />
+        </s:iterator>
+    
+

+

+ on the JSP console and hit enter. Do it for me +

+

+ [More on the if tag] + [More on the iterator tag] +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_3.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_3.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_3.jsp new file mode 100644 index 0000000..483db12 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_3.jsp @@ -0,0 +1,65 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ set tag +

+

+ The set tag sets the variable with the name specified in the name attribute to + the value specified in the value attribute in the scope + entered in the scope attribute. The available scopes are: +

    +
  • application - application scope according to servlet spec
  • +
  • session - session scope according to servlet spec
  • +
  • request - request scope according to servlet spec
  • +
  • page - page scope according to servlet sepc
  • +
  • action - the value will be set in the request scope and Struts' action context
  • + +
+

+

+ This example sets favouriteBand in the request scope to the first element of the bands property: +

+

+

+        <s:set name="favouriteBand" value="bands[0]" />
+        <s:property value="#favouriteBand" />
+    
+

+

+ Do it for me +

+

+ url tag +

+

+ The url tag is used to build urls (who would have guessed!). To build an url mapping to + an action, set the namespace and action attributes. The url will be stored under + the name specified in the id attribute. url tag uses the id attribute while + the set tag uses name. To specify a value (no action lookup), just use the value + attribute. param tags can be nested inside the url tag to add parameters to the url. +

+

+ First link creates a url that maps to an action, second one creates a url to google, passing one parameter: +

+

+

+        <s:url id="evalAction" namespace="/nodecorate" action="jspEval" />
+        <s:a href="%{#evalAction}" >Eval</s:a>
+        
+        <s:url id="google" value="http://www.google.com" >
+            <s:param name="q" value="%{'Struts 2'}" /> 
+        </s:url>
+        <s:a href="%{#google}" >Eval</s:a>
+    
+

+

+ Do it for me +

+

+ [More on the set tag] + [More on the url tag] +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_4.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_4.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_4.jsp new file mode 100644 index 0000000..8d63ee5 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/jsp_4.jsp @@ -0,0 +1,16 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ More on JSP tags +

+

+ Struts 2 provides many more tags which you can learn about + here +

+
+You can keep playing with the JSP console or +Start OGNL Interactive Demo \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_0.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_0.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_0.jsp new file mode 100644 index 0000000..7f441e4 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_0.jsp @@ -0,0 +1,30 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ Accessing properties +

+

+ The framework uses a standard naming context to evaluate OGNL expressions. + The top level object dealing with OGNL is a Map (usually referred as a context map or context). + OGNL has a notion of there being a root (or default) object within the context. + In OGNL expressions, the properties of the root object can be referenced without any special "marker" notion. + References to other objects are marked with a pound sign (#). + + In this example (and in your JSP pages) the last action executed will be on the top of the stack. +

+

+ This action is available on the third tab above. + To access the name field type: +

+

+ + name + +

+

+ on the OGNL console and hit enter. Do it for me +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_1.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_1.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_1.jsp new file mode 100644 index 0000000..17505bd --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_1.jsp @@ -0,0 +1,28 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ Accessing nested properties +

+

+ To access nested properties, use the dot "." operator to concatenate the property names. The action + class has a book field, with title and author fields. +

+

+ To access the name of the book type: +

+

+ + book.title + +

+

+ on the OGNL console and hit enter. Do it for me +

+
+

+ [More details] +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_2.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_2.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_2.jsp new file mode 100644 index 0000000..c1716db --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_2.jsp @@ -0,0 +1,43 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ Accessing properties inside Arrays +

+

+ To access properties inside arrays, use the brackets "[]" operators with the desired index(starting from 0). The action + class has an array of String in the field bands. +

+

+ To access the second element in the bands array type: +

+

+ + bands[1] + +

+

+ on the OGNL console and hit enter. Do it for me +

+

+ Accessing properties inside Lists +

+

Lists can be accessed on the same way. The action class has a List of String on the field movies.

+

+ To access the first element in the movies list type: +

+

+ + movies[0] + +

+

+ on the OGNL console and hit enter. Do it for me +

+
+

+ [More details] +

http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_3.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_3.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_3.jsp new file mode 100644 index 0000000..03c3095 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_3.jsp @@ -0,0 +1,54 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ Accessing properties inside Maps +

+

+ To access properties inside maps, use the brackets "[]" operators with the desired key. The action + class has a map of Book objects in the field books. +

+

+ To access the book with key "Iliad" in the books map type: +

+

+ + books['Iliad'] + +

+

+ on the OGNL console and hit enter. Do it for me +

+

If the key does not have spaces in it, you can access an element in the map, using the dot "." operator.

+

+ To access the book with key "Iliad" in the books map type: +

+

+ + books.Iliad + +

+

+ on the OGNL console and hit enter. Do it for me +

+

+ Note that the object returned is of type Book. If you want to access one of its properties, you can do so using the dot + "." operator as you did before.

+

+ To access the author property of the book with key "Iliad" in the books map type: +

+

+ + books['Iliad'].author + +

+

+ on the OGNL console and hit enter. Do it for me +

+
+

+ [More details] +

http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_4.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_4.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_4.jsp new file mode 100644 index 0000000..7e158d5 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_4.jsp @@ -0,0 +1,32 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ Accessing properties on the stack +

+

+ Object that are not on the top of the Value Stack are accessed using the "#name" notation. + Some objects are always pushed into the stack by Struts, like: +

+
    +
  • #application
  • +
  • #session
  • +
  • #request
  • +
  • #parameters
  • +
+

To see the value of the first parameter type:

+

+ + #parameters['debug'][0] + +

+

+ on the OGNL console and hit enter. Do it for me +

+
+

+ [More details] +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_5.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_5.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_5.jsp new file mode 100644 index 0000000..5624567 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_5.jsp @@ -0,0 +1,25 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ Calling methods +

+

+ OGNL follows Java's syntax to execute a method. +

+

To execute the getTitle() method on the book object type:

+

+ + book.getTitle() + +

+

+ on the OGNL console and hit enter. Do it for me +

+
+

+ [More details] +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_6.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_6.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_6.jsp new file mode 100644 index 0000000..91466e1 --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_6.jsp @@ -0,0 +1,43 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ Expressions +

+

+ OGNL supports expressions using primitive values. +

+

Arithmetic:

+

+ + (6 - 2)/2 + +

+

+ on the OGNL console and hit enter. Do it for me +

+

Logical:

+

+ + (true || false) and true + +

+

+ on the OGNL console and hit enter. Do it for me +

+

Equality:

+

+ + 'a' == 'a' + +

+

+ on the OGNL console and hit enter. Do it for me +

+

+ OGNL supports many more operators and expressions, see [Operators Reference] + for more details. +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_7.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_7.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_7.jsp new file mode 100644 index 0000000..a0318ab --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_7.jsp @@ -0,0 +1,55 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

Creating arrays

+

+ OGNL follows Java syntax to create arrys. +

+

+ Create an array of integers: +

+

+ + new int[] {0, 1, 2} + +

+

+ on the OGNL console and hit enter. Do it for me +

+

Creating lists

+

+ To create a list, enclose a list of comma separated expression in a pair of braces. +

+

+ Create a list of Strings: +

+

+ + {'Is', 'there', 'any', 'body', 'out', 'there?'} + +

+

+ on the OGNL console and hit enter. Do it for me +

+

Creating maps

+

+ To create a map, use the syntax #@MAP_TYPE@{key:value}. +

+

+ Create a LinkedHashMap: +

+

+ + #@java.util.LinkedHashMap@{'name': 'John Galt', 'job' : 'Engineer'} + +

+

+ on the OGNL console and hit enter. Do it for me +

+
+

+ [More details] +

\ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/65eb9751/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_8.jsp ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_8.jsp b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_8.jsp new file mode 100644 index 0000000..3a2cc6e --- /dev/null +++ b/apps/showcase/src/main/webapp/WEB-INF/interactive/ognl_8.jsp @@ -0,0 +1,18 @@ +<% + request.setAttribute("decorator", "none"); + response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 + response.setHeader("Pragma","no-cache"); //HTTP 1.0 + response.setDateHeader ("Expires", 0); //prevents caching at the proxy server +%> +

+ More on OGNL +

+

+ There are a lot of OGNL features that we have not covered on this short tutorial. +

+
+

+ To learn more see the [OGNL Documentation] +

+You can keep playing with the OGNL console or +Start JSP Interactive Demo \ No newline at end of file