From 59f4f31a7f3800a540c168abc67b8800db3f2f97 Mon Sep 17 00:00:00 2001 From: Johannes Geppert Date: Fri, 19 Oct 2012 18:49:39 +0000 Subject: [PATCH] WW-3900 Refactor the Struts2 Showcase git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1400220 13f79535-47bb-0310-9956-ffa450edef68 --- apps/showcase/pom.xml | 62 +- .../apache/struts2/showcase/DateAction.java | 117 +- .../showcase/DynamicTreeSelectAction.java | 34 +- .../LotsOfOptiontransferselectAction.java | 412 +++--- .../showcase/LotsOfRichtexteditorAction.java | 76 +- .../struts2/showcase/MoreSelectsAction.java | 165 +-- .../showcase/ShowAjaxDynamicTreeAction.java | 23 +- .../showcase/ShowDynamicTreeAction.java | 9 +- .../apache/struts2/showcase/UITagExample.java | 602 ++++---- .../showcase/action/AbstractCRUDAction.java | 106 +- .../showcase/action/EmployeeAction.java | 141 +- .../showcase/action/ExampleAction.java | 96 +- .../showcase/action/JSPEvalAction.java | 80 +- .../struts2/showcase/action/SkillAction.java | 84 +- .../showcase/actionchaining/ActionChain1.java | 25 +- .../showcase/actionchaining/ActionChain2.java | 48 +- .../showcase/actionchaining/ActionChain3.java | 59 +- .../struts2/showcase/ajax/AjaxTestAction.java | 36 +- .../ajax/AutocompleterExampleAction.java | 54 +- .../ajax/Example4ShowPanelAction.java | 68 +- .../struts2/showcase/ajax/Example5Action.java | 30 +- .../struts2/showcase/ajax/tree/Category.java | 120 +- .../showcase/ajax/tree/GetCategory.java | 32 +- .../struts2/showcase/ajax/tree/Toggle.java | 10 +- .../showcase/application/MemoryStorage.java | 189 +-- .../struts2/showcase/application/Storage.java | 21 +- .../application/TestDataProvider.java | 137 +- .../chat/ChatAuthenticationInterceptor.java | 37 +- .../struts2/showcase/chat/ChatException.java | 18 +- .../showcase/chat/ChatInterceptor.java | 36 +- .../showcase/chat/ChatLoginAction.java | 63 +- .../showcase/chat/ChatLogoutAction.java | 41 +- .../struts2/showcase/chat/ChatMessage.java | 40 +- .../struts2/showcase/chat/ChatService.java | 28 +- .../showcase/chat/ChatServiceImpl.java | 146 +- .../showcase/chat/ChatSessionListener.java | 41 +- .../struts2/showcase/chat/Constants.java | 2 +- .../struts2/showcase/chat/CrudRoomAction.java | 55 +- .../struts2/showcase/chat/DateConverter.java | 48 +- .../showcase/chat/EnterRoomAction.java | 55 +- .../struts2/showcase/chat/ExitRoomAction.java | 46 +- .../chat/MessagesAvailableInRoomAction.java | 52 +- .../apache/struts2/showcase/chat/Room.java | 119 +- .../showcase/chat/RoomsAvailableAction.java | 30 +- .../chat/SendMessageToRoomAction.java | 67 +- .../apache/struts2/showcase/chat/User.java | 29 +- .../showcase/chat/UsersAvailableAction.java | 30 +- .../chat/UsersAvailableInRoomAction.java | 52 +- .../struts2/showcase/conversion/Address.java | 22 +- .../showcase/conversion/AddressAction.java | 28 +- .../conversion/EnumTypeConverter.java | 44 +- .../showcase/conversion/OperationsEnum.java | 11 +- .../conversion/OperationsEnumAction.java | 41 +- .../struts2/showcase/conversion/Person.java | 25 +- .../showcase/conversion/PersonAction.java | 29 +- .../struts2/showcase/dao/AbstractDao.java | 65 +- .../org/apache/struts2/showcase/dao/Dao.java | 23 +- .../struts2/showcase/dao/EmployeeDao.java | 60 +- .../apache/struts2/showcase/dao/SkillDao.java | 17 +- .../showcase/exception/CreateException.java | 21 +- .../showcase/exception/DeleteException.java | 21 +- .../exception/DuplicateKeyException.java | 21 +- .../showcase/exception/StorageException.java | 21 +- .../showcase/exception/UpdateException.java | 21 +- .../filedownload/FileDownloadAction.java | 26 +- .../showcase/fileupload/FileUploadAction.java | 94 +- .../MultipleFileUploadUsingArrayAction.java | 72 +- .../MultipleFileUploadUsingListAction.java | 85 +- .../freemarker/CustomFreemarkerManager.java | 28 +- .../CustomFreemarkerManagerUtil.java | 16 +- .../freemarker/StandardTagsAction.java | 52 +- .../hangman/GetUpdatedHangmanAction.java | 48 +- .../hangman/GuessCharacterAction.java | 47 +- .../struts2/showcase/hangman/Hangman.java | 134 +- .../showcase/hangman/HangmanConstants.java | 4 +- .../showcase/hangman/HangmanException.java | 28 +- .../showcase/hangman/HangmanService.java | 14 +- .../hangman/PropertiesVocabSource.java | 68 +- .../showcase/hangman/StartHangmanAction.java | 45 +- .../struts2/showcase/hangman/Vocab.java | 91 +- .../struts2/showcase/hangman/VocabSource.java | 2 +- .../integration/EditGangsterAction.java | 22 +- .../showcase/integration/GangsterForm.java | 151 +- .../integration/SaveGangsterAction.java | 33 +- .../showcase/jsf/JsfEmployeeAction.java | 153 +-- .../struts2/showcase/model/Employee.java | 225 ++- .../struts2/showcase/model/IdEntity.java | 5 +- .../apache/struts2/showcase/model/Skill.java | 61 +- .../showcase/modelDriven/Gangster.java | 66 +- .../modelDriven/ModelDrivenAction.java | 21 +- .../showcase/person/EditPersonAction.java | 85 +- .../showcase/person/ListPeopleAction.java | 40 +- .../showcase/person/NewPersonAction.java | 44 +- .../struts2/showcase/person/Person.java | 92 +- .../showcase/person/PersonManager.java | 55 +- .../struts2/showcase/person/package-info.java | 3 +- .../showcase/source/ViewSourceAction.java | 338 +++-- .../tag/nonui/actionPrefix/SubmitAction.java | 25 +- .../tag/nonui/actiontag/ActionTagDemo.java | 14 +- .../iteratortag/AppendIteratorTagDemo.java | 74 +- .../iteratortag/IteratorGeneratorTagDemo.java | 58 +- .../iteratortag/MergeIteratorTagDemo.java | 71 +- .../iteratortag/SubsetIteratorTagDemo.java | 75 +- .../struts2/showcase/token/TokenAction.java | 77 +- .../AbstractValidationActionSupport.java | 12 +- .../FieldValidatorsExampleAction.java | 144 +- .../NonFieldValidatorsExampleAction.java | 49 +- .../showcase/validation/QuizAction.java | 44 +- .../validation/SubmitApplication.java | 54 +- .../struts2/showcase/validation/User.java | 47 +- .../VisitorValidatorsExampleAction.java | 16 +- .../showcase/wait/LongProcessAction.java | 27 +- .../struts2/showcase/xslt/JVMAction.java | 106 +- .../src/main/resources/log4j.properties | 13 +- .../src/main/resources/struts-fileupload.xml | 4 +- .../src/main/resources/struts-hangman.xml | 3 - .../src/main/resources/struts-tags-non-ui.xml | 9 + apps/showcase/src/main/resources/struts.xml | 14 +- .../webapp/WEB-INF/applicationContext.xml | 138 +- .../main/webapp/WEB-INF/decorators/main.jsp | 377 +++-- .../actionchaining/actionChainingResult.jsp | 19 +- .../src/main/webapp/chat/chatLogin.ftl | 29 +- .../src/main/webapp/chat/roomSelection.ftl | 327 ++--- .../src/main/webapp/chat/showRoom.ftl | 316 ++--- .../src/main/webapp/continuations/guess.ftl | 18 - .../webapp/conversion/enterAddressInfo.jsp | 75 +- .../webapp/conversion/enterOperations.jsp | 51 +- .../webapp/conversion/enterPersonInfo.jsp | 97 +- .../src/main/webapp/conversion/index.jsp | 41 +- .../webapp/conversion/showAddressInfo.jsp | 22 +- .../main/webapp/conversion/showOperations.jsp | 24 +- .../main/webapp/conversion/showPersonInfo.jsp | 21 +- .../main/webapp/empmanager/editEmployee.jsp | 79 +- .../src/main/webapp/empmanager/editSkill.jsp | 59 +- .../src/main/webapp/empmanager/index.jsp | 22 +- .../main/webapp/empmanager/listEmployees.jsp | 61 +- .../src/main/webapp/empmanager/listSkills.jsp | 57 +- .../src/main/webapp/filedownload/index.jsp | 37 +- .../src/main/webapp/fileupload/index.jsp | 25 - .../multipleUploadUsingArray-success.jsp | 37 - .../fileupload/multipleUploadUsingArray.jsp | 36 +- .../multipleUploadUsingList-success.jsp | 37 - .../fileupload/multipleUploadUsingList.jsp | 28 +- .../main/webapp/fileupload/upload-success.jsp | 26 +- .../src/main/webapp/fileupload/upload.jsp | 30 +- .../customFreemarkerManagerUsage.ftl | 18 +- .../src/main/webapp/freemarker/index.jsp | 23 +- .../main/webapp/freemarker/standardTags.ftl | 28 +- .../src/main/webapp/hangman/hangmanAjax.ftl | 439 +++--- .../src/main/webapp/hangman/hangmanMenu.ftl | 18 - .../main/webapp/hangman/hangmanNonAjax.ftl | 261 ++-- apps/showcase/src/main/webapp/help.jsp | 43 +- .../main/webapp/integration/modelDriven.jsp | 59 +- .../webapp/integration/modelDrivenResult.jsp | 55 +- .../src/main/webapp/interactive/index.jsp | 8 +- .../src/main/webapp/jsf/employee/edit.jsp | 161 +-- .../src/main/webapp/jsf/employee/list.jsp | 86 +- apps/showcase/src/main/webapp/jsf/index.jsp | 41 +- .../main/webapp/modelDriven/modelDriven.jsp | 59 +- .../webapp/modelDriven/modelDrivenResult.jsp | 50 +- .../src/main/webapp/person/edit-person.jsp | 78 +- .../showcase/src/main/webapp/person/index.jsp | 17 +- .../src/main/webapp/person/list-people.ftl | 58 +- .../src/main/webapp/person/new-person.ftl | 54 +- apps/showcase/src/main/webapp/showcase.jsp | 58 +- apps/showcase/src/main/webapp/styles/main.css | 24 +- apps/showcase/src/main/webapp/tags/index.jsp | 16 - .../tags/non-ui/actionPrefix/actionPrefix.ftl | 28 +- .../actionPrefix/actionPrefixExample.ftl | 96 +- .../webapp/tags/non-ui/actionPrefix/index.jsp | 13 - .../tags/non-ui/actionPrefix/methodPrefix.ftl | 26 +- .../tags/non-ui/actionPrefix/normalSubmit.ftl | 25 +- .../actionPrefix/redirectActionPrefix.ftl | 32 +- .../tags/non-ui/actionTag/includedPage.jsp | 2 +- .../tags/non-ui/actionTag/includedPage2.jsp | 2 +- .../tags/non-ui/actionTag/includedPage3.jsp | 2 +- .../non-ui/actionTag/showActionTagDemo.jsp | 69 +- .../src/main/webapp/tags/non-ui/date.jsp | 200 +-- .../src/main/webapp/tags/non-ui/debug.jsp | 32 +- .../main/webapp/tags/non-ui/ifTag/testIf.ftl | 1209 +++++++++-------- .../main/webapp/tags/non-ui/ifTag/testIf.jsp | 1175 ++++++++-------- .../src/main/webapp/tags/non-ui/index.jsp | 24 - .../appendIteratorTagDemoResult.jsp | 41 +- .../iteratorGeneratorTagDemoResult.jsp | 28 +- .../mergeIteratorTagDemoResult.jsp | 38 +- .../iteratorTag/showAppendIteratorTagDemo.jsp | 27 +- .../showIteratorGeneratorTagDemo.jsp | 32 +- .../iteratorTag/showMergeIteratorTagDemo.jsp | 26 +- .../iteratorTag/subsetIteratorTagDemo.jsp | 29 +- .../subsetIteratorTagDemoResult.jsp | 29 +- .../tags/ui/actionTagExampleCalling.jsp | 24 +- .../webapp/tags/ui/componentTagExample.jsp | 111 +- .../main/webapp/tags/ui/datepicker/index.jsp | 44 +- .../src/main/webapp/tags/ui/example.jsp | 243 ++-- .../src/main/webapp/tags/ui/example.vm | 55 +- .../main/webapp/tags/ui/exampleSubmited.jsp | 92 +- .../main/webapp/tags/ui/exampleSubmited.vm | 96 +- .../src/main/webapp/tags/ui/index.jsp | 25 - .../tags/ui/lotsOfOptiontransferselect.jsp | 174 +-- .../ui/lotsOfOptiontransferselectSubmit.jsp | 179 +-- .../src/main/webapp/tags/ui/moreSelects.jsp | 104 +- .../main/webapp/tags/ui/moreSelectsSubmit.jsp | 100 +- .../main/webapp/tags/ui/timepicker/index.jsp | 39 +- .../webapp/tags/ui/treeExampleAjaxDynamic.jsp | 23 +- .../webapp/tags/ui/treeExampleDynamic.jsp | 78 +- .../main/webapp/tags/ui/treeExampleStatic.jsp | 87 +- apps/showcase/src/main/webapp/tiles/body.ftl | 20 +- apps/showcase/src/main/webapp/tiles/body.jsp | 32 +- .../showcase/src/main/webapp/tiles/header.jsp | 4 +- .../showcase/src/main/webapp/tiles/layout.ftl | 6 +- .../showcase/src/main/webapp/tiles/layout.jsp | 8 +- .../src/main/webapp/token/doublePost.jsp | 23 +- .../src/main/webapp/token/example1.jsp | 54 +- .../src/main/webapp/token/example2.jsp | 42 +- .../src/main/webapp/token/example3.jsp | 41 +- .../src/main/webapp/token/example4.ftl | 48 +- apps/showcase/src/main/webapp/token/index.jsp | 57 +- .../src/main/webapp/token/transferDone.jsp | 53 +- .../clientSideValidationExample.jsp | 81 +- .../validation/fieldValidatorsExample.jsp | 95 +- .../src/main/webapp/validation/footer.jsp | 3 +- .../src/main/webapp/validation/index.jsp | 69 +- .../validation/nonFieldValidatorsExample.jsp | 58 +- .../src/main/webapp/validation/quiz-ajax.jsp | 137 +- .../src/main/webapp/validation/quiz-basic.jsp | 36 +- .../webapp/validation/quiz-client-css.jsp | 31 +- .../main/webapp/validation/quiz-client.jsp | 31 +- .../main/webapp/validation/quiz-success.jsp | 19 +- .../storeErrorsAcrossRequestCancel.jsp | 35 +- .../storeErrorsAcrossRequestExample.jsp | 80 +- .../validation/storeErrorsAcrossRequestOk.jsp | 34 +- .../successClientSideValidationExample.jsp | 27 +- .../successFieldValidatorsExample.jsp | 29 +- .../successNonFieldValidatorsExample.jsp | 26 +- .../successVisitorValidatorsExample.jsp | 29 +- .../validation/validationExamplesStyles.css | 11 - .../validation/visitorValidatorsExample.jsp | 47 +- apps/showcase/src/main/webapp/viewSource.jsp | 72 +- .../src/main/webapp/wait/complete.jsp | 22 +- .../src/main/webapp/wait/example1.jsp | 28 +- .../src/main/webapp/wait/example2.jsp | 28 +- .../src/main/webapp/wait/example3.jsp | 29 +- apps/showcase/src/main/webapp/wait/index.jsp | 35 +- apps/showcase/src/main/webapp/wait/wait.jsp | 37 + 244 files changed, 9210 insertions(+), 8234 deletions(-) delete mode 100644 apps/showcase/src/main/webapp/continuations/guess.ftl delete mode 100644 apps/showcase/src/main/webapp/fileupload/index.jsp delete mode 100644 apps/showcase/src/main/webapp/fileupload/multipleUploadUsingArray-success.jsp delete mode 100644 apps/showcase/src/main/webapp/fileupload/multipleUploadUsingList-success.jsp delete mode 100644 apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl delete mode 100644 apps/showcase/src/main/webapp/tags/index.jsp delete mode 100644 apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/index.jsp delete mode 100644 apps/showcase/src/main/webapp/tags/non-ui/index.jsp delete mode 100644 apps/showcase/src/main/webapp/tags/ui/index.jsp delete mode 100644 apps/showcase/src/main/webapp/validation/validationExamplesStyles.css diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml index d3fe5b64c..b41a47ffd 100644 --- a/apps/showcase/pom.xml +++ b/apps/showcase/pom.xml @@ -164,10 +164,11 @@ log4j log4j + 1.2.16 commons-logging - commons-logging + commons-logging org.apache.myfaces.core @@ -217,47 +218,35 @@ org.mortbay.jetty - maven-jetty-plugin - 6.0.1 + jetty-maven-plugin + 8.0.0.M2 + + + log4j.configuration + file:${basedir}/src/main/resources/log4j.properties + + + slf4j + false + + 10 + ${basedir}/src/main/webapp/ + + /struts2-showcase + ${basedir}/src/main/webapp/WEB-INF/web.xml + - - org.apache.myfaces.core - myfaces-impl - 1.1.2 - - - org.apache.myfaces.core - myfaces-api - 1.1.2 - log4j log4j - 1.2.9 + 1.2.16 - + maven-surefire-plugin @@ -283,13 +272,4 @@ - diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/DateAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/DateAction.java index c84e0b5a2..21aa14840 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/DateAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/DateAction.java @@ -20,87 +20,84 @@ */ package org.apache.struts2.showcase; +import com.opensymphony.xwork2.ActionSupport; + import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; -import com.opensymphony.xwork2.ActionSupport; - /** * DateAction - * */ public class DateAction extends ActionSupport { - private static DateFormat DF = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); + private static DateFormat DF = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); - private Date now; - private Date past; - private Date future; - private Date after; - private Date before; + private Date now; + private Date past; + private Date future; + private Date after; + private Date before; - public String getDate() { - return DF.format(new Date()); - } + public String getDate() { + return DF.format(new Date()); + } - /** - * @return Returns the future. - */ - public Date getFuture() { - return future; - } + /** + * @return Returns the future. + */ + public Date getFuture() { + return future; + } - /** - * @return Returns the now. - */ - public Date getNow() { - return now; - } + /** + * @return Returns the now. + */ + public Date getNow() { + return now; + } - /** - * @return Returns the past. - */ - public Date getPast() { - return past; - } + /** + * @return Returns the past. + */ + public Date getPast() { + return past; + } - /** - * - * @return Returns the before date. - */ - public Date getBefore() { - return before; - } + /** + * @return Returns the before date. + */ + public Date getBefore() { + return before; + } - /** - * - * @return Returns the after date. - */ - public Date getAfter() { - return after; - } + /** + * @return Returns the after date. + */ + public Date getAfter() { + return after; + } - /** - */ - public String browse() throws Exception { - Calendar cal = GregorianCalendar.getInstance(); - now = cal.getTime(); - cal.roll(Calendar.DATE, -1); - cal.roll(Calendar.HOUR, -3); - past = cal.getTime(); - cal.roll(Calendar.DATE, 2); - future = cal.getTime(); + /** + */ + public String browse() throws Exception { + Calendar cal = GregorianCalendar.getInstance(); + now = cal.getTime(); + cal.roll(Calendar.DATE, -1); + cal.roll(Calendar.HOUR, -3); + past = cal.getTime(); + cal.roll(Calendar.DATE, 2); + future = cal.getTime(); - cal.roll(Calendar.YEAR, -1); - before = cal.getTime(); + cal.roll(Calendar.YEAR, -1); + before = cal.getTime(); - cal.roll(Calendar.YEAR, 2); - after = cal.getTime(); - return SUCCESS; - } + cal.roll(Calendar.YEAR, 2); + after = cal.getTime(); + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/DynamicTreeSelectAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/DynamicTreeSelectAction.java index b57833320..422b483cb 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/DynamicTreeSelectAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/DynamicTreeSelectAction.java @@ -20,35 +20,35 @@ */ package org.apache.struts2.showcase; -import org.apache.struts2.showcase.ajax.tree.Category; - import com.opensymphony.xwork2.ActionSupport; +import org.apache.struts2.showcase.ajax.tree.Category; //START SNIPPET: treeExampleDynamicJavaSelected public class DynamicTreeSelectAction extends ActionSupport { - private long nodeId; - private Category currentCategory; + private long nodeId; + private Category currentCategory; - public void setNodeId(long nodeId) { - this.nodeId = nodeId; - } - public long getNodeId() { - return nodeId; - } + public void setNodeId(long nodeId) { + this.nodeId = nodeId; + } + + public long getNodeId() { + return nodeId; + } - public String execute() throws Exception { - currentCategory = Category.getById(nodeId); - return SUCCESS; - } + public String execute() throws Exception { + currentCategory = Category.getById(nodeId); + return SUCCESS; + } - public String getNodeName() { - return currentCategory != null ? currentCategory.getName() : "Node not found"; - } + public String getNodeName() { + return currentCategory != null ? currentCategory.getName() : "Node not found"; + } } //START SNIPPET: treeExampleDynamicJavaSelected diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/LotsOfOptiontransferselectAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/LotsOfOptiontransferselectAction.java index 3649b039b..b56618eeb 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/LotsOfOptiontransferselectAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/LotsOfOptiontransferselectAction.java @@ -20,267 +20,261 @@ */ package org.apache.struts2.showcase; +import com.opensymphony.xwork2.ActionSupport; + +import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.ArrayList; - -import com.opensymphony.xwork2.ActionSupport; /** */ public class LotsOfOptiontransferselectAction extends ActionSupport { - private List _favouriteCartoonCharactersKeys; - private List _notFavouriteCartoonCharactersKeys; + private List _favouriteCartoonCharactersKeys; + private List _notFavouriteCartoonCharactersKeys; - private List _favouriteCarsKeys; - private List _notFavouriteCarsKeys; + private List _favouriteCarsKeys; + private List _notFavouriteCarsKeys; - private List _favouriteMotorcyclesKeys; - private List _notFavouriteMotorcyclesKeys; + private List _favouriteMotorcyclesKeys; + private List _notFavouriteMotorcyclesKeys; - private List _favouriteCountriesKeys; - private List _notFavouriteCountriesKeys; + private List _favouriteCountriesKeys; + private List _notFavouriteCountriesKeys; - private List _favouriteSportsKeys; - private List _nonFavouriteSportsKeys; + private List _favouriteSportsKeys; + private List _nonFavouriteSportsKeys; - private List _favouriteCities; + private List _favouriteCities; - private List _prioritisedFavouriteCartoonCharacters; - private List _prioritisedFavouriteCars; - private List _prioritisedFavouriteCountries; + private List _prioritisedFavouriteCartoonCharacters; + private List _prioritisedFavouriteCars; + private List _prioritisedFavouriteCountries; + // Cartoon Characters + public Map getDefaultFavouriteCartoonCharacters() { + Map m = new LinkedHashMap(); + m.put("heMan", "He-Man"); + m.put("popeye", "Popeye"); + m.put("mockeyMouse", "Mickey Mouse"); + return m; + } - // Cartoon Characters - public Map getDefaultFavouriteCartoonCharacters() { - Map m = new LinkedHashMap(); - m.put("heMan", "He-Man"); - m.put("popeye", "Popeye"); - m.put("mockeyMouse", "Mickey Mouse"); - return m; - } + public Map getDefaultNotFavouriteCartoonCharacters() { + Map m = new LinkedHashMap(); + m.put("donaldDuck", "Donald Duck"); + m.put("atomicAnt", "Atomic Ant"); + m.put("pinkPainter", "Pink Painter"); + return m; + } - public Map getDefaultNotFavouriteCartoonCharacters() { - Map m = new LinkedHashMap(); - m.put("donaldDuck", "Donald Duck"); - m.put("atomicAnt", "Atomic Ant"); - m.put("pinkPainter", "Pink Painter"); - return m; - } + public List getFavouriteCartoonCharacters() { + return _favouriteCartoonCharactersKeys; + } - public List getFavouriteCartoonCharacters() { - return _favouriteCartoonCharactersKeys; - } + public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) { + _favouriteCartoonCharactersKeys = favouriteCartoonCharacters; + } - public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) { - _favouriteCartoonCharactersKeys = favouriteCartoonCharacters; - } + public List getNotFavouriteCartoonCharacters() { + return _notFavouriteCartoonCharactersKeys; + } - public List getNotFavouriteCartoonCharacters() { - return _notFavouriteCartoonCharactersKeys; - } - - public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) { - _notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters; - } + public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) { + _notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters; + } + // Cars + public Map getDefaultFavouriteCars() { + Map m = new LinkedHashMap(); + m.put("alfaRomeo", "Alfa Romeo"); + m.put("Toyota", "Toyota"); + m.put("Mitsubitshi", "Mitsubitshi"); + return m; + } + + public Map getDefaultNotFavouriteCars() { + Map m = new LinkedHashMap(); + m.put("ford", "Ford"); + m.put("landRover", "Land Rover"); + m.put("mercedes", "Mercedes"); + return m; + } + + public List getFavouriteCars() { + return _favouriteCarsKeys; + } + + public void setFavouriteCars(List favouriteCars) { + _favouriteCarsKeys = favouriteCars; + } + + public List getNotFavouriteCars() { + return _notFavouriteCarsKeys; + } + + public void setNotFavouriteCars(List notFavouriteCars) { + _notFavouriteCarsKeys = notFavouriteCars; + } + // Motorcycles + public Map getDefaultFavouriteMotorcycles() { + Map m = new LinkedHashMap(); + m.put("honda", "Honda"); + m.put("yamaha", "Yamaha"); + m.put("Aprillia", "Aprillia"); + return m; + } - // Cars - public Map getDefaultFavouriteCars() { - Map m = new LinkedHashMap(); - m.put("alfaRomeo", "Alfa Romeo"); - m.put("Toyota", "Toyota"); - m.put("Mitsubitshi", "Mitsubitshi"); - return m; - } + public Map getDefaultNotFavouriteMotorcycles() { + Map m = new LinkedHashMap(); + m.put("cagiva", "Cagiva"); + m.put("harleyDavidson", "Harley Davidson"); + m.put("suzuki", "Suzuki"); + return m; + } - public Map getDefaultNotFavouriteCars() { - Map m = new LinkedHashMap(); - m.put("ford", "Ford"); - m.put("landRover", "Land Rover"); - m.put("mercedes", "Mercedes"); - return m; - } + public List getFavouriteMotorcycles() { + return _favouriteMotorcyclesKeys; + } - public List getFavouriteCars() { - return _favouriteCarsKeys; - } + public void setFavouriteMotorcycles(List favouriteMotorcycles) { + _favouriteMotorcyclesKeys = favouriteMotorcycles; + } - public void setFavouriteCars(List favouriteCars) { - _favouriteCarsKeys = favouriteCars; - } + public List getNotFavouriteMotorcycles() { + return _notFavouriteMotorcyclesKeys; + } - public List getNotFavouriteCars() { - return _notFavouriteCarsKeys; - } - - public void setNotFavouriteCars(List notFavouriteCars) { - _notFavouriteCarsKeys = notFavouriteCars; - } + public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) { + _notFavouriteMotorcyclesKeys = notFavouriteMotorcycles; + } + // Countries + public Map getDefaultFavouriteCountries() { + Map m = new LinkedHashMap(); + m.put("england", "England"); + m.put("america", "America"); + m.put("brazil", "Brazil"); + return m; + } - // Motorcycles - public Map getDefaultFavouriteMotorcycles() { - Map m = new LinkedHashMap(); - m.put("honda", "Honda"); - m.put("yamaha", "Yamaha"); - m.put("Aprillia", "Aprillia"); - return m; - } + public Map getDefaultNotFavouriteCountries() { + Map m = new LinkedHashMap(); + m.put("germany", "Germany"); + m.put("china", "China"); + m.put("russia", "Russia"); + return m; + } - public Map getDefaultNotFavouriteMotorcycles() { - Map m = new LinkedHashMap(); - m.put("cagiva", "Cagiva"); - m.put("harleyDavidson", "Harley Davidson"); - m.put("suzuki", "Suzuki"); - return m; - } + public List getFavouriteCountries() { + return _favouriteCountriesKeys; + } - public List getFavouriteMotorcycles() { - return _favouriteMotorcyclesKeys; - } + public void setFavouriteCountries(List favouriteCountries) { + _favouriteCountriesKeys = favouriteCountries; + } - public void setFavouriteMotorcycles(List favouriteMotorcycles) { - _favouriteMotorcyclesKeys = favouriteMotorcycles; - } + public List getNotFavouriteCountries() { + return _notFavouriteCountriesKeys; + } - public List getNotFavouriteMotorcycles() { - return _notFavouriteMotorcyclesKeys; - } + public void setNotFavouriteCountries(List notFavouriteCountries) { + _notFavouriteCountriesKeys = notFavouriteCountries; + } - public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) { - _notFavouriteMotorcyclesKeys = notFavouriteMotorcycles; - } + // Sports + public Map getDefaultNonFavoriteSports() { + Map m = new LinkedHashMap(); + m.put("basketball", "Basketball"); + m.put("football", "Football"); + m.put("baseball", "Baseball"); + return m; + } + + public Map getDefaultFavoriteSports() { + return new LinkedHashMap(); + } + + public List getFavouriteSports() { + return _favouriteSportsKeys; + } + + public void setFavouriteSports(List favouriteSportsKeys) { + this._favouriteSportsKeys = favouriteSportsKeys; + } + + public List getNonFavouriteSports() { + return _nonFavouriteSportsKeys; + } + + public void setNonFavouriteSports(List notFavouriteSportsKeys) { + this._nonFavouriteSportsKeys = notFavouriteSportsKeys; + } + public List getPrioritisedFavouriteCartoonCharacters() { + return _prioritisedFavouriteCartoonCharacters; + } - // Countries - public Map getDefaultFavouriteCountries() { - Map m = new LinkedHashMap(); - m.put("england", "England"); - m.put("america", "America"); - m.put("brazil", "Brazil"); - return m; - } + public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) { + _prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters; + } - public Map getDefaultNotFavouriteCountries() { - Map m = new LinkedHashMap(); - m.put("germany", "Germany"); - m.put("china", "China"); - m.put("russia", "Russia"); - return m; - } + public List getPrioritisedFavouriteCars() { + return _prioritisedFavouriteCars; + } - public List getFavouriteCountries() { - return _favouriteCountriesKeys; - } - - public void setFavouriteCountries(List favouriteCountries) { - _favouriteCountriesKeys = favouriteCountries; - } - - public List getNotFavouriteCountries() { - return _notFavouriteCountriesKeys; - } - - public void setNotFavouriteCountries(List notFavouriteCountries) { - _notFavouriteCountriesKeys = notFavouriteCountries; - } - - // Sports - public Map getDefaultNonFavoriteSports() { - Map m = new LinkedHashMap(); - m.put("basketball", "Basketball"); - m.put("football", "Football"); - m.put("baseball", "Baseball"); - return m; - } - - public Map getDefaultFavoriteSports() { - return new LinkedHashMap(); - } - - public List getFavouriteSports() { - return _favouriteSportsKeys; - } - - public void setFavouriteSports(List favouriteSportsKeys) { - this._favouriteSportsKeys = favouriteSportsKeys; - } - - public List getNonFavouriteSports() { - return _nonFavouriteSportsKeys; - } - - public void setNonFavouriteSports(List notFavouriteSportsKeys) { - this._nonFavouriteSportsKeys = notFavouriteSportsKeys; - } + public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) { + _prioritisedFavouriteCars = prioritisedFavouriteCars; + } - + public List getPrioritisedFavouriteCountries() { + return _prioritisedFavouriteCountries; + } - public List getPrioritisedFavouriteCartoonCharacters() { - return _prioritisedFavouriteCartoonCharacters; - } - public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) { - _prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters; - } - - public List getPrioritisedFavouriteCars() { - return _prioritisedFavouriteCars; - } - public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) { - _prioritisedFavouriteCars = prioritisedFavouriteCars; - } + public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) { + _prioritisedFavouriteCountries = prioritisedFavouriteCountries; + } - public List getPrioritisedFavouriteCountries() { - return _prioritisedFavouriteCountries; - } - public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) { - _prioritisedFavouriteCountries = prioritisedFavouriteCountries; - } + public Map getAvailableCities() { + Map map = new LinkedHashMap(); + map.put("boston", "Boston"); + map.put("new york", "New York"); + map.put("london", "London"); + map.put("rome", "Rome"); + return map; + } + public List getDefaultFavouriteCities() { + List list = new ArrayList(); + list.add("boston"); + list.add("rome"); + return list; + } + public List getFavouriteCities() { + return _favouriteCities; + } - public Map getAvailableCities() { - Map map = new LinkedHashMap(); - map.put("boston", "Boston"); - map.put("new york", "New York"); - map.put("london", "London"); - map.put("rome", "Rome"); - return map; - } + public void setFavouriteCities(List favouriteCities) { + this._favouriteCities = favouriteCities; + } - public List getDefaultFavouriteCities() { - List list = new ArrayList(); - list.add("boston"); - list.add("rome"); - return list; - } + // actions - public List getFavouriteCities() { - return _favouriteCities; - } + public String input() throws Exception { + return SUCCESS; + } - public void setFavouriteCities(List favouriteCities) { - this._favouriteCities = favouriteCities; - } - - // actions - - public String input() throws Exception { - return SUCCESS; - } - - public String submit() throws Exception { - return SUCCESS; - } + public String submit() throws Exception { + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/LotsOfRichtexteditorAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/LotsOfRichtexteditorAction.java index 410a499c7..1e106691d 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/LotsOfRichtexteditorAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/LotsOfRichtexteditorAction.java @@ -27,52 +27,52 @@ import com.opensymphony.xwork2.ActionSupport; */ public class LotsOfRichtexteditorAction extends ActionSupport { - public String description1; - public String description2 = "This is Description 2"; - public String description3; - public String description4 = "This is Description 4"; + public String description1; + public String description2 = "This is Description 2"; + public String description3; + public String description4 = "This is Description 4"; - public String getDescription1() { - return this.description1; - } - public void setDescription1(String description1) { - this.description1 = description1; - } + public String getDescription1() { + return this.description1; + } + + public void setDescription1(String description1) { + this.description1 = description1; + } - public String getDescription2() { - return this.description2; - } - public void setDescription2(String description2) { - this.description2 = description2; - } + public String getDescription2() { + return this.description2; + } + + public void setDescription2(String description2) { + this.description2 = description2; + } - public String getDescription3() { - return this.description3; - } - public void setDescription3(String description3) { - this.description3 = description3; - } + public String getDescription3() { + return this.description3; + } + + public void setDescription3(String description3) { + this.description3 = description3; + } + public String getDescription4() { + return this.description4; + } + + public void setDescription4(String description4) { + this.description4 = description4; + } - public String getDescription4() { - return this.description4; - } - public void setDescription4(String description4) { - this.description4 = description4; - } + public String input() throws Exception { + return SUCCESS; + } - - - - public String input() throws Exception { - return SUCCESS; - } - - public String submit() throws Exception { - return SUCCESS; - } + public String submit() throws Exception { + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/MoreSelectsAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/MoreSelectsAction.java index 516f4314a..edbe4ae2b 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/MoreSelectsAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/MoreSelectsAction.java @@ -22,114 +22,115 @@ package org.apache.struts2.showcase; import com.opensymphony.xwork2.ActionSupport; +import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.LinkedHashMap; -import java.util.ArrayList; /** */ public class MoreSelectsAction extends ActionSupport { - private List _prioritisedFavouriteCartoonCharacters; - private List _prioritisedFavouriteCars; - private List _prioritisedFavouriteCountries; - private List favouriteNumbers; + private List _prioritisedFavouriteCartoonCharacters; + private List _prioritisedFavouriteCars; + private List _prioritisedFavouriteCountries; + private List favouriteNumbers; - // Cartoon Characters - public Map getDefaultFavouriteCartoonCharacters() { - Map m = new LinkedHashMap(); - m.put("heMan", "He-Man"); - m.put("popeye", "Popeye"); - m.put("mockeyMouse", "Mickey Mouse"); - return m; - } + // Cartoon Characters + public Map getDefaultFavouriteCartoonCharacters() { + Map m = new LinkedHashMap(); + m.put("heMan", "He-Man"); + m.put("popeye", "Popeye"); + m.put("mockeyMouse", "Mickey Mouse"); + return m; + } - // Cars - public Map getDefaultFavouriteCars() { - Map m = new LinkedHashMap(); - m.put("alfaRomeo", "Alfa Romeo"); - m.put("Toyota", "Toyota"); - m.put("Mitsubitshi", "Mitsubitshi"); - return m; - } + // Cars + public Map getDefaultFavouriteCars() { + Map m = new LinkedHashMap(); + m.put("alfaRomeo", "Alfa Romeo"); + m.put("Toyota", "Toyota"); + m.put("Mitsubitshi", "Mitsubitshi"); + return m; + } + // Countries + public Map getDefaultFavouriteCountries() { + Map m = new LinkedHashMap(); + m.put("england", "England"); + m.put("america", "America"); + m.put("brazil", "Brazil"); + return m; + } - // Countries - public Map getDefaultFavouriteCountries() { - Map m = new LinkedHashMap(); - m.put("england", "England"); - m.put("america", "America"); - m.put("brazil", "Brazil"); - return m; - } - - public List getDefaultFavouriteNumbers() { - List list = new ArrayList(); - list.add("Three"); - list.add("Seven"); - return list; - } + public List getDefaultFavouriteNumbers() { + List list = new ArrayList(); + list.add("Three"); + list.add("Seven"); + return list; + } + public List getPrioritisedFavouriteCartoonCharacters() { + return _prioritisedFavouriteCartoonCharacters; + } - public List getPrioritisedFavouriteCartoonCharacters() { - return _prioritisedFavouriteCartoonCharacters; - } - public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) { - _prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters; - } + public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) { + _prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters; + } - public List getPrioritisedFavouriteCars() { - return _prioritisedFavouriteCars; - } - public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) { - _prioritisedFavouriteCars = prioritisedFavouriteCars; - } + public List getPrioritisedFavouriteCars() { + return _prioritisedFavouriteCars; + } + + public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) { + _prioritisedFavouriteCars = prioritisedFavouriteCars; + } - public List getPrioritisedFavouriteCountries() { - return _prioritisedFavouriteCountries; - } - public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) { - _prioritisedFavouriteCountries = prioritisedFavouriteCountries; - } + public List getPrioritisedFavouriteCountries() { + return _prioritisedFavouriteCountries; + } - public List getFavouriteNumbers() { - return favouriteNumbers; - } + public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) { + _prioritisedFavouriteCountries = prioritisedFavouriteCountries; + } - public void setFavouriteNumbers(List favouriteNumbers) { - this.favouriteNumbers = favouriteNumbers; - } + public List getFavouriteNumbers() { + return favouriteNumbers; + } - public Map getAvailableCities() { - Map map = new LinkedHashMap(); - map.put("boston", "Boston"); - map.put("new york", "New York"); - map.put("london", "London"); - map.put("rome", "Rome"); - return map; - } + public void setFavouriteNumbers(List favouriteNumbers) { + this.favouriteNumbers = favouriteNumbers; + } - public List getDefaultFavouriteCities() { - List list = new ArrayList(); - list.add("boston"); - list.add("rome"); - return list; - } + public Map getAvailableCities() { + Map map = new LinkedHashMap(); + map.put("boston", "Boston"); + map.put("new york", "New York"); + map.put("london", "London"); + map.put("rome", "Rome"); + return map; + } - // actions + public List getDefaultFavouriteCities() { + List list = new ArrayList(); + list.add("boston"); + list.add("rome"); + return list; + } - public String input() throws Exception { - return SUCCESS; - } + // actions - public String submit() throws Exception { - return SUCCESS; - } + public String input() throws Exception { + return SUCCESS; + } + + public String submit() throws Exception { + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ShowAjaxDynamicTreeAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ShowAjaxDynamicTreeAction.java index 5a8fb4007..40ec4b72c 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ShowAjaxDynamicTreeAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ShowAjaxDynamicTreeAction.java @@ -20,22 +20,21 @@ */ package org.apache.struts2.showcase; +import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.showcase.ajax.tree.Category; -import com.opensymphony.xwork2.ActionSupport; - public class ShowAjaxDynamicTreeAction extends ActionSupport { - private int nodeId = 1; + private int nodeId = 1; - public Category getCategory() { - return Category.getById(nodeId); - } + public Category getCategory() { + return Category.getById(nodeId); + } - public int getNodeId() { - return nodeId; - } + public int getNodeId() { + return nodeId; + } - public void setNodeId(int nodeId) { - this.nodeId = nodeId; - } + public void setNodeId(int nodeId) { + this.nodeId = nodeId; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ShowDynamicTreeAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ShowDynamicTreeAction.java index fcbe56d0a..cec997465 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ShowDynamicTreeAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ShowDynamicTreeAction.java @@ -20,17 +20,16 @@ */ package org.apache.struts2.showcase; -import org.apache.struts2.showcase.ajax.tree.Category; - import com.opensymphony.xwork2.ActionSupport; +import org.apache.struts2.showcase.ajax.tree.Category; // START SNIPPET: treeExampleDynamicJavaShow public class ShowDynamicTreeAction extends ActionSupport { - public Category getTreeRootNode() { - return Category.getById(1); - } + public Category getTreeRootNode() { + return Category.getById(1); + } } // END SNIPPET: treeExampleDynamicJavaShow diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/UITagExample.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/UITagExample.java index 077a7f380..ca5aecbb7 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/UITagExample.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/UITagExample.java @@ -32,306 +32,318 @@ import java.util.*; */ public class UITagExample extends ActionSupport implements Validateable { - private static final long serialVersionUID = -94044809860988047L; - - - String name; - Date birthday; - Date wakeup; - String bio; - String favouriteColor; - List friends; - String bestFriend; - boolean legalAge; - String state; - String region; - File picture; - String pictureContentType; - String pictureFileName; - String favouriteLanguage; - String favouriteVehicalType = "MotorcycleKey"; - String favouriteVehicalSpecific = "YamahaKey"; - - List leftSideCartoonCharacters; - List rightSideCartoonCharacters; - - List favouriteLanguages = new ArrayList(); - List vehicalTypeList = new ArrayList(); - Map vehicalSpecificMap = new HashMap(); - - String thoughts; - - public UITagExample() { - favouriteLanguages.add(new Language("EnglishKey", "English Language", "color: blue; font-style: italic;")); - favouriteLanguages.add(new Language("FrenchKey", "French Language", "color: grey;")); - favouriteLanguages.add(new Language("SpanishKey", "Spanish Language", "color: red; font-wight: bold;")); - - VehicalType car = new VehicalType("CarKey", "Car"); - VehicalType motorcycle = new VehicalType("MotorcycleKey", "Motorcycle"); - vehicalTypeList.add(car); - vehicalTypeList.add(motorcycle); - - List cars = new ArrayList(); - cars.add(new VehicalSpecific("MercedesKey", "Mercedes")); - cars.add(new VehicalSpecific("HondaKey", "Honda")); - cars.add(new VehicalSpecific("FordKey", "Ford")); - - List motorcycles = new ArrayList(); - motorcycles.add(new VehicalSpecific("SuzukiKey", "Suzuki")); - motorcycles.add(new VehicalSpecific("YamahaKey", "Yamaha")); - - vehicalSpecificMap.put(car, cars); - vehicalSpecificMap.put(motorcycle, motorcycles); - } - - - - public List getLeftSideCartoonCharacters() { - return leftSideCartoonCharacters; - } - public void setLeftSideCartoonCharacters(List leftSideCartoonCharacters) { - this.leftSideCartoonCharacters = leftSideCartoonCharacters; - } - - - public List getRightSideCartoonCharacters() { - return rightSideCartoonCharacters; - } - public void setRightSideCartoonCharacters(List rightSideCartoonCharacters) { - this.rightSideCartoonCharacters = rightSideCartoonCharacters; - } - - - public String getFavouriteVehicalType() { - return favouriteVehicalType; - } - - public void setFavouriteVehicalType(String favouriteVehicalType) { - this.favouriteVehicalType = favouriteVehicalType; - } - - public String getFavouriteVehicalSpecific() { - return favouriteVehicalSpecific; - } - - public void setFavouriteVehicalSpecific(String favouriteVehicalSpecific) { - this.favouriteVehicalSpecific = favouriteVehicalSpecific; - } - - public List getVehicalTypeList() { - return vehicalTypeList; - } - - public List getVehicalSpecificList() { - ValueStack stack = ServletActionContext.getValueStack(ServletActionContext.getRequest()); - Object vehicalType = stack.findValue("top"); - if (vehicalType != null && vehicalType instanceof VehicalType) { - List l = (List) vehicalSpecificMap.get(vehicalType); - return l; - } - return Collections.EMPTY_LIST; - } - - public List getFavouriteLanguages() { - return favouriteLanguages; - } - - public String execute() throws Exception { - return SUCCESS; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Date getBirthday() { - return birthday; - } + private static final long serialVersionUID = -94044809860988047L; + + + String name; + Date birthday; + Date wakeup; + String bio; + String favouriteColor; + List friends; + String bestFriend; + boolean legalAge; + String state; + String region; + File picture; + String pictureContentType; + String pictureFileName; + String favouriteLanguage; + String favouriteVehicalType = "MotorcycleKey"; + String favouriteVehicalSpecific = "YamahaKey"; + + List leftSideCartoonCharacters; + List rightSideCartoonCharacters; + + List favouriteLanguages = new ArrayList(); + List vehicalTypeList = new ArrayList(); + Map vehicalSpecificMap = new HashMap(); + + String thoughts; + + public UITagExample() { + favouriteLanguages.add(new Language("EnglishKey", "English Language", "color: blue; font-style: italic;")); + favouriteLanguages.add(new Language("FrenchKey", "French Language", "color: grey;")); + favouriteLanguages.add(new Language("SpanishKey", "Spanish Language", "color: red; font-wight: bold;")); + + VehicalType car = new VehicalType("CarKey", "Car"); + VehicalType motorcycle = new VehicalType("MotorcycleKey", "Motorcycle"); + vehicalTypeList.add(car); + vehicalTypeList.add(motorcycle); + + List cars = new ArrayList(); + cars.add(new VehicalSpecific("MercedesKey", "Mercedes")); + cars.add(new VehicalSpecific("HondaKey", "Honda")); + cars.add(new VehicalSpecific("FordKey", "Ford")); + + List motorcycles = new ArrayList(); + motorcycles.add(new VehicalSpecific("SuzukiKey", "Suzuki")); + motorcycles.add(new VehicalSpecific("YamahaKey", "Yamaha")); + + vehicalSpecificMap.put(car, cars); + vehicalSpecificMap.put(motorcycle, motorcycles); + } + + + public List getLeftSideCartoonCharacters() { + return leftSideCartoonCharacters; + } + + public void setLeftSideCartoonCharacters(List leftSideCartoonCharacters) { + this.leftSideCartoonCharacters = leftSideCartoonCharacters; + } + + + public List getRightSideCartoonCharacters() { + return rightSideCartoonCharacters; + } + + public void setRightSideCartoonCharacters(List rightSideCartoonCharacters) { + this.rightSideCartoonCharacters = rightSideCartoonCharacters; + } + + + public String getFavouriteVehicalType() { + return favouriteVehicalType; + } + + public void setFavouriteVehicalType(String favouriteVehicalType) { + this.favouriteVehicalType = favouriteVehicalType; + } + + public String getFavouriteVehicalSpecific() { + return favouriteVehicalSpecific; + } + + public void setFavouriteVehicalSpecific(String favouriteVehicalSpecific) { + this.favouriteVehicalSpecific = favouriteVehicalSpecific; + } + + public List getVehicalTypeList() { + return vehicalTypeList; + } + + public List getVehicalSpecificList() { + ValueStack stack = ServletActionContext.getValueStack(ServletActionContext.getRequest()); + Object vehicalType = stack.findValue("top"); + if (vehicalType != null && vehicalType instanceof VehicalType) { + List l = (List) vehicalSpecificMap.get(vehicalType); + return l; + } + return Collections.EMPTY_LIST; + } + + public List getFavouriteLanguages() { + return favouriteLanguages; + } + + public String execute() throws Exception { + return SUCCESS; + } + + public String getName() { + return name; + } - public void setBirthday(Date birthday) { - this.birthday = birthday; - } - - public String getBio() { - return bio; - } + public void setName(String name) { + this.name = name; + } - public void setBio(String bio) { - this.bio = bio; - } + public Date getBirthday() { + return birthday; + } - public String getFavouriteColor() { - return favouriteColor; - } + public void setBirthday(Date birthday) { + this.birthday = birthday; + } - public void setFavouriteColor(String favoriteColor) { - this.favouriteColor = favoriteColor; - } + public String getBio() { + return bio; + } - public List getFriends() { - return friends; - } + public void setBio(String bio) { + this.bio = bio; + } - public void setFriends(List friends) { - this.friends = friends; - } - - public String getBestFriend() { - return bestFriend; - } + public String getFavouriteColor() { + return favouriteColor; + } - public void setBestFriend(String bestFriend) { - this.bestFriend = bestFriend; - } - - public boolean isLegalAge() { - return legalAge; - } - - public void setLegalAge(boolean legalAge) { - this.legalAge = legalAge; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getRegion() { - return region; - } - - public void setRegion(String region) { - this.region = region; - } - - public void setPicture(File picture) { - this.picture = picture; - } - - public File getPicture() { - return this.picture; - } - - public void setPictureContentType(String pictureContentType) { - this.pictureContentType = pictureContentType; - } - - public void setPictureFileName(String pictureFileName) { - this.pictureFileName = pictureFileName; - } - - public void setFavouriteLanguage(String favouriteLanguage) { - this.favouriteLanguage = favouriteLanguage; - } - - public String getFavouriteLanguage() { - return favouriteLanguage; - } - - - public void setThoughts(String thoughts) { - this.thoughts = thoughts; - } - - public String getThoughts() { - return this.thoughts; - } - - public Date getWakeup() { - return wakeup; - } - - public void setWakeup(Date wakeup) { - this.wakeup = wakeup; - } - - public String doSubmit() { - return SUCCESS; - } - - - - // === inner class - public static class Language { - String description; - String key; - String style; - - public Language(String key, String description, String style) { - this.key = key; - this.description = description; - this.style = style; - } - - public String getKey() { - return key; - } - public String getDescription() { - return description; - } - public String getStyle() { - return style; - } - - } - - - public static class VehicalType { - String key; - String description; - public VehicalType(String key, String description) { - this.key = key; - this.description = description; - } - - public String getKey() { return this.key; } - public String getDescription() { return this.description; } - - public boolean equals(Object obj) { - if (! (obj instanceof VehicalType)) { - return false; - } - else { - return key.equals(((VehicalType)obj).getKey()); - } - } - - public int hashCode() { - return key.hashCode(); - } - } - - - public static class VehicalSpecific { - String key; - String description; - public VehicalSpecific(String key, String description) { - this.key = key; - this.description = description; - } - - public String getKey() { return this.key; } - public String getDescription() { return this.description; } - - public boolean equals(Object obj) { - if (! (obj instanceof VehicalSpecific)) { - return false; - } - else { - return key.equals(((VehicalSpecific)obj).getKey()); - } - } - - public int hashCode() { - return key.hashCode(); - } - } + public void setFavouriteColor(String favoriteColor) { + this.favouriteColor = favoriteColor; + } + + public List getFriends() { + return friends; + } + + public void setFriends(List friends) { + this.friends = friends; + } + + public String getBestFriend() { + return bestFriend; + } + + public void setBestFriend(String bestFriend) { + this.bestFriend = bestFriend; + } + + public boolean isLegalAge() { + return legalAge; + } + + public void setLegalAge(boolean legalAge) { + this.legalAge = legalAge; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public void setPicture(File picture) { + this.picture = picture; + } + + public File getPicture() { + return this.picture; + } + + public void setPictureContentType(String pictureContentType) { + this.pictureContentType = pictureContentType; + } + + public void setPictureFileName(String pictureFileName) { + this.pictureFileName = pictureFileName; + } + + public void setFavouriteLanguage(String favouriteLanguage) { + this.favouriteLanguage = favouriteLanguage; + } + + public String getFavouriteLanguage() { + return favouriteLanguage; + } + + + public void setThoughts(String thoughts) { + this.thoughts = thoughts; + } + + public String getThoughts() { + return this.thoughts; + } + + public Date getWakeup() { + return wakeup; + } + + public void setWakeup(Date wakeup) { + this.wakeup = wakeup; + } + + public String doSubmit() { + return SUCCESS; + } + + + // === inner class + public static class Language { + String description; + String key; + String style; + + public Language(String key, String description, String style) { + this.key = key; + this.description = description; + this.style = style; + } + + public String getKey() { + return key; + } + + public String getDescription() { + return description; + } + + public String getStyle() { + return style; + } + + } + + + public static class VehicalType { + String key; + String description; + + public VehicalType(String key, String description) { + this.key = key; + this.description = description; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return this.description; + } + + public boolean equals(Object obj) { + if (!(obj instanceof VehicalType)) { + return false; + } else { + return key.equals(((VehicalType) obj).getKey()); + } + } + + public int hashCode() { + return key.hashCode(); + } + } + + + public static class VehicalSpecific { + String key; + String description; + + public VehicalSpecific(String key, String description) { + this.key = key; + this.description = description; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return this.description; + } + + public boolean equals(Object obj) { + if (!(obj instanceof VehicalSpecific)) { + return false; + } else { + return key.equals(((VehicalSpecific) obj).getKey()); + } + } + + public int hashCode() { + return key.hashCode(); + } + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/AbstractCRUDAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/AbstractCRUDAction.java index 0e53d3832..e2db05c70 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/AbstractCRUDAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/AbstractCRUDAction.java @@ -20,78 +20,76 @@ */ package org.apache.struts2.showcase.action; -import java.io.Serializable; -import java.util.Collection; - +import com.opensymphony.xwork2.ActionSupport; import org.apache.log4j.Logger; import org.apache.struts2.showcase.dao.Dao; import org.apache.struts2.showcase.model.IdEntity; -import com.opensymphony.xwork2.ActionSupport; +import java.io.Serializable; +import java.util.Collection; /** * AbstractCRUDAction. - * */ public abstract class AbstractCRUDAction extends ActionSupport { - private static final Logger log = Logger.getLogger(AbstractCRUDAction.class); + private static final Logger log = Logger.getLogger(AbstractCRUDAction.class); - private Collection availableItems; - private String[] toDelete; + private Collection availableItems; + private String[] toDelete; - protected abstract Dao getDao(); + protected abstract Dao getDao(); - public Collection getAvailableItems() { - return availableItems; - } + public Collection getAvailableItems() { + return availableItems; + } - public String[] getToDelete() { - return toDelete; - } + public String[] getToDelete() { + return toDelete; + } - public void setToDelete(String[] toDelete) { - this.toDelete = toDelete; - } + public void setToDelete(String[] toDelete) { + this.toDelete = toDelete; + } - public String list() throws Exception { - this.availableItems = getDao().findAll(); - if (log.isDebugEnabled()) { - log.debug("AbstractCRUDAction - [list]: " + (availableItems !=null?""+availableItems.size():"no") + " items found"); - } - return execute(); - } + public String list() throws Exception { + this.availableItems = getDao().findAll(); + if (log.isDebugEnabled()) { + log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found"); + } + return execute(); + } - public String delete() throws Exception { - if (toDelete != null) { - int count=0; - for (int i = 0, j=toDelete.length; i < j; i++) { - count = count + getDao().delete(toDelete[i]); - } - if (log.isDebugEnabled()) { - log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted."); - } - } - return SUCCESS; - } + public String delete() throws Exception { + if (toDelete != null) { + int count = 0; + for (int i = 0, j = toDelete.length; i < j; i++) { + count = count + getDao().delete(toDelete[i]); + } + if (log.isDebugEnabled()) { + log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted."); + } + } + return SUCCESS; + } - /** - * Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle. - * - * @param tryId The id to try to get persistent object for - * @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent - * object for - * @return The persistent object, if found. null otherwise. - */ - protected IdEntity fetch(Serializable tryId, IdEntity tryObject) { - IdEntity result = null; - if (tryId != null) { - result = getDao().get(tryId); - } else if (tryObject != null) { - result = getDao().get(tryObject.getId()); - } - return result; - } + /** + * Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle. + * + * @param tryId The id to try to get persistent object for + * @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent + * object for + * @return The persistent object, if found. null otherwise. + */ + protected IdEntity fetch(Serializable tryId, IdEntity tryObject) { + IdEntity result = null; + if (tryId != null) { + result = getDao().get(tryId); + } else if (tryObject != null) { + result = getDao().get(tryObject.getId()); + } + return result; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/EmployeeAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/EmployeeAction.java index 8af63fa23..d0ebb32a6 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/EmployeeAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/EmployeeAction.java @@ -20,19 +20,19 @@ */ package org.apache.struts2.showcase.action; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - +import com.opensymphony.xwork2.Preparable; import org.apache.log4j.Logger; import org.apache.struts2.showcase.application.TestDataProvider; import org.apache.struts2.showcase.dao.Dao; import org.apache.struts2.showcase.dao.EmployeeDao; import org.apache.struts2.showcase.model.Employee; import org.apache.struts2.showcase.model.Skill; +import org.springframework.beans.factory.annotation.Autowired; -import com.opensymphony.xwork2.Preparable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; /** * JsfEmployeeAction. @@ -40,87 +40,82 @@ import com.opensymphony.xwork2.Preparable; public class EmployeeAction extends AbstractCRUDAction implements Preparable { - private static final long serialVersionUID = 7047317819789938957L; + private static final long serialVersionUID = 7047317819789938957L; - private static final Logger log = Logger.getLogger(EmployeeAction.class); + private static final Logger log = Logger.getLogger(EmployeeAction.class); - private Long empId; - protected EmployeeDao employeeDao; - private Employee currentEmployee; - private List selectedSkills; + @Autowired + private EmployeeDao employeeDao; - public Long getEmpId() { - return empId; - } + private Long empId; + private Employee currentEmployee; + private List selectedSkills; - public void setEmpId(Long empId) { - this.empId = empId; - } + public String execute() throws Exception { + if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) { + setSelectedSkills(new ArrayList()); + Iterator it = getCurrentEmployee().getOtherSkills().iterator(); + while (it.hasNext()) { + getSelectedSkills().add(((Skill) it.next()).getName()); + } + } + return super.execute(); + } - public Employee getCurrentEmployee() { - return currentEmployee; - } + public String save() throws Exception { + if (getCurrentEmployee() != null) { + setEmpId((Long) employeeDao.merge(getCurrentEmployee())); + employeeDao.setSkills(getEmpId(), getSelectedSkills()); + } + return SUCCESS; + } - public void setCurrentEmployee(Employee currentEmployee) { - this.currentEmployee = currentEmployee; - } + public Long getEmpId() { + return empId; + } - public String[] getAvailablePositions() { - return TestDataProvider.POSITIONS; - } + public void setEmpId(Long empId) { + this.empId = empId; + } - public List getAvailableLevels() { - return Arrays.asList(TestDataProvider.LEVELS); - } + public Employee getCurrentEmployee() { + return currentEmployee; + } - public List getSelectedSkills() { - return selectedSkills; - } + public void setCurrentEmployee(Employee currentEmployee) { + this.currentEmployee = currentEmployee; + } - public void setSelectedSkills(List selectedSkills) { - this.selectedSkills = selectedSkills; - } + public String[] getAvailablePositions() { + return TestDataProvider.POSITIONS; + } - protected Dao getDao() { - return employeeDao; - } + public List getAvailableLevels() { + return Arrays.asList(TestDataProvider.LEVELS); + } - public void setEmployeeDao(EmployeeDao employeeDao) { - if (log.isDebugEnabled()) { - log.debug("JsfEmployeeAction - [setEmployeeDao]: employeeDao injected."); - } - this.employeeDao = employeeDao; - } + public List getSelectedSkills() { + return selectedSkills; + } - /** - * This method is called to allow the action to prepare itself. - * - * @throws Exception thrown if a system level exception occurs. - */ - public void prepare() throws Exception { - Employee preFetched = (Employee) fetch(getEmpId(), getCurrentEmployee()); - if (preFetched != null) { - setCurrentEmployee(preFetched); - } - } + public void setSelectedSkills(List selectedSkills) { + this.selectedSkills = selectedSkills; + } - public String execute() throws Exception { - if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) { - setSelectedSkills(new ArrayList()); - Iterator it = getCurrentEmployee().getOtherSkills().iterator(); - while (it.hasNext()) { - getSelectedSkills().add(((Skill) it.next()).getName()); - } - } - return super.execute(); - } + protected Dao getDao() { + return employeeDao; + } - public String save() throws Exception { - if (getCurrentEmployee() != null) { - setEmpId((Long) employeeDao.merge(getCurrentEmployee())); - employeeDao.setSkills(getEmpId(), getSelectedSkills()); - } - return SUCCESS; - } + /** + * This method is called to allow the action to prepare itself. + * + * @throws Exception thrown if a system level exception occurs. + */ + public void prepare() throws Exception { + Employee preFetched = (Employee) fetch(getEmpId(), getCurrentEmployee()); + if (preFetched != null) { + setCurrentEmployee(preFetched); + } + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java index 4bc64fb7e..82d8d3231 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java @@ -20,69 +20,65 @@ */ 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; +import java.util.*; + 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 static final String CONSTANT = "Struts Rocks!"; - public String[] getBands() { - return new String[] { "Pink Floyd", "Metallica", "Guns & Roses" }; - } + public static Date getCurrentDate() { + return new Date(); + } - public List getMovies() { - return Arrays.asList("Lord of the Rings", "Matrix"); - } + public String getName() { + return "John Galt"; + } - public Book getBook() { - return new Book("Iliad", "Homer"); - } + public String[] getBands() { + return new String[]{"Pink Floyd", "Metallica", "Guns & Roses"}; + } - public Map getBooks() { - Map books = new HashMap(); - 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; - } + public List getMovies() { + return Arrays.asList("Lord of the Rings", "Matrix"); + } + + public Book getBook() { + return new Book("Iliad", "Homer"); + } + + public Map getBooks() { + Map books = new HashMap(); + 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; + private String title; + private String author; - public Book(String title, String author) { - this.title = title; - this.author = author; - } + public Book(String title, String author) { + this.title = title; + this.author = author; + } - public String getTitle() { - return title; - } + public String getTitle() { + return title; + } - public void setTitle(String title) { - this.title = title; - } + public void setTitle(String title) { + this.title = title; + } - public String getAuthor() { - return author; - } + public String getAuthor() { + return author; + } - public void setAuthor(String author) { - this.author = author; - } + public void setAuthor(String author) { + this.author = author; + } } \ No newline at end of file diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/JSPEvalAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/JSPEvalAction.java index 66f8c2199..cc370c8a6 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/JSPEvalAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/JSPEvalAction.java @@ -20,58 +20,52 @@ */ package org.apache.struts2.showcase.action; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.net.URL; - -import org.apache.struts2.ServletActionContext; - import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.interceptor.annotations.After; +import org.apache.struts2.ServletActionContext; + +import java.io.*; +import java.net.URL; /** * Will only work on containers that unzip war files - * */ public class JSPEvalAction extends ExampleAction { - private String jsp; - private final static String FILE = "/interactive/demo.jsp"; + private String jsp; + private final static String FILE = "/interactive/demo.jsp"; - public String execute() throws IOException { - if (jsp != null) { - //write it to file - URL url = ServletActionContext.getServletContext().getResource(FILE); - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(url - .getFile()))); - try { - //directive - writer.write("<%@ taglib prefix=\"s\" uri=\"/struts-tags\" %>"); - writer.write(jsp); - } finally { - if (writer != null) - writer.close(); - } - } - return Action.SUCCESS; - } + public String execute() throws IOException { + if (jsp != null) { + //write it to file + URL url = ServletActionContext.getServletContext().getResource(FILE); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(url + .getFile()))); + try { + //directive + writer.write("<%@ taglib prefix=\"s\" uri=\"/struts-tags\" %>"); + writer.write(jsp); + } finally { + if (writer != null) + writer.close(); + } + } + return Action.SUCCESS; + } - @After - public void cleanUp() throws IOException { - URL url = ServletActionContext.getServletContext().getResource(FILE); - FileOutputStream out = new FileOutputStream(new File(url.getFile())); - try { - out.getChannel().truncate(0); - } finally { - if (out != null) - out.close(); - } - } + @After + public void cleanUp() throws IOException { + URL url = ServletActionContext.getServletContext().getResource(FILE); + FileOutputStream out = new FileOutputStream(new File(url.getFile())); + try { + out.getChannel().truncate(0); + } finally { + if (out != null) + out.close(); + } + } - public void setJsp(String jsp) { - this.jsp = jsp; - } + public void setJsp(String jsp) { + this.jsp = jsp; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/SkillAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/SkillAction.java index 96d10fc3d..bbd1346f2 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/SkillAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/SkillAction.java @@ -20,70 +20,64 @@ */ package org.apache.struts2.showcase.action; +import com.opensymphony.xwork2.Preparable; import org.apache.log4j.Logger; import org.apache.struts2.showcase.dao.Dao; import org.apache.struts2.showcase.dao.SkillDao; import org.apache.struts2.showcase.model.Skill; - -import com.opensymphony.xwork2.Preparable; +import org.springframework.beans.factory.annotation.Autowired; /** * SkillAction. - * */ public class SkillAction extends AbstractCRUDAction implements Preparable { - private static final Logger log = Logger.getLogger(SkillAction.class); + private static final Logger log = Logger.getLogger(SkillAction.class); - private String skillName; - protected SkillDao skillDao; - private Skill currentSkill; + @Autowired + private SkillDao skillDao; - public String getSkillName() { - return skillName; - } + private String skillName; + private Skill currentSkill; - public void setSkillName(String skillName) { - this.skillName = skillName; - } + /** + * This method is called to allow the action to prepare itself. + * + * @throws Exception thrown if a system level exception occurs. + */ + public void prepare() throws Exception { + Skill preFetched = (Skill) fetch(getSkillName(), getCurrentSkill()); + if (preFetched != null) { + setCurrentSkill(preFetched); + } + } - protected Dao getDao() { - return skillDao; - } + public String save() throws Exception { + if (getCurrentSkill() != null) { + setSkillName((String) skillDao.merge(getCurrentSkill())); + } + return SUCCESS; + } - public void setSkillDao(SkillDao skillDao) { - if (log.isDebugEnabled()) { - log.debug("SkillAction - [setSkillDao]: skillDao injected."); - } - this.skillDao = skillDao; - } + public String getSkillName() { + return skillName; + } - public Skill getCurrentSkill() { - return currentSkill; - } + public void setSkillName(String skillName) { + this.skillName = skillName; + } - public void setCurrentSkill(Skill currentSkill) { - this.currentSkill = currentSkill; - } + protected Dao getDao() { + return skillDao; + } - /** - * This method is called to allow the action to prepare itself. - * - * @throws Exception thrown if a system level exception occurs. - */ - public void prepare() throws Exception { - Skill preFetched = (Skill) fetch(getSkillName(), getCurrentSkill()); - if (preFetched != null) { - setCurrentSkill(preFetched); - } - } + public Skill getCurrentSkill() { + return currentSkill; + } - public String save() throws Exception { - if (getCurrentSkill() != null) { - setSkillName((String) skillDao.merge(getCurrentSkill())); - } - return SUCCESS; - } + public void setCurrentSkill(Skill currentSkill) { + this.currentSkill = currentSkill; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain1.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain1.java index 26fb309da..2edf54829 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain1.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain1.java @@ -22,24 +22,21 @@ package org.apache.struts2.showcase.actionchaining; import com.opensymphony.xwork2.ActionSupport; -/** - * - */ public class ActionChain1 extends ActionSupport { - private static final long serialVersionUID = -6811701750042275153L; + private static final long serialVersionUID = -6811701750042275153L; - private String actionChain1Property1 = "Property Set In Action Chain 1"; + private String actionChain1Property1 = "Property Set In Action Chain 1"; - public String getActionChain1Property1() { - return actionChain1Property1; - } - public void setActionChain1Property1(String actionChain1Property1) { - this.actionChain1Property1 = actionChain1Property1; - } + public String input() throws Exception { + return SUCCESS; + } + public String getActionChain1Property1() { + return actionChain1Property1; + } - public String input() throws Exception { - return SUCCESS; - } + public void setActionChain1Property1(String actionChain1Property1) { + this.actionChain1Property1 = actionChain1Property1; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain2.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain2.java index 603d19fd9..53baf90f5 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain2.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain2.java @@ -22,37 +22,31 @@ package org.apache.struts2.showcase.actionchaining; import com.opensymphony.xwork2.ActionSupport; -/** - * - */ public class ActionChain2 extends ActionSupport { - private static final long serialVersionUID = 3951745956044674809L; + private static final long serialVersionUID = 3951745956044674809L; - private String actionChain1Property1; - private String actionChain2Property1 = "Property Set in Action Chain 2"; + private String actionChain1Property1; + private String actionChain2Property1 = "Property Set in Action Chain 2"; + + public String execute() throws Exception { + return SUCCESS; + } + + public String getActionChain1Property1() { + return actionChain1Property1; + } + + public void setActionChain1Property1(String actionChain1Property1) { + this.actionChain1Property1 = actionChain1Property1; + } - public String getActionChain1Property1() { - return actionChain1Property1; - } - public void setActionChain1Property1(String actionChain1Property1) { - this.actionChain1Property1 = actionChain1Property1; - } + public String getActionChain2Property1() { + return actionChain2Property1; + } - - - public String getActionChain2Property1() { - return actionChain2Property1; - } - public void setActionChain2Property1(String actionChain2Property1) { - this.actionChain2Property1 = actionChain2Property1; - } - - - - - public String execute() throws Exception { - return SUCCESS; - } + public void setActionChain2Property1(String actionChain2Property1) { + this.actionChain2Property1 = actionChain2Property1; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain3.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain3.java index f2ec60cc9..43cf103a2 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain3.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/actionchaining/ActionChain3.java @@ -22,47 +22,42 @@ package org.apache.struts2.showcase.actionchaining; import com.opensymphony.xwork2.ActionSupport; -/** - * - */ public class ActionChain3 extends ActionSupport { - private static final long serialVersionUID = -1456568865075250621L; + private static final long serialVersionUID = -1456568865075250621L; - private String actionChain1Property1; - private String actionChain2Property1; - private String actionChain3Property1 = "Property set in Action Chain 3"; + private String actionChain1Property1; + private String actionChain2Property1; + private String actionChain3Property1 = "Property set in Action Chain 3"; - public String getActionChain1Property1() { - return actionChain1Property1; - } - public void setActionChain1Property1(String actionChain1Property1) { - this.actionChain1Property1 = actionChain1Property1; - } + public String execute() throws Exception { + return SUCCESS; + } + + public String getActionChain1Property1() { + return actionChain1Property1; + } + + public void setActionChain1Property1(String actionChain1Property1) { + this.actionChain1Property1 = actionChain1Property1; + } + public String getActionChain2Property1() { + return actionChain2Property1; + } - public String getActionChain2Property1() { - return actionChain2Property1; - } - public void setActionChain2Property1(String actionChain2Property1) { - this.actionChain2Property1 = actionChain2Property1; - } + public void setActionChain2Property1(String actionChain2Property1) { + this.actionChain2Property1 = actionChain2Property1; + } + public String getActionChain3Property1() { + return actionChain3Property1; + } - public String getActionChain3Property1() { - return actionChain3Property1; - } - public void setActionChain3Property1(String actionChain3Property1) { - this.actionChain3Property1 = actionChain3Property1; - } - - - - - public String execute() throws Exception { - return SUCCESS; - } + public void setActionChain3Property1(String actionChain3Property1) { + this.actionChain3Property1 = actionChain3Property1; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/AjaxTestAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/AjaxTestAction.java index c078ca74c..6fd2bfecb 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/AjaxTestAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/AjaxTestAction.java @@ -25,30 +25,28 @@ import com.opensymphony.xwork2.Action; import java.io.Serializable; -/** - */ public class AjaxTestAction implements Action, Serializable { - private static int counter = 0; - private String data; + private static int counter = 0; + private String data; - public long getServerTime() { - return System.currentTimeMillis(); - } + public String execute() throws Exception { + return SUCCESS; + } - public int getCount() { - return ++counter; - } + public long getServerTime() { + return System.currentTimeMillis(); + } - public String getData() { - return data; - } + public int getCount() { + return ++counter; + } - public void setData(String data) { - this.data = data; - } + public String getData() { + return data; + } - public String execute() throws Exception { - return SUCCESS; - } + public void setData(String data) { + this.data = data; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/AutocompleterExampleAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/AutocompleterExampleAction.java index 0e2316e03..001cffa39 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/AutocompleterExampleAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/AutocompleterExampleAction.java @@ -20,40 +20,40 @@ */ package org.apache.struts2.showcase.ajax; +import com.opensymphony.xwork2.ActionSupport; + import java.util.ArrayList; import java.util.List; -import com.opensymphony.xwork2.ActionSupport; - public class AutocompleterExampleAction extends ActionSupport { - private String select; - private List options = new ArrayList(); + private String select; + private List options = new ArrayList(); - private static final long serialVersionUID = -8481638176160014396L; + private static final long serialVersionUID = -8481638176160014396L; - public String execute() throws Exception { - if ("fruits".equals(select)) { - options.add("apple"); - options.add("banana"); - options.add("grape"); - options.add("pear"); - } else if ("colors".equals(select)) { - options.add("red"); - options.add("green"); - options.add("blue"); - } - return SUCCESS; - } + public String execute() throws Exception { + if ("fruits".equals(select)) { + options.add("apple"); + options.add("banana"); + options.add("grape"); + options.add("pear"); + } else if ("colors".equals(select)) { + options.add("red"); + options.add("green"); + options.add("blue"); + } + return SUCCESS; + } - public String getSelect() { - return select; - } + public String getSelect() { + return select; + } - public void setSelect(String select) { - this.select = select; - } + public void setSelect(String select) { + this.select = select; + } - public List getOptions() { - return options; - } + public List getOptions() { + return options; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/Example4ShowPanelAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/Example4ShowPanelAction.java index 6ff756de9..10a2d10db 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/Example4ShowPanelAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/Example4ShowPanelAction.java @@ -20,56 +20,56 @@ */ package org.apache.struts2.showcase.ajax; +import com.opensymphony.xwork2.ActionSupport; + import java.text.SimpleDateFormat; import java.util.Date; -import com.opensymphony.xwork2.ActionSupport; - /** * @version $Date$ $Id$ */ public class Example4ShowPanelAction extends ActionSupport { - private String name; - private String gender; + private String name; + private String gender; - private static final long serialVersionUID = 7751976335066456596L; + private static final long serialVersionUID = 7751976335066456596L; - public String panel1() throws Exception { - return SUCCESS; - } + public String panel1() throws Exception { + return SUCCESS; + } - public String panel2() throws Exception { - return SUCCESS; - } + public String panel2() throws Exception { + return SUCCESS; + } - public String panel3() throws Exception { - return SUCCESS; - } + public String panel3() throws Exception { + return SUCCESS; + } - public String getGender() { - return gender; - } + public String getGender() { + return gender; + } - public void setGender(String gender) { - this.gender = gender; - } + public void setGender(String gender) { + this.gender = gender; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getTodayDate() { - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy"); - return sdf.format(new Date()); - } + public String getTodayDate() { + SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy"); + return sdf.format(new Date()); + } - public String getTodayTime() { - SimpleDateFormat sdf = new SimpleDateFormat("kk:mm:ss"); - return sdf.format(new Date()); - } + public String getTodayTime() { + SimpleDateFormat sdf = new SimpleDateFormat("kk:mm:ss"); + return sdf.format(new Date()); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/Example5Action.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/Example5Action.java index 4fcc516eb..4f7d3ed65 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/Example5Action.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/Example5Action.java @@ -24,20 +24,28 @@ import com.opensymphony.xwork2.ActionSupport; public class Example5Action extends ActionSupport { - private static final long serialVersionUID = 2111967621952300611L; + private static final long serialVersionUID = 2111967621952300611L; - private String name; - private Integer age; + private String name; + private Integer age; + public String execute() throws Exception { + return SUCCESS; + } - public String getName() { return name; } - public void setName(String name) { this.name = name; } + public String getName() { + return name; + } - public Integer getAge() { return age; } - public void setAge(Integer age) { this.age = age; } + public void setName(String name) { + this.name = name; + } - @Override - public String execute() throws Exception { - return SUCCESS; - } + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/Category.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/Category.java index b3a9859b0..63c34fc4c 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/Category.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/Category.java @@ -28,77 +28,77 @@ import java.util.Map; /** */ public class Category { - private static Map catMap = new HashMap(); + private static Map catMap = new HashMap(); - static { - new Category(1, "Root", - new Category(2, "Java", - new Category(3, "Web Frameworks", - new Category(4, "Struts"), - new Category(7, "Stripes"), - new Category(8, "Rife")), - new Category(9, "Persistence", - new Category(10, "iBatis"), - new Category(11, "Hibernate"), - new Category(12, "JDO"), - new Category(13, "JDBC"))), - new Category(14, "JavaScript", - new Category(15, "Dojo"), - new Category(16, "Prototype"), - new Category(17, "Scriptaculous"), - new Category(18, "OpenRico"), - new Category(19, "DWR"))); - } + static { + new Category(1, "Root", + new Category(2, "Java", + new Category(3, "Web Frameworks", + new Category(4, "Struts"), + new Category(7, "Stripes"), + new Category(8, "Rife")), + new Category(9, "Persistence", + new Category(10, "iBatis"), + new Category(11, "Hibernate"), + new Category(12, "JDO"), + new Category(13, "JDBC"))), + new Category(14, "JavaScript", + new Category(15, "Dojo"), + new Category(16, "Prototype"), + new Category(17, "Scriptaculous"), + new Category(18, "OpenRico"), + new Category(19, "DWR"))); + } - public static Category getById(long id) { - return catMap.get(id); - } + public static Category getById(long id) { + return catMap.get(id); + } - private long id; - private String name; - private List children; - private boolean toggle; + private long id; + private String name; + private List children; + private boolean toggle; - public Category(long id, String name, Category... children) { - this.id = id; - this.name = name; - this.children = new ArrayList(); - for (Category child : children) { - this.children.add(child); - } + public Category(long id, String name, Category... children) { + this.id = id; + this.name = name; + this.children = new ArrayList(); + for (Category child : children) { + this.children.add(child); + } - catMap.put(id, this); - } + catMap.put(id, this); + } - public long getId() { - return id; - } + public long getId() { + return id; + } - public void setId(long id) { - this.id = id; - } + public void setId(long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public List getChildren() { - return children; - } + public List getChildren() { + return children; + } - public void setChildren(List children) { - this.children = children; - } + public void setChildren(List children) { + this.children = children; + } - public void toggle() { - toggle = !toggle; - } + public void toggle() { + toggle = !toggle; + } - public boolean isToggle() { - return toggle; - } + public boolean isToggle() { + return toggle; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/GetCategory.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/GetCategory.java index 69f6bd064..73362667d 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/GetCategory.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/GetCategory.java @@ -25,25 +25,25 @@ import com.opensymphony.xwork2.ActionSupport; /** */ public class GetCategory extends ActionSupport { - private long catId; - private Category category; + private long catId; + private Category category; - public String execute() throws Exception { - if (catId < 1) { - // force the root - catId = 1; - } + public String execute() throws Exception { + if (catId < 1) { + // force the root + catId = 1; + } - category = Category.getById(catId); + category = Category.getById(catId); - return SUCCESS; - } + return SUCCESS; + } - public void setCatId(long catId) { - this.catId = catId; - } + public void setCatId(long catId) { + this.catId = catId; + } - public Category getCategory() { - return category; - } + public Category getCategory() { + return category; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/Toggle.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/Toggle.java index 165b22266..036719157 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/Toggle.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/ajax/tree/Toggle.java @@ -24,11 +24,11 @@ package org.apache.struts2.showcase.ajax.tree; /** */ public class Toggle extends GetCategory { - public String execute() throws Exception { - super.execute(); + public String execute() throws Exception { + super.execute(); - getCategory().toggle(); + getCategory().toggle(); - return SUCCESS; - } + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/application/MemoryStorage.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/application/MemoryStorage.java index f1f2d7093..f3f5c548e 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/application/MemoryStorage.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/application/MemoryStorage.java @@ -20,123 +20,126 @@ */ package org.apache.struts2.showcase.application; +import org.apache.struts2.showcase.exception.CreateException; +import org.apache.struts2.showcase.exception.DuplicateKeyException; +import org.apache.struts2.showcase.exception.StorageException; +import org.apache.struts2.showcase.exception.UpdateException; +import org.apache.struts2.showcase.model.IdEntity; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Repository; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.apache.struts2.showcase.exception.CreateException; -import org.apache.struts2.showcase.exception.DuplicateKeyException; -import org.apache.struts2.showcase.exception.StorageException; -import org.apache.struts2.showcase.exception.UpdateException; -import org.apache.struts2.showcase.model.IdEntity; - /** * MemoryStorage. * Very simple in-memory persistence emulation. - * */ +@Repository +@Scope("singleton") public class MemoryStorage implements Storage { - private static final long serialVersionUID = 8611213748834904125L; + private static final long serialVersionUID = 8611213748834904125L; - private Map memory = new HashMap(); + private Map memory = new HashMap(); - private Map getEntityMap ( Class entityClass ) { - if (entityClass != null) { - Map tryMap = (Map) memory.get(entityClass); - if (tryMap == null) { - synchronized(memory) { - tryMap = new HashMap(); - memory.put(entityClass, tryMap); - } - } - return tryMap; - } else { - return null; - } - } + private Map getEntityMap(Class entityClass) { + if (entityClass != null) { + Map tryMap = (Map) memory.get(entityClass); + if (tryMap == null) { + synchronized (memory) { + tryMap = new HashMap(); + memory.put(entityClass, tryMap); + } + } + return tryMap; + } else { + return null; + } + } - private IdEntity intStore( Class entityClass, IdEntity object ) { - getEntityMap(entityClass).put(object.getId(), object); - return object; - } + private IdEntity intStore(Class entityClass, IdEntity object) { + getEntityMap(entityClass).put(object.getId(), object); + return object; + } - public IdEntity get( Class entityClass, Serializable id ) { - if (entityClass != null && id != null) { - return (IdEntity) getEntityMap(entityClass).get(id); - } else { - return null; - } - } + public IdEntity get(Class entityClass, Serializable id) { + if (entityClass != null && id != null) { + return (IdEntity) getEntityMap(entityClass).get(id); + } else { + return null; + } + } - public Serializable create ( IdEntity object ) throws CreateException { - if (object == null) { - throw new CreateException("Either given class or object was null"); - } - if (object.getId() == null) { - throw new CreateException("Cannot store object with null id"); - } - if (get(object.getClass(), object.getId()) != null) { - throw new DuplicateKeyException("Object with this id already exists."); - } - return intStore(object.getClass(), object).getId(); - } + public Serializable create(IdEntity object) throws CreateException { + if (object == null) { + throw new CreateException("Either given class or object was null"); + } + if (object.getId() == null) { + throw new CreateException("Cannot store object with null id"); + } + if (get(object.getClass(), object.getId()) != null) { + throw new DuplicateKeyException("Object with this id already exists."); + } + return intStore(object.getClass(), object).getId(); + } - public IdEntity update ( IdEntity object ) throws UpdateException { - if (object == null) { - throw new UpdateException("Cannot update null object."); - } - if ( get(object.getClass(), object.getId())==null ) { - throw new UpdateException("Object to update not found."); - } - return intStore(object.getClass(), object); - } + public IdEntity update(IdEntity object) throws UpdateException { + if (object == null) { + throw new UpdateException("Cannot update null object."); + } + if (get(object.getClass(), object.getId()) == null) { + throw new UpdateException("Object to update not found."); + } + return intStore(object.getClass(), object); + } - public Serializable merge ( IdEntity object ) throws StorageException { - if (object == null) { - throw new StorageException("Cannot merge null object"); - } - if (object.getId() == null || get(object.getClass(), object.getId())==null) { - return create(object); - } else { - return update(object).getId(); - } - } + public Serializable merge(IdEntity object) throws StorageException { + if (object == null) { + throw new StorageException("Cannot merge null object"); + } + if (object.getId() == null || get(object.getClass(), object.getId()) == null) { + return create(object); + } else { + return update(object).getId(); + } + } - public int delete( Class entityClass, Serializable id ) throws CreateException { - try { - if (get(entityClass, id) != null) { - getEntityMap(entityClass).remove(id); - return 1; - } else { - return 0; - } - } catch (Exception e) { - throw new CreateException(e); - } - } + public int delete(Class entityClass, Serializable id) throws CreateException { + try { + if (get(entityClass, id) != null) { + getEntityMap(entityClass).remove(id); + return 1; + } else { + return 0; + } + } catch (Exception e) { + throw new CreateException(e); + } + } - public int delete( IdEntity object ) throws CreateException { - if (object == null) { - throw new CreateException("Cannot delete null object"); - } - return delete(object.getClass(), object.getId()); - } + public int delete(IdEntity object) throws CreateException { + if (object == null) { + throw new CreateException("Cannot delete null object"); + } + return delete(object.getClass(), object.getId()); + } - public Collection findAll( Class entityClass ) { - if (entityClass != null) { - return getEntityMap(entityClass).values(); - } else { - return new ArrayList(); - } - } + public Collection findAll(Class entityClass) { + if (entityClass != null) { + return getEntityMap(entityClass).values(); + } else { + return new ArrayList(); + } + } - public void reset() { - this.memory = new HashMap(); - } + public void reset() { + this.memory = new HashMap(); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/application/Storage.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/application/Storage.java index 74d81e3b4..9dfb0dd1a 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/application/Storage.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/application/Storage.java @@ -20,31 +20,30 @@ */ package org.apache.struts2.showcase.application; -import java.io.Serializable; -import java.util.Collection; - import org.apache.struts2.showcase.exception.CreateException; import org.apache.struts2.showcase.exception.StorageException; import org.apache.struts2.showcase.exception.UpdateException; import org.apache.struts2.showcase.model.IdEntity; +import java.io.Serializable; +import java.util.Collection; + /** * Storage. Interface. - * */ public interface Storage extends Serializable { - IdEntity get( Class entityClass, Serializable id ); + IdEntity get(Class entityClass, Serializable id); - Serializable create ( IdEntity object ) throws CreateException; + Serializable create(IdEntity object) throws CreateException; - IdEntity update ( IdEntity object ) throws UpdateException; + IdEntity update(IdEntity object) throws UpdateException; - Serializable merge ( IdEntity object ) throws StorageException; + Serializable merge(IdEntity object) throws StorageException; - int delete( Class entityClass, Serializable id ) throws CreateException; + int delete(Class entityClass, Serializable id) throws CreateException; - int delete( IdEntity object ) throws CreateException; + int delete(IdEntity object) throws CreateException; - Collection findAll( Class entityClass ); + Collection findAll(Class entityClass); } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/application/TestDataProvider.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/application/TestDataProvider.java index 0cd0056df..c45e71803 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/application/TestDataProvider.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/application/TestDataProvider.java @@ -20,10 +20,6 @@ */ package org.apache.struts2.showcase.application; -import java.io.Serializable; -import java.util.Arrays; -import java.util.Date; - import org.apache.log4j.Logger; import org.apache.struts2.showcase.dao.EmployeeDao; import org.apache.struts2.showcase.dao.SkillDao; @@ -31,88 +27,87 @@ import org.apache.struts2.showcase.exception.StorageException; import org.apache.struts2.showcase.model.Employee; import org.apache.struts2.showcase.model.Skill; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Date; /** * TestDataProvider. - * */ - +@Service public class TestDataProvider implements Serializable, InitializingBean { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + private static final Logger log = Logger.getLogger(TestDataProvider.class); - private static final Logger log = Logger.getLogger(TestDataProvider.class); + public static final String[] POSITIONS = { + "Developer", + "System Architect", + "Sales Manager", + "CEO" + }; - public static final String[] POSITIONS = { - "Developer", - "System Architect", - "Sales Manager", - "CEO" - }; + public static final String[] LEVELS = { + "Junior", + "Senior", + "Master" + }; - public static final String[] LEVELS = { - "Junior", - "Senior", - "Master" - }; + private static final Skill[] TEST_SKILLS = { + new Skill("WW-SEN", "Struts Senior Developer"), + new Skill("WW-JUN", "Struts Junior Developer"), + new Skill("SPRING-DEV", "Spring Developer") + }; - private static final Skill[] TEST_SKILLS = { - new Skill("WW-SEN", "Struts Senior Developer"), - new Skill("WW-JUN", "Struts Junior Developer"), - new Skill("SPRING-DEV", "Spring Developer") - }; + public static final Employee[] TEST_EMPLOYEES = { + new Employee(new Long(1), "Alan", "Smithee", new Date(), new Float(2000f), true, POSITIONS[0], + TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"), + new Employee(new Long(2), "Robert", "Robson", new Date(), new Float(10000f), false, POSITIONS[1], + TEST_SKILLS[1], Arrays.asList(TEST_SKILLS).subList(1, TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy") + }; - public static final Employee[] TEST_EMPLOYEES = { - new Employee(new Long(1), "Alan", "Smithee", new Date(), new Float(2000f), true, POSITIONS[0], - TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"), - new Employee(new Long(2), "Robert", "Robson", new Date(), new Float(10000f), false, POSITIONS[1], - TEST_SKILLS[1], Arrays.asList(TEST_SKILLS).subList(1,TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy") - }; + @Autowired + private SkillDao skillDao; - private SkillDao skillDao; - private EmployeeDao employeeDao; + @Autowired + private EmployeeDao employeeDao; - public void setSkillDao(SkillDao skillDao) { - this.skillDao = skillDao; - } + protected void addTestSkills() { + try { + for (int i = 0, j = TEST_SKILLS.length; i < j; i++) { + skillDao.merge(TEST_SKILLS[i]); + } + if (log.isInfoEnabled()) { + log.info("TestDataProvider - [addTestSkills]: Added test skill data."); + } + } catch (StorageException e) { + log.error("TestDataProvider - [addTestSkills]: Exception catched: " + e.getMessage()); + } + } - public void setEmployeeDao(EmployeeDao employeeDao) { - this.employeeDao = employeeDao; - } + protected void addTestEmployees() { + try { + for (int i = 0, j = TEST_EMPLOYEES.length; i < j; i++) { + employeeDao.merge(TEST_EMPLOYEES[i]); + } + if (log.isInfoEnabled()) { + log.info("TestDataProvider - [addTestEmployees]: Added test employee data."); + } + } catch (StorageException e) { + log.error("TestDataProvider - [addTestEmployees]: Exception catched: " + e.getMessage()); + } + } - protected void addTestSkills() { - try { - for (int i = 0, j = TEST_SKILLS.length; i < j; i++) { - skillDao.merge(TEST_SKILLS[i]); - } - if (log.isInfoEnabled()) { - log.info("TestDataProvider - [addTestSkills]: Added test skill data."); - } - } catch (StorageException e) { - log.error("TestDataProvider - [addTestSkills]: Exception catched: " + e.getMessage()); - } - } + protected void addTestData() { + addTestSkills(); + addTestEmployees(); + } - protected void addTestEmployees() { - try { - for (int i = 0, j = TEST_EMPLOYEES.length; i < j; i++) { - employeeDao.merge(TEST_EMPLOYEES[i]); - } - if (log.isInfoEnabled()) { - log.info("TestDataProvider - [addTestEmployees]: Added test employee data."); - } - } catch (StorageException e) { - log.error("TestDataProvider - [addTestEmployees]: Exception catched: " + e.getMessage()); - } - } - - protected void addTestData() { - addTestSkills(); - addTestEmployees(); - } - - public void afterPropertiesSet() throws Exception { - addTestData(); - } + public void afterPropertiesSet() throws Exception { + addTestData(); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatAuthenticationInterceptor.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatAuthenticationInterceptor.java index 14a7cbeaf..cd4f9987b 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatAuthenticationInterceptor.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatAuthenticationInterceptor.java @@ -21,40 +21,37 @@ package org.apache.struts2.showcase.chat; -import org.apache.struts2.dispatcher.SessionMap; - import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; +import org.apache.struts2.dispatcher.SessionMap; public class ChatAuthenticationInterceptor implements Interceptor { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + private static final Logger LOG = LoggerFactory.getLogger(ChatAuthenticationInterceptor.class); + public static final String USER_SESSION_KEY = "chatUserSessionKey"; - private static final Logger LOG = LoggerFactory.getLogger(ChatAuthenticationInterceptor.class); + public void destroy() { + } - public static final String USER_SESSION_KEY = "chatUserSessionKey"; + public void init() { + } - public void destroy() { - } + public String intercept(ActionInvocation invocation) throws Exception { - public void init() { - } + LOG.debug("Authenticating chat user"); - public String intercept(ActionInvocation invocation) throws Exception { + SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION); + User user = (User) session.get(USER_SESSION_KEY); - LOG.debug("Authenticating chat user"); - - SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION); - User user = (User) session.get(USER_SESSION_KEY); - - if (user == null) { - return Action.LOGIN; - } - return invocation.invoke(); - } + if (user == null) { + return Action.LOGIN; + } + return invocation.invoke(); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatException.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatException.java index 50b5e9b81..a22d9b450 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatException.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatException.java @@ -22,15 +22,15 @@ package org.apache.struts2.showcase.chat; public class ChatException extends RuntimeException { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public enum ErrorType { - ROOM_ALREADY_EXISTS, - USER_ALREADY_EXISTS, - NO_SUCH_ROOM_EXISTS - } + public enum ErrorType { + ROOM_ALREADY_EXISTS, + USER_ALREADY_EXISTS, + NO_SUCH_ROOM_EXISTS + } - public ChatException(String description, ErrorType type) { - super(description); - } + public ChatException(String description, ErrorType type) { + super(description); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatInterceptor.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatInterceptor.java index 83d0c225c..cab13bdb3 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatInterceptor.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatInterceptor.java @@ -20,8 +20,6 @@ */ package org.apache.struts2.showcase.chat; -import javax.servlet.http.HttpSession; - import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; @@ -29,32 +27,34 @@ import com.opensymphony.xwork2.interceptor.Interceptor; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; +import javax.servlet.http.HttpSession; + /** * Authenticate showcase chat example, make sure everyone have a username. */ public class ChatInterceptor implements Interceptor { - private static final Logger LOG = LoggerFactory.getLogger(ChatInterceptor.class); + private static final Logger LOG = LoggerFactory.getLogger(ChatInterceptor.class); - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey"; + public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey"; - public void destroy() { - } + public void destroy() { + } - public void init() { - } + public void init() { + } - public String intercept(ActionInvocation invocation) throws Exception { - HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION); - User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY); - if (chatUser == null) { - LOG.debug("Chat user not logged in"); - return Action.LOGIN; - } - return invocation.invoke(); - } + public String intercept(ActionInvocation invocation) throws Exception { + HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION); + User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY); + if (chatUser == null) { + LOG.debug("Chat user not logged in"); + return Action.LOGIN; + } + return invocation.invoke(); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLoginAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLoginAction.java index 570d54523..a5fc15e73 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLoginAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLoginAction.java @@ -20,49 +20,48 @@ */ package org.apache.struts2.showcase.chat; -import java.util.Map; - +import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.SessionAware; -import com.opensymphony.xwork2.ActionSupport; +import java.util.Map; public class ChatLoginAction extends ActionSupport implements SessionAware { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private ChatService chatService; - private Map session; + private ChatService chatService; + private Map session; - private String name; + private String name; - public ChatLoginAction(ChatService chatService) { - this.chatService = chatService; - } + public ChatLoginAction(ChatService chatService) { + this.chatService = chatService; + } - public String getName() { - return this.name; - } - public void setName(String name) { - this.name = name; - } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } - public String execute() throws Exception { - try { - chatService.login(new User(name)); - session.put(ChatAuthenticationInterceptor.USER_SESSION_KEY, new User(name)); - } - catch(ChatException e) { - e.printStackTrace(); - addActionError(e.getMessage()); - return INPUT; - } - return SUCCESS; - } + public String execute() throws Exception { + try { + chatService.login(new User(name)); + session.put(ChatAuthenticationInterceptor.USER_SESSION_KEY, new User(name)); + } catch (ChatException e) { + e.printStackTrace(); + addActionError(e.getMessage()); + return INPUT; + } + return SUCCESS; + } - // === SessionAware === - public void setSession(Map session) { - this.session = session; - } + // === SessionAware === + public void setSession(Map session) { + this.session = session; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLogoutAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLogoutAction.java index c4a4bcd5e..d0c3e6ba6 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLogoutAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLogoutAction.java @@ -20,39 +20,38 @@ */ package org.apache.struts2.showcase.chat; -import java.util.Map; - +import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.SessionAware; -import com.opensymphony.xwork2.ActionSupport; +import java.util.Map; public class ChatLogoutAction extends ActionSupport implements SessionAware { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private ChatService chatService; + private ChatService chatService; - private Map session; + private Map session; - public ChatLogoutAction(ChatService chatService) { - this.chatService = chatService; - } + public ChatLogoutAction(ChatService chatService) { + this.chatService = chatService; + } - public String execute() throws Exception { + public String execute() throws Exception { - User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY); - if (user != null) { - chatService.logout(user.getName()); - session.remove(ChatAuthenticationInterceptor.USER_SESSION_KEY); - } + User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY); + if (user != null) { + chatService.logout(user.getName()); + session.remove(ChatAuthenticationInterceptor.USER_SESSION_KEY); + } - return SUCCESS; - } + return SUCCESS; + } - // === SessionAware === - public void setSession(Map session) { - this.session = session; - } + // === SessionAware === + public void setSession(Map session) { + this.session = session; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatMessage.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatMessage.java index 3426eec0e..fcd3aaf69 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatMessage.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatMessage.java @@ -24,26 +24,28 @@ import java.util.Date; public class ChatMessage { - private Date creationDate; - private String message; - private User creator; + private Date creationDate; + private String message; + private User creator; - public ChatMessage(String message, User creator) { - assert(message != null); - assert(creator != null); + public ChatMessage(String message, User creator) { + assert (message != null); + assert (creator != null); - this.creationDate = new Date(System.currentTimeMillis()); - this.message = message; - this.creator = creator; - } + this.creationDate = new Date(System.currentTimeMillis()); + this.message = message; + this.creator = creator; + } - public Date getCreationDate() { - return creationDate; - } - public User getCreator() { - return creator; - } - public String getMessage() { - return message; - } + public Date getCreationDate() { + return creationDate; + } + + public User getCreator() { + return creator; + } + + public String getMessage() { + return message; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatService.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatService.java index 907f77e00..7110ebe7c 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatService.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatService.java @@ -23,15 +23,23 @@ package org.apache.struts2.showcase.chat; import java.util.List; public interface ChatService { - List getAvailableUsers(); - void login(User user); - void logout(String name); + List getAvailableUsers(); - List getAvailableRooms(); - void addRoom(Room room); - void enterRoom(User user, String roomName); - void exitRoom(String userName, String roomName); - List getMessagesInRoom(String roomName); - void sendMessageToRoom(String roomName, User user, String message); - List getUsersAvailableInRoom(String roomName); + void login(User user); + + void logout(String name); + + List getAvailableRooms(); + + void addRoom(Room room); + + void enterRoom(User user, String roomName); + + void exitRoom(String userName, String roomName); + + List getMessagesInRoom(String roomName); + + void sendMessageToRoom(String roomName, User user, String message); + + List getUsersAvailableInRoom(String roomName); } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatServiceImpl.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatServiceImpl.java index 0cd783d7d..e6032638e 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatServiceImpl.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatServiceImpl.java @@ -27,89 +27,89 @@ import java.util.Map; public class ChatServiceImpl implements ChatService { - private Map availableUsers = new LinkedHashMap(); - private Map availableRooms = new LinkedHashMap(); + private Map availableUsers = new LinkedHashMap(); + private Map availableRooms = new LinkedHashMap(); - public List getAvailableUsers() { - return new ArrayList(availableUsers.values()); - } + public List getAvailableUsers() { + return new ArrayList(availableUsers.values()); + } - public List getAvailableRooms() { - return new ArrayList(availableRooms.values()); - } + public List getAvailableRooms() { + return new ArrayList(availableRooms.values()); + } - public void addRoom(Room room) { - if (availableRooms.containsKey(room.getName())) { - throw new ChatException("room ["+room.getName()+"] is already available", ChatException.ErrorType.valueOf("ROOM_ALREADY_EXISTS")); - } - availableRooms.put(room.getName(), room); - } + public void addRoom(Room room) { + if (availableRooms.containsKey(room.getName())) { + throw new ChatException("room [" + room.getName() + "] is already available", ChatException.ErrorType.valueOf("ROOM_ALREADY_EXISTS")); + } + availableRooms.put(room.getName(), room); + } - public void login(User user) { - assert(user != null); - if (availableUsers.containsKey(user.getName())) { - throw new ChatException("User ["+user.getName()+"] already exists", ChatException.ErrorType.valueOf("USER_ALREADY_EXISTS")); - } - availableUsers.put(user.getName(), user); - } + public void login(User user) { + assert (user != null); + if (availableUsers.containsKey(user.getName())) { + throw new ChatException("User [" + user.getName() + "] already exists", ChatException.ErrorType.valueOf("USER_ALREADY_EXISTS")); + } + availableUsers.put(user.getName(), user); + } - public void logout(String name) { - assert(name != null); - assert(name.trim().length() > 0); - availableUsers.remove(name); - for (Room room : availableRooms.values()) { - if (room.hasMember(name)) { - room.memberExit(name); - } - } - } + public void logout(String name) { + assert (name != null); + assert (name.trim().length() > 0); + availableUsers.remove(name); + for (Room room : availableRooms.values()) { + if (room.hasMember(name)) { + room.memberExit(name); + } + } + } - public void exitRoom(String userName, String roomName) { - assert(roomName != null); - assert(roomName.trim().length()> 0); + public void exitRoom(String userName, String roomName) { + assert (roomName != null); + assert (roomName.trim().length() > 0); - if (availableRooms.containsKey(roomName)) { - Room room = availableRooms.get(roomName); - room.memberExit(userName); - } - } + if (availableRooms.containsKey(roomName)) { + Room room = availableRooms.get(roomName); + room.memberExit(userName); + } + } - public void enterRoom(User user, String roomName) { - assert(roomName != null); - assert(roomName.trim().length() > 0); - if (! availableRooms.containsKey(roomName)) { - throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS); - } - Room room = availableRooms.get(roomName); - room.memberEnter(user); - } + public void enterRoom(User user, String roomName) { + assert (roomName != null); + assert (roomName.trim().length() > 0); + if (!availableRooms.containsKey(roomName)) { + throw new ChatException("No such room exists [" + roomName + "]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS); + } + Room room = availableRooms.get(roomName); + room.memberEnter(user); + } - public List getMessagesInRoom(String roomName) { - assert(roomName != null); - assert(roomName.trim().length() > 0); - if (! availableRooms.containsKey(roomName)) { - throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS); - } - Room room = availableRooms.get(roomName); - return room.getChatMessages(); - } + public List getMessagesInRoom(String roomName) { + assert (roomName != null); + assert (roomName.trim().length() > 0); + if (!availableRooms.containsKey(roomName)) { + throw new ChatException("No such room exists [" + roomName + "]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS); + } + Room room = availableRooms.get(roomName); + return room.getChatMessages(); + } - public void sendMessageToRoom(String roomName, User user, String message) { - assert(roomName != null); - if (! availableRooms.containsKey(roomName)) { - throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS); - } - Room room = availableRooms.get(roomName); - room.addMessage(new ChatMessage(message, user)); - } + public void sendMessageToRoom(String roomName, User user, String message) { + assert (roomName != null); + if (!availableRooms.containsKey(roomName)) { + throw new ChatException("No such room exists [" + roomName + "]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS); + } + Room room = availableRooms.get(roomName); + room.addMessage(new ChatMessage(message, user)); + } - public List getUsersAvailableInRoom(String roomName) { - assert(roomName != null); - if (! availableRooms.containsKey(roomName)) { - throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS); - } - Room room = availableRooms.get(roomName); - return room.getMembers(); - } + public List getUsersAvailableInRoom(String roomName) { + assert (roomName != null); + if (!availableRooms.containsKey(roomName)) { + throw new ChatException("No such room exists [" + roomName + "]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS); + } + Room room = availableRooms.get(roomName); + return room.getMembers(); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatSessionListener.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatSessionListener.java index db3961c8d..eb09746cd 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatSessionListener.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatSessionListener.java @@ -20,35 +20,34 @@ */ package org.apache.struts2.showcase.chat; +import com.opensymphony.xwork2.util.logging.Logger; +import com.opensymphony.xwork2.util.logging.LoggerFactory; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; - -import com.opensymphony.xwork2.util.logging.Logger; -import com.opensymphony.xwork2.util.logging.LoggerFactory; - public class ChatSessionListener implements HttpSessionListener { - private static final Logger LOG = LoggerFactory.getLogger(ChatSessionListener.class); + private static final Logger LOG = LoggerFactory.getLogger(ChatSessionListener.class); - public void sessionCreated(HttpSessionEvent event) { - } + public void sessionCreated(HttpSessionEvent event) { + } - public void sessionDestroyed(HttpSessionEvent event) { - HttpSession session = event.getSession(); - WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext()); - if (context != null) { - User user = (User) session.getAttribute(ChatInterceptor.CHAT_USER_SESSION_KEY); - if (user != null) { - ChatService service = (ChatService) context.getBean("chatService"); - service.logout(user.getName()); + public void sessionDestroyed(HttpSessionEvent event) { + HttpSession session = event.getSession(); + WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext()); + if (context != null) { + User user = (User) session.getAttribute(ChatInterceptor.CHAT_USER_SESSION_KEY); + if (user != null) { + ChatService service = (ChatService) context.getBean("chatService"); + service.logout(user.getName()); - LOG.info("session expired, logged user ["+user.getName()+"] out"); - } - } - } + LOG.info("session expired, logged user [" + user.getName() + "] out"); + } + } + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/Constants.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/Constants.java index 1e084338a..f0c55a3d9 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/Constants.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/Constants.java @@ -21,5 +21,5 @@ package org.apache.struts2.showcase.chat; public class Constants { - public static String UPDATE_FREQ = "5000"; + public static String UPDATE_FREQ = "5000"; } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/CrudRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/CrudRoomAction.java index dcbf24096..f447b073e 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/CrudRoomAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/CrudRoomAction.java @@ -24,41 +24,40 @@ import com.opensymphony.xwork2.ActionSupport; public class CrudRoomAction extends ActionSupport { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private ChatService chatService; + private ChatService chatService; - private String name; - private String description; + private String name; + private String description; - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public CrudRoomAction(ChatService chatService) { - this.chatService = chatService; - } + public CrudRoomAction(ChatService chatService) { + this.chatService = chatService; + } - public String create() throws Exception { - try { - chatService.addRoom(new Room(name, description)); - } - catch(ChatException e) { - addActionError(e.getMessage()); - } - return SUCCESS; - } + public String create() throws Exception { + try { + chatService.addRoom(new Room(name, description)); + } catch (ChatException e) { + addActionError(e.getMessage()); + } + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/DateConverter.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/DateConverter.java index 3ebb41831..8935497d0 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/DateConverter.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/DateConverter.java @@ -20,41 +20,39 @@ */ package org.apache.struts2.showcase.chat; +import com.opensymphony.xwork2.util.logging.Logger; +import com.opensymphony.xwork2.util.logging.LoggerFactory; +import org.apache.struts2.util.StrutsTypeConverter; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; -import org.apache.struts2.util.StrutsTypeConverter; - -import com.opensymphony.xwork2.util.logging.Logger; -import com.opensymphony.xwork2.util.logging.LoggerFactory; - public class DateConverter extends StrutsTypeConverter { - private static final Logger LOG = LoggerFactory.getLogger(DateConverter.class); + private static final Logger LOG = LoggerFactory.getLogger(DateConverter.class); - public Object convertFromString(Map context, String[] values, Class toClass) { + public Object convertFromString(Map context, String[] values, Class toClass) { - if (values.length > 0 && values[0] != null && values[0].trim().length() > 0) { - SimpleDateFormat sdf = new SimpleDateFormat(); - try { - return sdf.parse(values[0]); - } - catch(ParseException e) { - LOG.error("error converting value ["+values[0]+"] to Date ", e); - } - } - return null; - } + if (values.length > 0 && values[0] != null && values[0].trim().length() > 0) { + SimpleDateFormat sdf = new SimpleDateFormat(); + try { + return sdf.parse(values[0]); + } catch (ParseException e) { + LOG.error("error converting value [" + values[0] + "] to Date ", e); + } + } + return null; + } - public String convertToString(Map context, Object o) { + public String convertToString(Map context, Object o) { - if (o instanceof Date) { - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); - return sdf.format((Date) o); - } - return ""; - } + if (o instanceof Date) { + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); + return sdf.format((Date) o); + } + return ""; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/EnterRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/EnterRoomAction.java index 52e872258..24a54531a 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/EnterRoomAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/EnterRoomAction.java @@ -20,43 +20,46 @@ */ package org.apache.struts2.showcase.chat; -import java.util.Map; - +import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.SessionAware; -import com.opensymphony.xwork2.ActionSupport; +import java.util.Map; public class EnterRoomAction extends ActionSupport implements SessionAware { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private ChatService chatService; - private Map session; - private String roomName; + private ChatService chatService; + private Map session; + private String roomName; - public String getRoomName() { return this.roomName; } - public void setRoomName(String roomName) { this.roomName = roomName; } + public String getRoomName() { + return this.roomName; + } - public EnterRoomAction(ChatService chatService) { - this.chatService = chatService; - } + public void setRoomName(String roomName) { + this.roomName = roomName; + } - public String execute() throws Exception { + public EnterRoomAction(ChatService chatService) { + this.chatService = chatService; + } - User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY); - try { - chatService.enterRoom(user, roomName); - } - catch(Exception e) { - addActionError(e.getMessage()); - } - return SUCCESS; - } + public String execute() throws Exception { + + User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY); + try { + chatService.enterRoom(user, roomName); + } catch (Exception e) { + addActionError(e.getMessage()); + } + return SUCCESS; + } - // === SessionAware === - public void setSession(Map session) { - this.session = session; - } + // === SessionAware === + public void setSession(Map session) { + this.session = session; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ExitRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ExitRoomAction.java index 5d0990f04..592f2d07f 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ExitRoomAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ExitRoomAction.java @@ -20,39 +20,43 @@ */ package org.apache.struts2.showcase.chat; -import java.util.Map; - +import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.SessionAware; -import com.opensymphony.xwork2.ActionSupport; +import java.util.Map; public class ExitRoomAction extends ActionSupport implements SessionAware { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private String roomName; + private String roomName; - private Map session; + private Map session; - public String getRoomName() { return roomName; } - public void setRoomName(String roomName) { this.roomName = roomName; } + public String getRoomName() { + return roomName; + } - private ChatService chatService; + public void setRoomName(String roomName) { + this.roomName = roomName; + } - public ExitRoomAction(ChatService chatService) { - this.chatService = chatService; - } + private ChatService chatService; - public String execute() throws Exception { - User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY); - chatService.exitRoom(user.getName(), roomName); + public ExitRoomAction(ChatService chatService) { + this.chatService = chatService; + } - return SUCCESS; - } + public String execute() throws Exception { + User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY); + chatService.exitRoom(user.getName(), roomName); - // === SessionAware === - public void setSession(Map session) { - this.session = session; - } + return SUCCESS; + } + + // === SessionAware === + public void setSession(Map session) { + this.session = session; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/MessagesAvailableInRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/MessagesAvailableInRoomAction.java index ffb6e54e3..a7330e733 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/MessagesAvailableInRoomAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/MessagesAvailableInRoomAction.java @@ -20,40 +20,42 @@ */ package org.apache.struts2.showcase.chat; +import com.opensymphony.xwork2.ActionSupport; + import java.util.ArrayList; import java.util.List; -import com.opensymphony.xwork2.ActionSupport; - public class MessagesAvailableInRoomAction extends ActionSupport { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private String roomName; - private ChatService chatService; - private List messagesAvailableInRoom = new ArrayList(); + private String roomName; + private ChatService chatService; + private List messagesAvailableInRoom = new ArrayList(); - public String getRoomName() { return this.roomName; } - public void setRoomName(String roomName) { - this.roomName = roomName; - } + public String getRoomName() { + return this.roomName; + } - public List getMessagesAvailableInRoom() { - return messagesAvailableInRoom; - } + public void setRoomName(String roomName) { + this.roomName = roomName; + } - public MessagesAvailableInRoomAction(ChatService chatService) { - this.chatService = chatService; - } + public List getMessagesAvailableInRoom() { + return messagesAvailableInRoom; + } - public String execute() throws Exception { - try { - messagesAvailableInRoom = chatService.getMessagesInRoom(roomName); - } - catch(ChatException e) { - addActionError(e.getMessage()); - } - return SUCCESS; - } + public MessagesAvailableInRoomAction(ChatService chatService) { + this.chatService = chatService; + } + + public String execute() throws Exception { + try { + messagesAvailableInRoom = chatService.getMessagesInRoom(roomName); + } catch (ChatException e) { + addActionError(e.getMessage()); + } + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/Room.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/Room.java index 1ac856ef7..5ba444e01 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/Room.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/Room.java @@ -20,82 +20,81 @@ */ package org.apache.struts2.showcase.chat; -import java.util.ArrayList; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class Room { - private static final int MAX_CHAT_MESSAGES = 10; + private static final int MAX_CHAT_MESSAGES = 10; - private String name; - private String description; - private Date creationDate; + private String name; + private String description; + private Date creationDate; - private List messages = new ArrayList(); + private List messages = new ArrayList(); - private Map members = new LinkedHashMap(); + private Map members = new LinkedHashMap(); - public Room(String name, String description) { - this.name = name; - this.description = description; - this.creationDate = new Date(System.currentTimeMillis()); - } + public Room(String name, String description) { + this.name = name; + this.description = description; + this.creationDate = new Date(System.currentTimeMillis()); + } - // properties - public Date getCreationDate() { - return creationDate; - } + // properties + public Date getCreationDate() { + return creationDate; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - // (behaviour) members - public List getMembers() { - return new ArrayList(members.values()); - } - public User findMember(String name) { - assert(name != null); - return members.get(name); - } - public boolean hasMember(String name) { - assert(name != null); - return members.containsKey(name); - } - public void memberEnter(User member) { - assert(member != null); - if (! hasMember(member.getName())) { - members.put(member.getName(), member); - } - } + // (behaviour) members + public List getMembers() { + return new ArrayList(members.values()); + } - public void memberExit(String memberName) { - assert(memberName != null); - assert(memberName.trim().length() > 0); - members.remove(memberName); - } + public User findMember(String name) { + assert (name != null); + return members.get(name); + } + + public boolean hasMember(String name) { + assert (name != null); + return members.containsKey(name); + } + + public void memberEnter(User member) { + assert (member != null); + if (!hasMember(member.getName())) { + members.put(member.getName(), member); + } + } + + public void memberExit(String memberName) { + assert (memberName != null); + assert (memberName.trim().length() > 0); + members.remove(memberName); + } - // (behaviour) chat messags - public void addMessage(ChatMessage chatMessage) { - if (messages.size() > MAX_CHAT_MESSAGES) { - // messages.remove(messages.size() - 1); - messages.remove(0); - } - messages.add(chatMessage); - } + // (behaviour) chat messags + public void addMessage(ChatMessage chatMessage) { + if (messages.size() > MAX_CHAT_MESSAGES) { + // messages.remove(messages.size() - 1); + messages.remove(0); + } + messages.add(chatMessage); + } - public List getChatMessages() { - return new ArrayList(messages); - } + public List getChatMessages() { + return new ArrayList(messages); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/RoomsAvailableAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/RoomsAvailableAction.java index 25084d4ee..8ed8b4e82 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/RoomsAvailableAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/RoomsAvailableAction.java @@ -20,29 +20,29 @@ */ package org.apache.struts2.showcase.chat; +import com.opensymphony.xwork2.ActionSupport; + import java.util.ArrayList; import java.util.List; -import com.opensymphony.xwork2.ActionSupport; - public class RoomsAvailableAction extends ActionSupport { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private List availableRooms = new ArrayList(); + private List availableRooms = new ArrayList(); - private ChatService chatService; + private ChatService chatService; - public RoomsAvailableAction(ChatService chatService) { - this.chatService = chatService; - } + public RoomsAvailableAction(ChatService chatService) { + this.chatService = chatService; + } - public String execute() throws Exception { - availableRooms = chatService.getAvailableRooms(); - return SUCCESS; - } + public String execute() throws Exception { + availableRooms = chatService.getAvailableRooms(); + return SUCCESS; + } - public List getAvailableRooms() { - return availableRooms; - } + public List getAvailableRooms() { + return availableRooms; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/SendMessageToRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/SendMessageToRoomAction.java index a24e6c6c1..69a66609c 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/SendMessageToRoomAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/SendMessageToRoomAction.java @@ -20,51 +20,56 @@ */ package org.apache.struts2.showcase.chat; -import java.util.Map; - +import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.SessionAware; -import com.opensymphony.xwork2.ActionSupport; +import java.util.Map; public class SendMessageToRoomAction extends ActionSupport implements SessionAware { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private ChatService chatService; + private ChatService chatService; - private String roomName; - private String message; - private Map session; + private String roomName; + private String message; + private Map session; - public SendMessageToRoomAction(ChatService chatService) { - this.chatService = chatService; - } + public SendMessageToRoomAction(ChatService chatService) { + this.chatService = chatService; + } - public String getRoomName() { return this.roomName; } - public void setRoomName(String roomName) { - this.roomName = roomName; - } + public String getRoomName() { + return this.roomName; + } - public String getMessage() { return this.message; } - public void setMessage(String message) { - this.message = message; - } + public void setRoomName(String roomName) { + this.roomName = roomName; + } + + public String getMessage() { + return this.message; + } + + public void setMessage(String message) { + this.message = message; + } - public String execute() throws Exception { - User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY); - try { - chatService.sendMessageToRoom(roomName, user, message); - }catch(ChatException e) { - addActionError(e.getMessage()); - } - return SUCCESS; - } + public String execute() throws Exception { + User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY); + try { + chatService.sendMessageToRoom(roomName, user, message); + } catch (ChatException e) { + addActionError(e.getMessage()); + } + return SUCCESS; + } - public void setSession(Map session) { - this.session = session; - } + public void setSession(Map session) { + this.session = session; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/User.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/User.java index b649aca5d..0c0b5b3f4 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/User.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/User.java @@ -26,23 +26,24 @@ import java.util.Date; /** * Represends a user in the Chat example. */ -public class User implements Serializable { +public class User implements Serializable { - private static final long serialVersionUID = -1434958919516089297L; + private static final long serialVersionUID = -1434958919516089297L; - private String name; - private Date creationDate; + private String name; + private Date creationDate; - public User(String name) { - this.name = name; - this.creationDate = new Date(System.currentTimeMillis()); - } + public User(String name) { + this.name = name; + this.creationDate = new Date(System.currentTimeMillis()); + } - public Date getCreationDate() { - return creationDate; - } - public String getName() { - return name; - } + public Date getCreationDate() { + return creationDate; + } + + public String getName() { + return name; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/UsersAvailableAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/UsersAvailableAction.java index eae9a8cfe..c2a15c107 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/UsersAvailableAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/UsersAvailableAction.java @@ -20,30 +20,30 @@ */ package org.apache.struts2.showcase.chat; +import com.opensymphony.xwork2.ActionSupport; + import java.util.ArrayList; import java.util.List; -import com.opensymphony.xwork2.ActionSupport; - public class UsersAvailableAction extends ActionSupport { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private List availableUsers = new ArrayList(); - private ChatService chatService; + private List availableUsers = new ArrayList(); + private ChatService chatService; - public UsersAvailableAction(ChatService chatService) { - this.chatService = chatService; - } + public UsersAvailableAction(ChatService chatService) { + this.chatService = chatService; + } - public String execute() throws Exception { + public String execute() throws Exception { - availableUsers = chatService.getAvailableUsers(); + availableUsers = chatService.getAvailableUsers(); - return SUCCESS; - } + return SUCCESS; + } - public List getAvailableUsers() { - return availableUsers; - } + public List getAvailableUsers() { + return availableUsers; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/UsersAvailableInRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/UsersAvailableInRoomAction.java index f56f4334c..bebd73830 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/UsersAvailableInRoomAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/UsersAvailableInRoomAction.java @@ -20,42 +20,44 @@ */ package org.apache.struts2.showcase.chat; +import com.opensymphony.xwork2.ActionSupport; + import java.util.ArrayList; import java.util.List; -import com.opensymphony.xwork2.ActionSupport; - public class UsersAvailableInRoomAction extends ActionSupport { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private ChatService chatService; - private List usersAvailableInRoom = new ArrayList(); + private ChatService chatService; + private List usersAvailableInRoom = new ArrayList(); - private String roomName; + private String roomName; - public UsersAvailableInRoomAction(ChatService chatService) { - this.chatService = chatService; - } + public UsersAvailableInRoomAction(ChatService chatService) { + this.chatService = chatService; + } - public String getRoomName() { return this.roomName; } - public void setRoomName(String roomName) { - this.roomName = roomName; - } + public String getRoomName() { + return this.roomName; + } - public List getUsersAvailableInRoom() { - return usersAvailableInRoom; - } + public void setRoomName(String roomName) { + this.roomName = roomName; + } - public String execute() throws Exception { - try { - usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName); - } - catch(ChatException e) { - addActionError(e.getMessage()); - } - return SUCCESS; - } + public List getUsersAvailableInRoom() { + return usersAvailableInRoom; + } + + public String execute() throws Exception { + try { + usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName); + } catch (ChatException e) { + addActionError(e.getMessage()); + } + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java index 371def7b6..35d1df1ff 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java @@ -26,13 +26,23 @@ package org.apache.struts2.showcase.conversion; */ public class Address { - private String id; - private String address; + private String id; + private String address; - public String getId() { return id; } - public void setId(String id) { this.id = id; } + public String getId() { + return id; + } - public String getAddress() { return address; } - public void setAddress(String address) { this.address = address; } + public void setId(String id) { + this.id = id; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java index a0d20d903..66e9c2746 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java @@ -20,28 +20,32 @@ */ package org.apache.struts2.showcase.conversion; +import com.opensymphony.xwork2.ActionSupport; + import java.util.LinkedHashSet; import java.util.Set; -import com.opensymphony.xwork2.ActionSupport; - /** * @version $Date$ $Id$ */ public class AddressAction extends ActionSupport { - private Set addresses = new LinkedHashSet(); + private Set
addresses = new LinkedHashSet
(); - public Set getAddresses() { return addresses; } - public void setAddresses(Set addresses) { this.addresses = addresses; } + public String input() throws Exception { + return SUCCESS; + } + public String submit() throws Exception { + System.out.println(addresses); + return SUCCESS; + } - public String input() throws Exception { - return SUCCESS; - } + public Set
getAddresses() { + return addresses; + } - public String submit() throws Exception { - System.out.println(addresses); - return SUCCESS; - } + public void setAddresses(Set
addresses) { + this.addresses = addresses; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java index 6efa44cf3..361322318 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java @@ -20,39 +20,39 @@ */ package org.apache.struts2.showcase.conversion; +import org.apache.struts2.util.StrutsTypeConverter; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.struts2.util.StrutsTypeConverter; - /** * @version $Date$ $Id$ */ public class EnumTypeConverter extends StrutsTypeConverter { - @Override - public Object convertFromString(Map context, String[] values, Class toClass) { - List result = new ArrayList(); - for (int a=0; a< values.length; a++) { - Enum e = Enum.valueOf(OperationsEnum.class, values[a]); - if (e != null) - result.add(e); - } - return result; - } + @Override + public Object convertFromString(Map context, String[] values, Class toClass) { + List result = new ArrayList(); + for (int a = 0; a < values.length; a++) { + Enum e = Enum.valueOf(OperationsEnum.class, values[a]); + if (e != null) + result.add(e); + } + return result; + } - @Override - public String convertToString(Map context, Object o) { - List l = (List) o; - String result ="<"; - for (Iterator i = l.iterator(); i.hasNext(); ) { - result = result + "["+ i.next() +"]"; - } - result = result+">"; - return result; - } + @Override + public String convertToString(Map context, Object o) { + List l = (List) o; + String result = "<"; + for (Iterator i = l.iterator(); i.hasNext(); ) { + result = result + "[" + i.next() + "]"; + } + result = result + ">"; + return result; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java index e9a77988f..99ca27609 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java @@ -21,13 +21,12 @@ package org.apache.struts2.showcase.conversion; /** - * * @version $Date$ $Id$ */ public enum OperationsEnum { - ADD, - MINUS, - DIVIDE, - MULTIPLY, - REMAINDER; + ADD, + MINUS, + DIVIDE, + MULTIPLY, + REMAINDER; } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java index 2769858a3..a8f8cd624 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java @@ -20,37 +20,40 @@ */ package org.apache.struts2.showcase.conversion; +import com.opensymphony.xwork2.ActionSupport; + import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import com.opensymphony.xwork2.ActionSupport; - /** - * * @version $Date$ $Id$ */ public class OperationsEnumAction extends ActionSupport { - private static final long serialVersionUID = -2229489704988870318L; + private static final long serialVersionUID = -2229489704988870318L; - private List selectedOperations = new LinkedList(); + private List selectedOperations = new LinkedList(); - public List getSelectedOperations() { return this.selectedOperations; } - public void setSelectedOperations(List selectedOperations) { - this.selectedOperations = selectedOperations; - } + public String input() throws Exception { + return SUCCESS; + } + + public String submit() throws Exception { + return SUCCESS; + } + + public List getSelectedOperations() { + return this.selectedOperations; + } + + public void setSelectedOperations(List selectedOperations) { + this.selectedOperations = selectedOperations; + } - public List getAvailableOperations() { - return Arrays.asList(OperationsEnum.values()); - } - - public String input() throws Exception { - return SUCCESS; - } - public String submit() throws Exception { - return SUCCESS; - } + public List getAvailableOperations() { + return Arrays.asList(OperationsEnum.values()); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Person.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Person.java index ed63fd42c..9a3b597d0 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Person.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Person.java @@ -22,16 +22,23 @@ package org.apache.struts2.showcase.conversion; import java.io.Serializable; -/** - * - */ public class Person implements Serializable { - private String name; - private Integer age; + private String name; + private Integer age; - public void setName(String name) { this.name = name; } - public String getName() { return this.name; } + public void setName(String name) { + this.name = name; + } - public void setAge(Integer age) { this.age = age; } - public Integer getAge() { return this.age; } + public String getName() { + return this.name; + } + + public void setAge(Integer age) { + this.age = age; + } + + public Integer getAge() { + return this.age; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/PersonAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/PersonAction.java index 96ff77d40..70307db80 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/PersonAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/PersonAction.java @@ -20,27 +20,28 @@ */ package org.apache.struts2.showcase.conversion; -import java.util.List; - import com.opensymphony.xwork2.ActionSupport; -/** - * - */ +import java.util.List; + public class PersonAction extends ActionSupport { - private List persons; + private List persons; - public List getPersons() { return persons; } - public void setPersons(List persons) { this.persons = persons; } + public String input() throws Exception { + return SUCCESS; + } + public String submit() throws Exception { + return SUCCESS; + } + public List getPersons() { + return persons; + } - public String input() throws Exception { - return SUCCESS; - } + public void setPersons(List persons) { + this.persons = persons; + } - public String submit() throws Exception { - return SUCCESS; - } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/AbstractDao.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/AbstractDao.java index aae90e729..8f70e4de4 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/AbstractDao.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/AbstractDao.java @@ -20,58 +20,59 @@ */ package org.apache.struts2.showcase.dao; -import java.io.Serializable; -import java.util.Collection; - import org.apache.struts2.showcase.application.Storage; import org.apache.struts2.showcase.exception.CreateException; import org.apache.struts2.showcase.exception.StorageException; import org.apache.struts2.showcase.exception.UpdateException; import org.apache.struts2.showcase.model.IdEntity; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.Serializable; +import java.util.Collection; /** * AbstractDao. - * */ public abstract class AbstractDao implements Serializable, Dao { - private Storage storage; + @Autowired + private Storage storage; - public Storage getStorage() { - return storage; - } + public Storage getStorage() { + return storage; + } - public void setStorage(Storage storage) { - this.storage = storage; - } + public void setStorage(Storage storage) { + this.storage = storage; + } - public IdEntity get(Serializable id) { - return getStorage().get(getFeaturedClass(), id); - } + public IdEntity get(Serializable id) { + return getStorage().get(getFeaturedClass(), id); + } - public Serializable create(IdEntity object) throws CreateException { - return getStorage().create(object); - } + public Serializable create(IdEntity object) throws CreateException { + return getStorage().create(object); + } - public IdEntity update(IdEntity object) throws UpdateException { - return getStorage().update(object); - } + public IdEntity update(IdEntity object) throws UpdateException { + return getStorage().update(object); + } - public Serializable merge(IdEntity object) throws StorageException { - return getStorage().merge(object); - } + public Serializable merge(IdEntity object) throws StorageException { + return getStorage().merge(object); + } - public int delete(Serializable id) throws CreateException { - return getStorage().delete(getFeaturedClass(), id); - } + public int delete(Serializable id) throws CreateException { + return getStorage().delete(getFeaturedClass(), id); + } - public int delete(IdEntity object) throws CreateException { - return getStorage().delete(object); - } + public int delete(IdEntity object) throws CreateException { + return getStorage().delete(object); + } - public Collection findAll() { - return getStorage().findAll(getFeaturedClass()); - } + public Collection findAll() { + return getStorage().findAll(getFeaturedClass()); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/Dao.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/Dao.java index 9a88319da..6b4963bcd 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/Dao.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/Dao.java @@ -20,34 +20,33 @@ */ package org.apache.struts2.showcase.dao; -import java.io.Serializable; -import java.util.Collection; - import org.apache.struts2.showcase.exception.CreateException; import org.apache.struts2.showcase.exception.StorageException; import org.apache.struts2.showcase.exception.UpdateException; import org.apache.struts2.showcase.model.IdEntity; +import java.io.Serializable; +import java.util.Collection; + /** * Dao. Interface. - * */ public interface Dao { - Class getFeaturedClass(); + Class getFeaturedClass(); - IdEntity get(Serializable id); + IdEntity get(Serializable id); - Serializable create(IdEntity object) throws CreateException; + Serializable create(IdEntity object) throws CreateException; - IdEntity update(IdEntity object) throws UpdateException; + IdEntity update(IdEntity object) throws UpdateException; - Serializable merge(IdEntity object) throws StorageException; + Serializable merge(IdEntity object) throws StorageException; - int delete(Serializable id) throws CreateException; + int delete(Serializable id) throws CreateException; - int delete(IdEntity object) throws CreateException; + int delete(IdEntity object) throws CreateException; - Collection findAll(); + Collection findAll(); } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/EmployeeDao.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/EmployeeDao.java index ebec67348..b5d0c4b59 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/EmployeeDao.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/EmployeeDao.java @@ -20,48 +20,50 @@ */ package org.apache.struts2.showcase.dao; +import org.apache.struts2.showcase.model.Employee; +import org.apache.struts2.showcase.model.Skill; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + import java.util.ArrayList; import java.util.List; -import org.apache.struts2.showcase.model.Employee; -import org.apache.struts2.showcase.model.Skill; - /** * EmployeeDao. - * */ - +@Repository public class EmployeeDao extends AbstractDao { - private static final long serialVersionUID = -6615310540042830594L; + private static final long serialVersionUID = -6615310540042830594L; - protected SkillDao skillDao; + @Autowired + protected SkillDao skillDao; - public void setSkillDao(SkillDao skillDao) { - this.skillDao = skillDao; - } + public void setSkillDao(SkillDao skillDao) { + this.skillDao = skillDao; + } - public Class getFeaturedClass() { - return Employee.class; - } + public Class getFeaturedClass() { + return Employee.class; + } - public Employee getEmployee( Long id ) { - return (Employee) get(id); - } + public Employee getEmployee(Long id) { + return (Employee) get(id); + } - public Employee setSkills(Employee employee, List skillNames) { - if (employee!= null && skillNames != null) { - employee.setOtherSkills(new ArrayList()); - for (int i = 0, j = skillNames.size(); i < j; i++) { - Skill skill = (Skill) skillDao.get((String) skillNames.get(i)); - employee.getOtherSkills().add(skill); - } - } - return employee; - } + public Employee setSkills(Employee employee, List skillNames) { + if (employee != null && skillNames != null) { + employee.setOtherSkills(new ArrayList()); + for (int i = 0, j = skillNames.size(); i < j; i++) { + Skill skill = (Skill) skillDao.get(skillNames.get(i)); + employee.getOtherSkills().add(skill); + } + } + return employee; + } - public Employee setSkills(Long empId, List skillNames) { - return setSkills((Employee) get(empId), skillNames); - } + public Employee setSkills(Long empId, List skillNames) { + return setSkills((Employee) get(empId), skillNames); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/SkillDao.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/SkillDao.java index f51421d5c..3fdd931f3 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/SkillDao.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/dao/SkillDao.java @@ -21,21 +21,22 @@ package org.apache.struts2.showcase.dao; import org.apache.struts2.showcase.model.Skill; +import org.springframework.stereotype.Repository; /** * SkillDao. - * */ +@Repository public class SkillDao extends AbstractDao { - private static final long serialVersionUID = -8160406514074630866L; + private static final long serialVersionUID = -8160406514074630866L; - public Class getFeaturedClass() { - return Skill.class; - } + public Class getFeaturedClass() { + return Skill.class; + } - public Skill getSkill( String name ) { - return (Skill) get(name); - } + public Skill getSkill(String name) { + return (Skill) get(name); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/CreateException.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/CreateException.java index 23cc287e5..13011cba9 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/CreateException.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/CreateException.java @@ -22,22 +22,21 @@ package org.apache.struts2.showcase.exception; /** * CreateException. - * */ public class CreateException extends StorageException { - private static final long serialVersionUID = 6734349565111633783L; + private static final long serialVersionUID = 6734349565111633783L; - public CreateException(String message) { - super(message); - } + public CreateException(String message) { + super(message); + } - public CreateException(String message, Throwable cause) { - super(message, cause); - } + public CreateException(String message, Throwable cause) { + super(message, cause); + } - public CreateException(Throwable cause) { - super(cause); - } + public CreateException(Throwable cause) { + super(cause); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/DeleteException.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/DeleteException.java index f2d2dfcbb..da7d11e15 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/DeleteException.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/DeleteException.java @@ -22,23 +22,22 @@ package org.apache.struts2.showcase.exception; /** * DeleteException. - * */ public class DeleteException extends StorageException { - private static final long serialVersionUID = -5286362812955627352L; + private static final long serialVersionUID = -5286362812955627352L; - public DeleteException(String message) { - super(message); - } + public DeleteException(String message) { + super(message); + } - public DeleteException(Throwable cause) { - super(cause); - } + public DeleteException(Throwable cause) { + super(cause); + } - public DeleteException(String message, Throwable cause) { - super(message, cause); - } + public DeleteException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/DuplicateKeyException.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/DuplicateKeyException.java index 1ae17ddae..82f93653e 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/DuplicateKeyException.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/DuplicateKeyException.java @@ -22,23 +22,22 @@ package org.apache.struts2.showcase.exception; /** * DuplicateKeyException. - * */ public class DuplicateKeyException extends CreateException { - private static final long serialVersionUID = 989620752592415898L; + private static final long serialVersionUID = 989620752592415898L; - public DuplicateKeyException(String message) { - super(message); - } + public DuplicateKeyException(String message) { + super(message); + } - public DuplicateKeyException(Throwable cause) { - super(cause); - } + public DuplicateKeyException(Throwable cause) { + super(cause); + } - public DuplicateKeyException(String message, Throwable cause) { - super(message, cause); - } + public DuplicateKeyException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/StorageException.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/StorageException.java index 7628bc2f5..9f7fdf0ef 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/StorageException.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/StorageException.java @@ -22,23 +22,22 @@ package org.apache.struts2.showcase.exception; /** * StorageException. - * */ public class StorageException extends Exception { - private static final long serialVersionUID = -2528721270540362905L; + private static final long serialVersionUID = -2528721270540362905L; - public StorageException(String message) { - super(message); - } + public StorageException(String message) { + super(message); + } - public StorageException(Throwable cause) { - super(cause); - } + public StorageException(Throwable cause) { + super(cause); + } - public StorageException(String message, Throwable cause) { - super(message, cause); - } + public StorageException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/UpdateException.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/UpdateException.java index 3f5023c81..39aa9ab99 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/UpdateException.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/exception/UpdateException.java @@ -23,23 +23,22 @@ package org.apache.struts2.showcase.exception; /** * UpdateException. - * */ public class UpdateException extends StorageException { - private static final long serialVersionUID = -4728238600375630452L; + private static final long serialVersionUID = -4728238600375630452L; - public UpdateException(String message) { - super(message); - } + public UpdateException(String message) { + super(message); + } - public UpdateException(Throwable cause) { - super(cause); - } + public UpdateException(Throwable cause) { + super(cause); + } - public UpdateException(String message, Throwable cause) { - super(message, cause); - } + public UpdateException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/filedownload/FileDownloadAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/filedownload/FileDownloadAction.java index 5e3cc5679..4dd1be5f5 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/filedownload/FileDownloadAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/filedownload/FileDownloadAction.java @@ -20,31 +20,29 @@ */ package org.apache.struts2.showcase.filedownload; -import java.io.InputStream; - +import com.opensymphony.xwork2.Action; import org.apache.struts2.ServletActionContext; -import com.opensymphony.xwork2.Action; +import java.io.InputStream; /** * Demonstrates file resource download. * Set filePath to the local file resource to download, * relative to the application root ("/images/struts.gif"). - * */ public class FileDownloadAction implements Action { - private String inputPath; - public void setInputPath(String value) { - inputPath = value; - } + private String inputPath; - public InputStream getInputStream() throws Exception { - return ServletActionContext.getServletContext().getResourceAsStream(inputPath); - } + public String execute() throws Exception { + return SUCCESS; + } - public String execute() throws Exception { - return SUCCESS; - } + public void setInputPath(String value) { + inputPath = value; + } + public InputStream getInputStream() throws Exception { + return ServletActionContext.getServletContext().getResourceAsStream(inputPath); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java index e0b7c06a0..60053067e 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java @@ -20,66 +20,68 @@ */ package org.apache.struts2.showcase.fileupload; -import java.io.File; - import com.opensymphony.xwork2.ActionSupport; +import java.io.File; + /** * Show case File Upload example's action. FileUploadAction - * */ public class FileUploadAction extends ActionSupport { - private static final long serialVersionUID = 5156288255337069381L; + private static final long serialVersionUID = 5156288255337069381L; - private String contentType; - private File upload; - private String fileName; - private String caption; + private String contentType; + private File upload; + private String fileName; + private String caption; - // since we are using the file name will be - // obtained through getter/setter of FileName - public String getUploadFileName() { - return fileName; - } - public void setUploadFileName(String fileName) { - this.fileName = fileName; - } + public String input() throws Exception { + return SUCCESS; + } + + public String upload() throws Exception { + return SUCCESS; + } + + // since we are using the file name will be + // obtained through getter/setter of FileName + public String getUploadFileName() { + return fileName; + } + + public void setUploadFileName(String fileName) { + this.fileName = fileName; + } - // since we are using the content type will be - // obtained through getter/setter of ContentType - public String getUploadContentType() { - return contentType; - } - public void setUploadContentType(String contentType) { - this.contentType = contentType; - } + // since we are using the content type will be + // obtained through getter/setter of ContentType + public String getUploadContentType() { + return contentType; + } + + public void setUploadContentType(String contentType) { + this.contentType = contentType; + } - // since we are using the File itself will be - // obtained through getter/setter of - public File getUpload() { - return upload; - } - public void setUpload(File upload) { - this.upload = upload; - } + // since we are using the File itself will be + // obtained through getter/setter of + public File getUpload() { + return upload; + } + + public void setUpload(File upload) { + this.upload = upload; + } - public String getCaption() { - return caption; - } - public void setCaption(String caption) { - this.caption = caption; - } - - public String input() throws Exception { - return SUCCESS; - } - - public String upload() throws Exception { - return SUCCESS; - } + public String getCaption() { + return caption; + } + public void setCaption(String caption) { + this.caption = caption; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingArrayAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingArrayAction.java index b7427f41f..b1a598543 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingArrayAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingArrayAction.java @@ -21,10 +21,10 @@ // START SNIPPET: entire-file package org.apache.struts2.showcase.fileupload; -import java.io.File; - import com.opensymphony.xwork2.ActionSupport; +import java.io.File; + /** * Showcase action - mutiple file upload using array. * @@ -32,35 +32,51 @@ import com.opensymphony.xwork2.ActionSupport; */ public class MultipleFileUploadUsingArrayAction extends ActionSupport { - private File[] uploads; - private String[] uploadFileNames; - private String[] uploadContentTypes; + private File[] uploads; + private String[] uploadFileNames; + private String[] uploadContentTypes; - public File[] getUpload() { return this.uploads; } - public void setUpload(File[] upload) { this.uploads = upload; } - public String[] getUploadFileName() { return this.uploadFileNames; } - public void setUploadFileName(String[] uploadFileName) { this.uploadFileNames = uploadFileName; } + public String upload() throws Exception { + System.out.println("\n\n upload2"); + System.out.println("files:"); + for (File u : uploads) { + System.out.println("*** " + u + "\t" + u.length()); + } + System.out.println("filenames:"); + for (String n : uploadFileNames) { + System.out.println("*** " + n); + } + System.out.println("content types:"); + for (String c : uploadContentTypes) { + System.out.println("*** " + c); + } + System.out.println("\n\n"); + return SUCCESS; + } - public String[] getUploadContentType() { return this.uploadContentTypes; } - public void setUploadContentType(String[] uploadContentType) { this.uploadContentTypes = uploadContentType; } + public File[] getUpload() { + return this.uploads; + } - public String upload() throws Exception { - System.out.println("\n\n upload2"); - System.out.println("files:"); - for (File u: uploads) { - System.out.println("*** "+u+"\t"+u.length()); - } - System.out.println("filenames:"); - for (String n: uploadFileNames) { - System.out.println("*** "+n); - } - System.out.println("content types:"); - for (String c: uploadContentTypes) { - System.out.println("*** "+c); - } - System.out.println("\n\n"); - return SUCCESS; - } + public void setUpload(File[] upload) { + this.uploads = upload; + } + + public String[] getUploadFileName() { + return this.uploadFileNames; + } + + public void setUploadFileName(String[] uploadFileName) { + this.uploadFileNames = uploadFileName; + } + + public String[] getUploadContentType() { + return this.uploadContentTypes; + } + + public void setUploadContentType(String[] uploadContentType) { + this.uploadContentTypes = uploadContentType; + } } // END SNIPPET: entire-file \ No newline at end of file diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java index 1ab84becb..56e5875bd 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java @@ -20,61 +20,66 @@ */ // START SNIPPET: entire-file package org.apache.struts2.showcase.fileupload; + +import com.opensymphony.xwork2.ActionSupport; + import java.io.File; import java.util.ArrayList; import java.util.List; -import com.opensymphony.xwork2.ActionSupport; - /** * Showcase action - multiple file upload using List + * * @version $Date$ $Id$ */ public class MultipleFileUploadUsingListAction extends ActionSupport { - private List uploads = new ArrayList(); - private List uploadFileNames = new ArrayList(); - private List uploadContentTypes = new ArrayList(); + private List uploads = new ArrayList(); + private List uploadFileNames = new ArrayList(); + private List uploadContentTypes = new ArrayList(); - public List getUpload() { - return this.uploads; - } - public void setUpload(List uploads) { - this.uploads = uploads; - } + public List getUpload() { + return this.uploads; + } - public List getUploadFileName() { - return this.uploadFileNames; - } - public void setUploadFileName(List uploadFileNames) { - this.uploadFileNames = uploadFileNames; - } + public void setUpload(List uploads) { + this.uploads = uploads; + } - public List getUploadContentType() { - return this.uploadContentTypes; - } - public void setUploadContentType(List contentTypes) { - this.uploadContentTypes = contentTypes; - } + public List getUploadFileName() { + return this.uploadFileNames; + } - public String upload() throws Exception { + public void setUploadFileName(List uploadFileNames) { + this.uploadFileNames = uploadFileNames; + } - System.out.println("\n\n upload1"); - System.out.println("files:"); - for (File u: uploads) { - System.out.println("*** "+u+"\t"+u.length()); - } - System.out.println("filenames:"); - for (String n: uploadFileNames) { - System.out.println("*** "+n); - } - System.out.println("content types:"); - for (String c: uploadContentTypes) { - System.out.println("*** "+c); - } - System.out.println("\n\n"); - return SUCCESS; - } + public List getUploadContentType() { + return this.uploadContentTypes; + } + + public void setUploadContentType(List contentTypes) { + this.uploadContentTypes = contentTypes; + } + + public String upload() throws Exception { + + System.out.println("\n\n upload1"); + System.out.println("files:"); + for (File u : uploads) { + System.out.println("*** " + u + "\t" + u.length()); + } + System.out.println("filenames:"); + for (String n : uploadFileNames) { + System.out.println("*** " + n); + } + System.out.println("content types:"); + for (String c : uploadContentTypes) { + System.out.println("*** " + c); + } + System.out.println("\n\n"); + return SUCCESS; + } } // END SNIPPET: entire-file \ No newline at end of file diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/CustomFreemarkerManager.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/CustomFreemarkerManager.java index 9b712c065..3eb4e0888 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/CustomFreemarkerManager.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/CustomFreemarkerManager.java @@ -20,39 +20,37 @@ */ package org.apache.struts2.showcase.freemarker; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - +import com.opensymphony.xwork2.util.ValueStack; import org.apache.struts2.views.freemarker.FreemarkerManager; import org.apache.struts2.views.freemarker.ScopesHashModel; -import com.opensymphony.xwork2.ognl.OgnlValueStack; -import com.opensymphony.xwork2.util.ValueStack; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** * This is an example of a custom FreemarkerManager, mean to be * instantiated through Spring. *

- * + *

* It will add into Freemarker's model * an utility class called {@link CustomFreemarkerManagerUtil} as a simple * example demonstrating how to extends FreemarkerManager. *

- * + *

* The {@link CustomFreemarkerManagerUtil} will be created by Spring and * injected through constructor injection. *

*/ public class CustomFreemarkerManager extends FreemarkerManager { - private CustomFreemarkerManagerUtil util; + private CustomFreemarkerManagerUtil util; - public CustomFreemarkerManager(CustomFreemarkerManagerUtil util) { - this.util = util; - } + public CustomFreemarkerManager(CustomFreemarkerManagerUtil util) { + this.util = util; + } - protected void populateContext(ScopesHashModel model, ValueStack stack, Object action, HttpServletRequest request, HttpServletResponse response) { - super.populateContext(model, stack, action, request, response); - model.put("customFreemarkerManagerUtil", util); - } + protected void populateContext(ScopesHashModel model, ValueStack stack, Object action, HttpServletRequest request, HttpServletResponse response) { + super.populateContext(model, stack, action, request, response); + model.put("customFreemarkerManagerUtil", util); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/CustomFreemarkerManagerUtil.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/CustomFreemarkerManagerUtil.java index d80932378..290e9928c 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/CustomFreemarkerManagerUtil.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/CustomFreemarkerManagerUtil.java @@ -30,13 +30,13 @@ import java.util.Date; */ public class CustomFreemarkerManagerUtil { - public String getTodayDate() { - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); - return sdf.format(new Date()); - } + public String getTodayDate() { + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); + return sdf.format(new Date()); + } - public String getTimeNow() { - SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss"); - return sdf.format(new Date()); - } + public String getTimeNow() { + SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss"); + return sdf.format(new Date()); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/StandardTagsAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/StandardTagsAction.java index ce881b62c..c23ee156a 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/StandardTagsAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/freemarker/StandardTagsAction.java @@ -30,38 +30,38 @@ import java.text.DateFormatSymbols; */ public class StandardTagsAction extends ActionSupport implements Preparable { - private String name; - private String[] gender; - private String[] months; + private String name; + private String[] gender; + private String[] months; - public void prepare() { - months = new DateFormatSymbols().getMonths(); - name = StandardTagsAction.class.getName().substring(StandardTagsAction.class.getName().lastIndexOf(".")+1); - gender = new String[] { "Male", "Femal" }; - } + public void prepare() { + months = new DateFormatSymbols().getMonths(); + name = StandardTagsAction.class.getName().substring(StandardTagsAction.class.getName().lastIndexOf(".") + 1); + gender = new String[]{"Male", "Femal"}; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String[] getMonths() { - return months; - } + public String[] getMonths() { + return months; + } - public void setMonths(String[] months) { - this.months = months; - } + public void setMonths(String[] months) { + this.months = months; + } - public String[] getGender() { - return gender; - } + public String[] getGender() { + return gender; + } - public void setGender(String[] gender) { - this.gender = gender; - } + public void setGender(String[] gender) { + this.gender = gender; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GetUpdatedHangmanAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GetUpdatedHangmanAction.java index e0c99b205..24b777355 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GetUpdatedHangmanAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GetUpdatedHangmanAction.java @@ -20,40 +20,40 @@ */ package org.apache.struts2.showcase.hangman; -import java.util.Map; - +import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.SessionAware; -import com.opensymphony.xwork2.ActionSupport; +import java.util.Map; public class GetUpdatedHangmanAction extends ActionSupport implements SessionAware { - private static final long serialVersionUID = 5506025785406043027L; + private static final long serialVersionUID = 5506025785406043027L; - private Map session; - private Hangman hangman; + private Map session; + private Hangman hangman; - public String execute() throws Exception { - hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY); + public String execute() throws Exception { + hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY); - System.out.println("\n\n\n"); - System.out.println("hangman="+hangman); - System.out.println("available = "+hangman.getCharactersAvailable().size()); - System.out.println("guess left="+hangman.guessLeft()); - System.out.println("\n\n\n"); + System.out.println("\n\n\n"); + System.out.println("hangman=" + hangman); + System.out.println("available = " + hangman.getCharactersAvailable().size()); + System.out.println("guess left=" + hangman.guessLeft()); + System.out.println("\n\n\n"); - return SUCCESS; - } + return SUCCESS; + } - public void setSession(Map session) { - this.session = session; - } + public void setSession(Map session) { + this.session = session; + } - public Hangman getHangman() { - return hangman; - } - public void setHangman(Hangman hangman) { - this.hangman = hangman; - } + public Hangman getHangman() { + return hangman; + } + + public void setHangman(Hangman hangman) { + this.hangman = hangman; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java index d15c223d4..40ab60fe4 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java @@ -20,40 +20,39 @@ */ package org.apache.struts2.showcase.hangman; -import java.util.Map; - +import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.SessionAware; -import com.opensymphony.xwork2.ActionSupport; +import java.util.Map; public class GuessCharacterAction extends ActionSupport implements SessionAware { - private static final long serialVersionUID = 9050915577007590674L; + private static final long serialVersionUID = 9050915577007590674L; - private Map session; - private Character character; - private Hangman hangman; + private Map session; + private Character character; + private Hangman hangman; - public String execute() throws Exception { - hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY); - hangman.guess(character); + public String execute() throws Exception { + hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY); + hangman.guess(character); - return SUCCESS; - } + return SUCCESS; + } - public Hangman getHangman() { - return hangman; - } + public Hangman getHangman() { + return hangman; + } - public void setSession(Map session) { - this.session = session; - } + public void setSession(Map session) { + this.session = session; + } - public void setCharacter(Character character) { - this.character = character; - } + public void setCharacter(Character character) { + this.character = character; + } - public Character getCharacter() { - return this.character; - } + public Character getCharacter() { + return this.character; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/Hangman.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/Hangman.java index 1fdf2daa4..4dce5521c 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/Hangman.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/Hangman.java @@ -27,83 +27,83 @@ import java.util.List; public class Hangman implements Serializable { - private static final long serialVersionUID = 8566954355839652509L; + private static final long serialVersionUID = 8566954355839652509L; - private Vocab vocab; + private Vocab vocab; - private Boolean win = false; + private Boolean win = false; - private int guessLeft = 5; - public List charactersAvailable; - public List charactersGuessed; + private int guessLeft = 5; + public List charactersAvailable; + public List charactersGuessed; - public Hangman(Vocab vocab) { - // Arrays.asList(...) returns List that doesn't support remove(), hence - // we wrap it with an ArrayList to avoid UnsupportedOperationException - // when doing a remove() - charactersAvailable = new ArrayList(Arrays.asList( - new Character[] { - Character.valueOf('A'), Character.valueOf('B'), Character.valueOf('C'), - Character.valueOf('D'), Character.valueOf('E'), Character.valueOf('F'), - Character.valueOf('G'), Character.valueOf('H'), Character.valueOf('I'), - Character.valueOf('J'), Character.valueOf('K'), Character.valueOf('L'), - Character.valueOf('M'), Character.valueOf('N'), Character.valueOf('O'), - Character.valueOf('P'), Character.valueOf('Q'), Character.valueOf('R'), - Character.valueOf('S'), Character.valueOf('T'), Character.valueOf('U'), - Character.valueOf('V'), Character.valueOf('W'), Character.valueOf('X'), - Character.valueOf('Y'), Character.valueOf('Z') - })); - charactersGuessed = new ArrayList(); - this.vocab = vocab; - } + public Hangman(Vocab vocab) { + // Arrays.asList(...) returns List that doesn't support remove(), hence + // we wrap it with an ArrayList to avoid UnsupportedOperationException + // when doing a remove() + charactersAvailable = new ArrayList(Arrays.asList( + new Character[]{ + Character.valueOf('A'), Character.valueOf('B'), Character.valueOf('C'), + Character.valueOf('D'), Character.valueOf('E'), Character.valueOf('F'), + Character.valueOf('G'), Character.valueOf('H'), Character.valueOf('I'), + Character.valueOf('J'), Character.valueOf('K'), Character.valueOf('L'), + Character.valueOf('M'), Character.valueOf('N'), Character.valueOf('O'), + Character.valueOf('P'), Character.valueOf('Q'), Character.valueOf('R'), + Character.valueOf('S'), Character.valueOf('T'), Character.valueOf('U'), + Character.valueOf('V'), Character.valueOf('W'), Character.valueOf('X'), + Character.valueOf('Y'), Character.valueOf('Z') + })); + charactersGuessed = new ArrayList(); + this.vocab = vocab; + } - public void guess(Character character) { - assert(character != null); + public void guess(Character character) { + assert (character != null); - synchronized(charactersAvailable) { - if (guessLeft < 0) { - throw new HangmanException( - HangmanException.Type.valueOf("GAME_ENDED"), "Game already eneded"); - } - Character characterInUpperCase = Character.toUpperCase(character); - boolean ok = charactersAvailable.remove(characterInUpperCase); - if (ok) { - charactersGuessed.add(characterInUpperCase); - if (! vocab.containCharacter(characterInUpperCase)) { - guessLeft = guessLeft - 1; - } - } - if (vocab.containsAllCharacter(charactersGuessed)) { - win = true; - } - System.out.println(" *********************************** "+win); - } - } + synchronized (charactersAvailable) { + if (guessLeft < 0) { + throw new HangmanException( + HangmanException.Type.valueOf("GAME_ENDED"), "Game already eneded"); + } + Character characterInUpperCase = Character.toUpperCase(character); + boolean ok = charactersAvailable.remove(characterInUpperCase); + if (ok) { + charactersGuessed.add(characterInUpperCase); + if (!vocab.containCharacter(characterInUpperCase)) { + guessLeft = guessLeft - 1; + } + } + if (vocab.containsAllCharacter(charactersGuessed)) { + win = true; + } + System.out.println(" *********************************** " + win); + } + } - public Boolean isWin() { - return this.win; - } + public Boolean isWin() { + return this.win; + } - public Vocab getVocab() { - return vocab; - } + public Vocab getVocab() { + return vocab; + } - public Boolean gameEnded() { - return ((guessLeft < 0) || win); - } + public Boolean gameEnded() { + return ((guessLeft < 0) || win); + } - public Integer guessLeft() { - return guessLeft; - } + public Integer guessLeft() { + return guessLeft; + } - public List getCharactersAvailable() { - synchronized(charactersAvailable) { - return new ArrayList(charactersAvailable); - //return charactersAvailable; - } - } + public List getCharactersAvailable() { + synchronized (charactersAvailable) { + return new ArrayList(charactersAvailable); + //return charactersAvailable; + } + } - public boolean characterGuessedBefore(Character character) { - return charactersGuessed.contains(character); - } + public boolean characterGuessedBefore(Character character) { + return charactersGuessed.contains(character); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanConstants.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanConstants.java index bae60ded0..cf6881ee0 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanConstants.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanConstants.java @@ -21,6 +21,6 @@ package org.apache.struts2.showcase.hangman; public class HangmanConstants { - // keeps a Hangman object in HttpSession - public static final String HANGMAN_SESSION_KEY = "Hangman_Session_Key"; + // keeps a Hangman object in HttpSession + public static final String HANGMAN_SESSION_KEY = "Hangman_Session_Key"; } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanException.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanException.java index feffb1c22..ce4d72cea 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanException.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanException.java @@ -22,23 +22,23 @@ package org.apache.struts2.showcase.hangman; public class HangmanException extends RuntimeException { - private static final long serialVersionUID = -8500292863595941335L; + private static final long serialVersionUID = -8500292863595941335L; - enum Type { - GAME_ENDED, - NO_VOCAB, - NO_VOCAB_SOURCE; - } + enum Type { + GAME_ENDED, + NO_VOCAB, + NO_VOCAB_SOURCE; + } - private Type type; + private Type type; - public HangmanException (Type type, String reason) { - super(reason); - this.type = type; - } + public HangmanException(Type type, String reason) { + super(reason); + this.type = type; + } - public Type getType() { - return type; - } + public Type getType() { + return type; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanService.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanService.java index 410acd85c..33d1cb3a3 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanService.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/HangmanService.java @@ -22,13 +22,13 @@ package org.apache.struts2.showcase.hangman; public class HangmanService { - public VocabSource vocabSource; + public VocabSource vocabSource; - public HangmanService(VocabSource vocabSource) { - this.vocabSource = vocabSource; - } + public HangmanService(VocabSource vocabSource) { + this.vocabSource = vocabSource; + } - public Hangman startNewGame() { - return new Hangman(vocabSource.getRandomVocab()); - } + public Hangman startNewGame() { + return new Hangman(vocabSource.getRandomVocab()); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/PropertiesVocabSource.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/PropertiesVocabSource.java index 0ab443977..54782d1ce 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/PropertiesVocabSource.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/PropertiesVocabSource.java @@ -27,45 +27,45 @@ import java.util.Properties; public class PropertiesVocabSource implements VocabSource { - private Properties prop; - private List vocabs; + private Properties prop; + private List vocabs; - public PropertiesVocabSource() { - } + public PropertiesVocabSource() { + } - public PropertiesVocabSource(Properties prop) { - assert(prop != null); - this.prop = prop; - vocabs = readVocab(prop); - } + public PropertiesVocabSource(Properties prop) { + assert (prop != null); + this.prop = prop; + vocabs = readVocab(prop); + } - public void setVocabProperties(Properties prop) { - assert(prop != null); - this.prop = prop; - vocabs = readVocab(prop); - } + public void setVocabProperties(Properties prop) { + assert (prop != null); + this.prop = prop; + vocabs = readVocab(prop); + } - public Vocab getRandomVocab() { - if (vocabs == null) { - throw new HangmanException(HangmanException.Type.valueOf("NO_VOCAB_SOURCE"), "No vocab source"); - } - if (vocabs.size() <= 0) { - throw new HangmanException(HangmanException.Type.valueOf("NO_VOCAB"), "No vocab"); - } - long vocabIndex = Math.round((Math.random() * (double)prop.size())); - vocabIndex = vocabIndex == vocabs.size() ? vocabs.size() - 1 : vocabIndex; - return vocabs.get((int)vocabIndex); - } + public Vocab getRandomVocab() { + if (vocabs == null) { + throw new HangmanException(HangmanException.Type.valueOf("NO_VOCAB_SOURCE"), "No vocab source"); + } + if (vocabs.size() <= 0) { + throw new HangmanException(HangmanException.Type.valueOf("NO_VOCAB"), "No vocab"); + } + long vocabIndex = Math.round((Math.random() * (double) prop.size())); + vocabIndex = vocabIndex == vocabs.size() ? vocabs.size() - 1 : vocabIndex; + return vocabs.get((int) vocabIndex); + } - protected List readVocab(Properties prop) { - List vocabList = new ArrayList(); + protected List readVocab(Properties prop) { + List vocabList = new ArrayList(); - for (Map.Entry e : prop.entrySet()) { - String vocab = (String) e.getKey(); - String hint = (String) e.getValue(); + for (Map.Entry e : prop.entrySet()) { + String vocab = (String) e.getKey(); + String hint = (String) e.getValue(); - vocabList.add(new Vocab(vocab, hint)); - } - return vocabList; - } + vocabList.add(new Vocab(vocab, hint)); + } + return vocabList; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/StartHangmanAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/StartHangmanAction.java index 4c8aed099..a38b10954 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/StartHangmanAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/StartHangmanAction.java @@ -20,42 +20,41 @@ */ package org.apache.struts2.showcase.hangman; -import static org.apache.struts2.showcase.hangman.HangmanConstants.HANGMAN_SESSION_KEY; +import com.opensymphony.xwork2.ActionSupport; +import org.apache.struts2.interceptor.SessionAware; import java.util.Map; -import org.apache.struts2.interceptor.SessionAware; - -import com.opensymphony.xwork2.ActionSupport; +import static org.apache.struts2.showcase.hangman.HangmanConstants.HANGMAN_SESSION_KEY; public class StartHangmanAction extends ActionSupport implements SessionAware { - private static final long serialVersionUID = 2333463075324892521L; + private static final long serialVersionUID = 2333463075324892521L; - private HangmanService service; - private Hangman hangman; - private Map session; + private HangmanService service; + private Hangman hangman; + private Map session; - public StartHangmanAction(HangmanService service) { - this.service = service; - } + public StartHangmanAction(HangmanService service) { + this.service = service; + } - public String execute() throws Exception { + public String execute() throws Exception { - hangman = service.startNewGame(); - session.put(HANGMAN_SESSION_KEY, hangman); + hangman = service.startNewGame(); + session.put(HANGMAN_SESSION_KEY, hangman); - return SUCCESS; - } + return SUCCESS; + } - public Hangman getHangman() { - return hangman; - } + public Hangman getHangman() { + return hangman; + } - // === SessionAware === - public void setSession(Map session) { - this.session = session; - } + // === SessionAware === + public void setSession(Map session) { + this.session = session; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/Vocab.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/Vocab.java index da1cf1541..80f8b470d 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/Vocab.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/Vocab.java @@ -27,60 +27,65 @@ import java.util.List; public class Vocab implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private String vocab; - private String hint; - private Character[] characters; // character this vocab is made up of + private String vocab; + private String hint; + private Character[] characters; // character this vocab is made up of - public Vocab(String vocab, String hint) { - assert(vocab != null); - assert(hint != null); + public Vocab(String vocab, String hint) { + assert (vocab != null); + assert (hint != null); - this.vocab = vocab.toUpperCase(); - this.hint = hint; - } + this.vocab = vocab.toUpperCase(); + this.hint = hint; + } - public String getVocab() { return this.vocab; } - public String getHint() { return this.hint; } + public String getVocab() { + return this.vocab; + } - public Boolean containCharacter(Character character) { - assert(character != null); + public String getHint() { + return this.hint; + } - return (vocab.contains(character.toString())) ? true : false; - } + public Boolean containCharacter(Character character) { + assert (character != null); - public Character[] inCharacters() { - if (characters == null) { - char[] c = vocab.toCharArray(); - characters = new Character[c.length]; - for (int a=0; a< c.length; a++) { - characters[a] = Character.valueOf(c[a]); - } - } - return characters; - } + return (vocab.contains(character.toString())) ? true : false; + } - public boolean containsAllCharacter(List charactersGuessed) { - Character[] chars = inCharacters(); - List tmpChars = Arrays.asList(chars); - return charactersGuessed.containsAll(tmpChars); - } + public Character[] inCharacters() { + if (characters == null) { + char[] c = vocab.toCharArray(); + characters = new Character[c.length]; + for (int a = 0; a < c.length; a++) { + characters[a] = Character.valueOf(c[a]); + } + } + return characters; + } - public static void main(String args[]) throws Exception { - Vocab v = new Vocab("JAVA", "a java word"); + public boolean containsAllCharacter(List charactersGuessed) { + Character[] chars = inCharacters(); + List tmpChars = Arrays.asList(chars); + return charactersGuessed.containsAll(tmpChars); + } - List list1= new ArrayList(); - list1.add(new Character('J')); - list1.add(new Character('V')); + public static void main(String args[]) throws Exception { + Vocab v = new Vocab("JAVA", "a java word"); - List list2 = new ArrayList(); - list2.add(new Character('J')); - list2.add(new Character('V')); - list2.add(new Character('A')); + List list1 = new ArrayList(); + list1.add(new Character('J')); + list1.add(new Character('V')); - System.out.println(v.containsAllCharacter(list1)); - System.out.println(v.containsAllCharacter(list2)); + List list2 = new ArrayList(); + list2.add(new Character('J')); + list2.add(new Character('V')); + list2.add(new Character('A')); - } + System.out.println(v.containsAllCharacter(list1)); + System.out.println(v.containsAllCharacter(list2)); + + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/VocabSource.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/VocabSource.java index b2d64a6a3..8caff3838 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/VocabSource.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/VocabSource.java @@ -21,5 +21,5 @@ package org.apache.struts2.showcase.hangman; public interface VocabSource { - Vocab getRandomVocab(); + Vocab getRandomVocab(); } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/EditGangsterAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/EditGangsterAction.java index d90b67547..f4610b224 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/EditGangsterAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/EditGangsterAction.java @@ -20,25 +20,25 @@ */ package org.apache.struts2.showcase.integration; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + public class EditGangsterAction extends Action { - /* (non-Javadoc) - * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - @Override - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { - // Some code to load the gangster from the db as necessary + /* (non-Javadoc) + * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + // Some code to load the gangster from the db as necessary - return mapping.findForward("success"); - } + return mapping.findForward("success"); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/GangsterForm.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/GangsterForm.java index 5bb5c4142..87047411f 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/GangsterForm.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/GangsterForm.java @@ -20,89 +20,96 @@ */ package org.apache.struts2.showcase.integration; -import javax.servlet.http.HttpServletRequest; - import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.validator.ValidatorForm; +import javax.servlet.http.HttpServletRequest; + public class GangsterForm extends ValidatorForm { - private String name; - private String age; - private String description; - private boolean bustedBefore; + private String name; + private String age; + private String description; + private boolean bustedBefore; - /* (non-Javadoc) - * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest) - */ - @Override - public void reset(ActionMapping arg0, HttpServletRequest arg1) { - bustedBefore = false; - } + /* (non-Javadoc) + * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest) + */ + @Override + public void reset(ActionMapping arg0, HttpServletRequest arg1) { + bustedBefore = false; + } - /* (non-Javadoc) - * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest) - */ - @Override - public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { - ActionErrors errors = super.validate(mapping, request); - if (name == null || name.length() == 0) { - errors.add("name", new ActionMessage("The name must not be blank")); - } + /* (non-Javadoc) + * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest) + */ + @Override + public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { + ActionErrors errors = super.validate(mapping, request); + if (name == null || name.length() == 0) { + errors.add("name", new ActionMessage("The name must not be blank")); + } - return errors; - } + return errors; + } - /** - * @return the age - */ - public String getAge() { - return age; - } - /** - * @param age the age to set - */ - public void setAge(String age) { - this.age = age; - } - /** - * @return the bustedBefore - */ - public boolean isBustedBefore() { - return bustedBefore; - } - /** - * @param bustedBefore the bustedBefore to set - */ - public void setBustedBefore(boolean bustedBefore) { - this.bustedBefore = bustedBefore; - } - /** - * @return the description - */ - public String getDescription() { - return description; - } - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - /** - * @return the name - */ - public String getName() { - return name; - } - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } + /** + * @return the age + */ + public String getAge() { + return age; + } + + /** + * @param age the age to set + */ + public void setAge(String age) { + this.age = age; + } + + /** + * @return the bustedBefore + */ + public boolean isBustedBefore() { + return bustedBefore; + } + + /** + * @param bustedBefore the bustedBefore to set + */ + public void setBustedBefore(boolean bustedBefore) { + this.bustedBefore = bustedBefore; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/SaveGangsterAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/SaveGangsterAction.java index ab68d7e58..afc358728 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/SaveGangsterAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/integration/SaveGangsterAction.java @@ -20,32 +20,27 @@ */ package org.apache.struts2.showcase.integration; +import org.apache.struts.action.*; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.struts.action.Action; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; - public class SaveGangsterAction extends Action { - /* (non-Javadoc) - * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - @Override - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + /* (non-Javadoc) + * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { - // Some code to save the gangster to the db as necessary - GangsterForm gform = (GangsterForm) form; - ActionMessages messages = new ActionMessages(); - messages.add("msg", new ActionMessage("Gangster "+gform.getName()+" added successfully")); - addMessages(request, messages); + // Some code to save the gangster to the db as necessary + GangsterForm gform = (GangsterForm) form; + ActionMessages messages = new ActionMessages(); + messages.add("msg", new ActionMessage("Gangster " + gform.getName() + " added successfully")); + addMessages(request, messages); - return mapping.findForward("success"); - } + return mapping.findForward("success"); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/jsf/JsfEmployeeAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/jsf/JsfEmployeeAction.java index d1bcc234e..0a0387f48 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/jsf/JsfEmployeeAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/jsf/JsfEmployeeAction.java @@ -20,17 +20,13 @@ */ package org.apache.struts2.showcase.jsf; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - import org.apache.struts2.showcase.action.EmployeeAction; import org.apache.struts2.showcase.dao.SkillDao; import org.apache.struts2.showcase.model.Employee; import org.apache.struts2.showcase.model.Skill; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; /** * Overriding the EmployeeAction to main provide getters returning the data in @@ -38,85 +34,82 @@ import org.apache.struts2.showcase.model.Skill; */ public class JsfEmployeeAction extends EmployeeAction { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * Creating a default employee and main skill, since the JSF EL can't handle - * creating new objects as necessary - * - */ - public JsfEmployeeAction() { - Employee e = new Employee(); - e.setMainSkill(new Skill()); - setCurrentEmployee(e); - } + @Autowired + private SkillDao skillDao; - private SkillDao skillDao; + /** + * Creating a default employee and main skill, since the JSF EL can't handle + * creating new objects as necessary + */ + public JsfEmployeeAction() { + Employee e = new Employee(); + e.setMainSkill(new Skill()); + setCurrentEmployee(e); + } - public void setSkillDao(SkillDao skillDao) { - this.skillDao = skillDao; - } - /** - * Returning a List because the JSF dataGrid can't handle a Set for some - * reason - */ - @Override - public Collection getAvailableItems() { - return new ArrayList(super.getAvailableItems()); - } + /** + * Returning a List because the JSF dataGrid can't handle a Set for some + * reason + */ + @Override + public Collection getAvailableItems() { + return new ArrayList(super.getAvailableItems()); + } - /** - * Changing the String array into a Map - */ - public Map getAvailablePositionsAsMap() { - Map map = new LinkedHashMap(); - for (String val : super.getAvailablePositions()) { - map.put(val, val); - } - return map; - } + /** + * Changing the String array into a Map + */ + public Map getAvailablePositionsAsMap() { + Map map = new LinkedHashMap(); + for (String val : super.getAvailablePositions()) { + map.put(val, val); + } + return map; + } - /** - * Converting the list into a map - */ - public Map getAvailableLevelsAsMap() { - Map map = new LinkedHashMap(); - for (Object val : super.getAvailableLevels()) { - map.put(val, val); - } - return map; - } + /** + * Converting the list into a map + */ + public Map getAvailableLevelsAsMap() { + Map map = new LinkedHashMap(); + for (Object val : super.getAvailableLevels()) { + map.put(val, val); + } + return map; + } - /** - * Converting the Skill object list into a map - */ - public Map getAvailableSkills() { - Map map = new HashMap(); - for (Object val : skillDao.findAll()) { - Skill skill = (Skill) val; - map.put(skill.getDescription(), skill.getName()); - } - return map; - } + /** + * Converting the Skill object list into a map + */ + public Map getAvailableSkills() { + Map map = new HashMap(); + for (Object val : skillDao.findAll()) { + Skill skill = (Skill) val; + map.put(skill.getDescription(), skill.getName()); + } + return map; + } - /** - * Gets the selected Skill objects as a list - */ - public List getSelectedSkillsAsList() { - System.out.println("asked for skills"); - List list = new ArrayList(); - List skills = super.getSelectedSkills(); - if (skills != null) { - for (Object val : skills) { - if (val instanceof Skill) { - list.add(((Skill) val).getDescription()); - } else { - Skill skill = skillDao.getSkill((String) val); - list.add(skill.getDescription()); - } - } - } - return list; - } + /** + * Gets the selected Skill objects as a list + */ + public List getSelectedSkillsAsList() { + System.out.println("asked for skills"); + List list = new ArrayList(); + List skills = super.getSelectedSkills(); + if (skills != null) { + for (Object val : skills) { + if (val instanceof Skill) { + list.add(((Skill) val).getDescription()); + } else { + Skill skill = skillDao.getSkill((String) val); + list.add(skill.getDescription()); + } + } + } + return list; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/model/Employee.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/model/Employee.java index ed93b20df..91b6edaac 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/model/Employee.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/model/Employee.java @@ -26,151 +26,150 @@ import java.util.List; /** * Employee. - * */ public class Employee implements IdEntity { - private static final long serialVersionUID = -6226845151026823748L; + private static final long serialVersionUID = -6226845151026823748L; - private Long empId; //textfield w/ conversion - private String firstName; - private String lastName; - private Date birthDate; //datepicker - private Float salary; //textfield w/ conversion - private boolean married; //checkbox - private String position; //combobox - private Skill mainSkill; //select - private List otherSkills; //doubleSelect - private String password; //password - private String level; //radio - private String comment; //textarea + private Long empId; //textfield w/ conversion + private String firstName; + private String lastName; + private Date birthDate; //datepicker + private Float salary; //textfield w/ conversion + private boolean married; //checkbox + private String position; //combobox + private Skill mainSkill; //select + private List otherSkills; //doubleSelect + private String password; //password + private String level; //radio + private String comment; //textarea - public Employee() { - } + public Employee() { + } - public Employee(Long empId, String firstName, String lastName) { - this.empId = empId; - this.firstName = firstName; - this.lastName = lastName; - } + public Employee(Long empId, String firstName, String lastName) { + this.empId = empId; + this.firstName = firstName; + this.lastName = lastName; + } - public Employee(Long empId, String firstName, String lastName, Date birthDate, Float salary, boolean married, String position, Skill mainSkill, List otherSkills, String password, String level, String comment) { - this.empId = empId; - this.firstName = firstName; - this.lastName = lastName; - this.birthDate = birthDate; - this.salary = salary; - this.married = married; - this.position = position; - this.mainSkill = mainSkill; - this.otherSkills = otherSkills; - this.password = password; - this.level = level; - this.comment = comment; - } + public Employee(Long empId, String firstName, String lastName, Date birthDate, Float salary, boolean married, String position, Skill mainSkill, List otherSkills, String password, String level, String comment) { + this.empId = empId; + this.firstName = firstName; + this.lastName = lastName; + this.birthDate = birthDate; + this.salary = salary; + this.married = married; + this.position = position; + this.mainSkill = mainSkill; + this.otherSkills = otherSkills; + this.password = password; + this.level = level; + this.comment = comment; + } - public Long getEmpId() { - return empId; - } + public Long getEmpId() { + return empId; + } - public void setEmpId(Long empId) { - this.empId = empId; - } + public void setEmpId(Long empId) { + this.empId = empId; + } - public Serializable getId() { - return getEmpId(); - } + public Serializable getId() { + return getEmpId(); + } - public void setId(Serializable id) { - setEmpId((Long) id); - } + public void setId(Serializable id) { + setEmpId((Long) id); + } - public String getFirstName() { - return firstName; - } + public String getFirstName() { + return firstName; + } - public void setFirstName(String firstName) { - this.firstName = firstName; - } + public void setFirstName(String firstName) { + this.firstName = firstName; + } - public String getLastName() { - return lastName; - } + public String getLastName() { + return lastName; + } - public void setLastName(String lastName) { - this.lastName = lastName; - } + public void setLastName(String lastName) { + this.lastName = lastName; + } - public Date getBirthDate() { - return birthDate; - } + public Date getBirthDate() { + return birthDate; + } - public void setBirthDate(Date birthDate) { - this.birthDate = birthDate; - } + public void setBirthDate(Date birthDate) { + this.birthDate = birthDate; + } - public Float getSalary() { - return salary; - } + public Float getSalary() { + return salary; + } - public void setSalary(Float salary) { - this.salary = salary; - } + public void setSalary(Float salary) { + this.salary = salary; + } - public boolean isMarried() { - return married; - } + public boolean isMarried() { + return married; + } - public void setMarried(boolean married) { - this.married = married; - } + public void setMarried(boolean married) { + this.married = married; + } - public String getPosition() { - return position; - } + public String getPosition() { + return position; + } - public void setPosition(String position) { - this.position = position; - } + public void setPosition(String position) { + this.position = position; + } - public Skill getMainSkill() { - return mainSkill; - } + public Skill getMainSkill() { + return mainSkill; + } - public void setMainSkill(Skill mainSkill) { - this.mainSkill = mainSkill; - } + public void setMainSkill(Skill mainSkill) { + this.mainSkill = mainSkill; + } - public List getOtherSkills() { - return otherSkills; - } + public List getOtherSkills() { + return otherSkills; + } - public void setOtherSkills(List otherSkills) { - this.otherSkills = otherSkills; - } + public void setOtherSkills(List otherSkills) { + this.otherSkills = otherSkills; + } - public String getPassword() { - return password; - } + public String getPassword() { + return password; + } - public void setPassword(String password) { - this.password = password; - } + public void setPassword(String password) { + this.password = password; + } - public String getLevel() { - return level; - } + public String getLevel() { + return level; + } - public void setLevel(String level) { - this.level = level; - } + public void setLevel(String level) { + this.level = level; + } - public String getComment() { - return comment; - } + public String getComment() { + return comment; + } - public void setComment(String comment) { - this.comment = comment; - } + public void setComment(String comment) { + this.comment = comment; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/model/IdEntity.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/model/IdEntity.java index 9e1353803..aecfea909 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/model/IdEntity.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/model/IdEntity.java @@ -24,13 +24,12 @@ import java.io.Serializable; /** * IdEntity. Interface. - * */ public interface IdEntity extends Serializable { - Serializable getId (); + Serializable getId(); - void setId ( Serializable id ); + void setId(Serializable id); } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/model/Skill.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/model/Skill.java index 1f2d831d1..111d90021 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/model/Skill.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/model/Skill.java @@ -26,49 +26,48 @@ import java.io.Serializable; /** * Skill. - * */ public class Skill implements IdEntity { - private static final long serialVersionUID = -4150317722693212439L; + private static final long serialVersionUID = -4150317722693212439L; - private String name; - private String description; + private String name; + private String description; - public Skill() { - } + public Skill() { + } - public Skill(String name, String description) { - this.name = name; - this.description = description; - } + public Skill(String name, String description) { + this.name = name; + this.description = description; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4(name)); - } + public void setName(String name) { + this.name = StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4(name)); + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4(description)); - } + public void setDescription(String description) { + this.description = StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4(description)); + } - public Serializable getId() { - return getName(); - } + public Serializable getId() { + return getName(); + } - public void setId(Serializable id) { - setName((String) id); - } + public void setId(Serializable id) { + setName((String) id); + } - public String toString() { - return getName(); - } + public String toString() { + return getName(); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/modelDriven/Gangster.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/modelDriven/Gangster.java index aa9591fb6..be2a571bb 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/modelDriven/Gangster.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/modelDriven/Gangster.java @@ -24,39 +24,45 @@ import java.io.Serializable; /** * A model class to be used by the simple Model-Driven example. - * */ public class Gangster implements Serializable { - private static final long serialVersionUID = 3688389475320294992L; + private static final long serialVersionUID = 3688389475320294992L; - private String name; - private int age; - private String description; - private boolean bustedBefore; + private String name; + private int age; + private String description; + private boolean bustedBefore; - public int getAge() { - return age; - } - public void setAge(int age) { - this.age = age; - } - public boolean isBustedBefore() { - return bustedBefore; - } - public void setBustedBefore(boolean bustedBefore) { - this.bustedBefore = bustedBefore; - } - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public boolean isBustedBefore() { + return bustedBefore; + } + + public void setBustedBefore(boolean bustedBefore) { + this.bustedBefore = bustedBefore; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/modelDriven/ModelDrivenAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/modelDriven/ModelDrivenAction.java index 4ab545710..c32cd2003 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/modelDriven/ModelDrivenAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/modelDriven/ModelDrivenAction.java @@ -25,21 +25,20 @@ import com.opensymphony.xwork2.ModelDriven; /** * Action to demonstrate simple model-driven feature of the framework. - * */ public class ModelDrivenAction extends ActionSupport implements ModelDriven { - private static final long serialVersionUID = 1271130427666936592L; + private static final long serialVersionUID = 1271130427666936592L; - public String input() throws Exception { - return SUCCESS; - } + public String input() throws Exception { + return SUCCESS; + } - public String execute() throws Exception { - return SUCCESS; - } + public String execute() throws Exception { + return SUCCESS; + } - public Object getModel() { - return new Gangster(); - } + public Object getModel() { + return new Gangster(); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/EditPersonAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/EditPersonAction.java index 83e03dc5b..4d102f780 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/EditPersonAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/EditPersonAction.java @@ -20,68 +20,59 @@ */ package org.apache.struts2.showcase.person; +import com.opensymphony.xwork2.ActionSupport; +import org.apache.struts2.convention.annotation.Result; +import org.apache.struts2.convention.annotation.Results; +import org.springframework.beans.factory.annotation.Autowired; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.apache.struts2.convention.annotation.ParentPackage; -import org.apache.struts2.convention.annotation.Result; - -import com.opensymphony.xwork2.ActionSupport; -import org.apache.struts2.convention.annotation.Results; - /** * EditPerson - * */ @Results({ - @Result(name="list", location="list-people.action", type="redirect"), - @Result(name="input", location="new-person.ftl", type="freemarker") + @Result(name = "list", location = "list-people.action", type = "redirect"), + @Result(name = "input", location = "edit-person.jsp") }) public class EditPersonAction extends ActionSupport { - private static final long serialVersionUID = 7699491775215130850L; + private static final long serialVersionUID = 7699491775215130850L; - PersonManager personManager; - List persons = new ArrayList(); + @Autowired + private PersonManager personManager; + private List persons = new ArrayList(); - public void setPersonManager(PersonManager personManager) { - this.personManager = personManager; - } + /** + * A default implementation that does nothing an returns "success". + * + * @return {@link #INPUT} + */ + public String execute() throws Exception { + persons.addAll(personManager.getPeople()); + return INPUT; + } - public List getPersons() { - return persons; - } + /** + * A default implementation that does nothing an returns "success". + * + * @return {@link #SUCCESS} + */ + public String save() throws Exception { - public void setPersons(List persons) { - this.persons = persons; - } + for (Person p : persons) { + personManager.getPeople().remove(p); + personManager.getPeople().add(p); + } + return "list"; + } - /** - * A default implementation that does nothing an returns "success". - * - * @return {@link #SUCCESS} - */ - public String execute() throws Exception { - persons.addAll(personManager.getPeople()); - return SUCCESS; - } - - /** - * A default implementation that does nothing an returns "success". - * - * @return {@link #SUCCESS} - */ - public String save() throws Exception { - - // Set people = personManager.getPeople(); - - for ( Iterator iter = persons.iterator(); iter.hasNext();) { - Person p = (Person) iter.next(); - personManager.getPeople().remove(p); - personManager.getPeople().add(p); - } - return "list"; - } + public List getPersons() { + return persons; + } + public void setPersons(List persons) { + this.persons = persons; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/ListPeopleAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/ListPeopleAction.java index c77438c43..e64c199d6 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/ListPeopleAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/ListPeopleAction.java @@ -20,37 +20,35 @@ */ package org.apache.struts2.showcase.person; +import com.opensymphony.xwork2.ActionSupport; +import org.apache.struts2.convention.annotation.Result; +import org.springframework.beans.factory.annotation.Autowired; + import java.util.ArrayList; import java.util.List; -import com.opensymphony.xwork2.ActionSupport; -import org.apache.struts2.convention.annotation.ParentPackage; -import org.apache.struts2.convention.annotation.Result; - -@Result(location="list-people.ftl", type="freemarker") +@Result(location = "list-people.ftl", type = "freemarker") public class ListPeopleAction extends ActionSupport { - private static final long serialVersionUID = 3608017189783645371L; + private static final long serialVersionUID = 3608017189783645371L; - PersonManager personManager; - List people = new ArrayList(); + @Autowired + private PersonManager personManager; - public void setPersonManager(PersonManager personManager) { - this.personManager = personManager; - } + private List people = new ArrayList(); - public String execute() { - people.addAll(personManager.getPeople()); + public String execute() { + people.addAll(personManager.getPeople()); - return SUCCESS; - } + return SUCCESS; + } - public List getPeople() { - return people; - } + public List getPeople() { + return people; + } - public int getPeopleCount() { - return people.size(); - } + public int getPeopleCount() { + return people.size(); + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/NewPersonAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/NewPersonAction.java index fedb22d31..eb07bd721 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/NewPersonAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/NewPersonAction.java @@ -20,35 +20,35 @@ */ package org.apache.struts2.showcase.person; -import org.apache.struts2.convention.annotation.ParentPackage; -import org.apache.struts2.convention.annotation.Result; -import org.apache.struts2.views.freemarker.FreemarkerResult; - import com.opensymphony.xwork2.ActionSupport; +import org.apache.struts2.convention.annotation.Result; +import org.apache.struts2.convention.annotation.Results; +import org.springframework.beans.factory.annotation.Autowired; -@Result(name="input", location="new-person.ftl", type="freemarker") + +@Results({ + @Result(name = "list", location = "list-people.action", type = "redirect"), + @Result(name = "input", location = "new-person.ftl", type = "freemarker") +}) public class NewPersonAction extends ActionSupport { - private static final long serialVersionUID = 200410824352645515L; + private static final long serialVersionUID = 200410824352645515L; - PersonManager personManager; - Person person; + @Autowired + private PersonManager personManager; + private Person person; - public void setPersonManager(PersonManager personManager) { - this.personManager = personManager; - } + public String execute() { + personManager.createPerson(person); - public String execute() { - personManager.createPerson(person); + return "list"; + } - return SUCCESS; - } + public Person getPerson() { + return person; + } - public Person getPerson() { - return person; - } - - public void setPerson(Person person) { - this.person = person; - } + public void setPerson(Person person) { + this.person = person; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/Person.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/Person.java index 440966a45..66ff6156f 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/Person.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/Person.java @@ -20,67 +20,65 @@ */ package org.apache.struts2.showcase.person; -/** - */ public class Person { - Long id; - String name; - String lastName; + private Long id; + private String name; + private String lastName; - public Person() { - } + public Person() { + } - public Person(Long id, String name, String lastName) { - this.id = id; - this.name = name; - this.lastName = lastName; - } + public Person(Long id, String name, String lastName) { + this.id = id; + this.name = name; + this.lastName = lastName; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getLastName() { - return lastName; - } + public String getLastName() { + return lastName; + } - public void setLastName(String lastName) { - this.lastName = lastName; - } + public void setLastName(String lastName) { + this.lastName = lastName; + } - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - final Person person = (Person) o; + final Person person = (Person) o; - if (id != null ? !id.equals(person.id) : person.id != null) return false; + if (id != null ? !id.equals(person.id) : person.id != null) return false; - return true; - } + return true; + } - public int hashCode() { - return (id != null ? id.hashCode() : 0); - } + public int hashCode() { + return (id != null ? id.hashCode() : 0); + } - public String toString() { - return "Person{" + - "id=" + id + - ", name='" + name + '\'' + - ", lastName='" + lastName + '\'' + - '}'; - } + public String toString() { + return "Person{" + + "id=" + id + + ", name='" + name + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/PersonManager.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/PersonManager.java index cf7e28c28..0b37f3ad8 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/PersonManager.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/PersonManager.java @@ -20,39 +20,40 @@ */ package org.apache.struts2.showcase.person; +import org.springframework.stereotype.Service; + import java.util.HashSet; import java.util.Set; -/** - */ +@Service public class PersonManager { - private static Set people = new HashSet(5); - private static long COUNT = 5; + private static Set people = new HashSet(5); + private static long COUNT = 5; - static { - // create some imaginary persons - Person p1 = new Person(new Long(1), "Patrick", "Lightbuddie"); - Person p2 = new Person(new Long(2), "Jason", "Carrora"); - Person p3 = new Person(new Long(3), "Alexandru", "Papesco"); - Person p4 = new Person(new Long(4), "Jay", "Boss"); - Person p5 = new Person(new Long(5), "Rainer", "Hermanos"); - people.add(p1); - people.add(p2); - people.add(p3); - people.add(p4); - people.add(p5); - } + static { + // create some imaginary persons + Person p1 = new Person(new Long(1), "Patrick", "Lightbuddie"); + Person p2 = new Person(new Long(2), "Jason", "Carrora"); + Person p3 = new Person(new Long(3), "Alexandru", "Papesco"); + Person p4 = new Person(new Long(4), "Jay", "Boss"); + Person p5 = new Person(new Long(5), "Rainer", "Hermanos"); + people.add(p1); + people.add(p2); + people.add(p3); + people.add(p4); + people.add(p5); + } - public void createPerson(Person person) { - person.setId(new Long(++COUNT)); - people.add(person); - } + public void createPerson(Person person) { + person.setId(new Long(++COUNT)); + people.add(person); + } - public void updatePerson(Person person) { - people.add(person); - } + public void updatePerson(Person person) { + people.add(person); + } - public Set getPeople() { - return people; - } + public Set getPeople() { + return people; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/package-info.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/package-info.java index 6127e603b..c21b7a84d 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/person/package-info.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/person/package-info.java @@ -1,6 +1,5 @@ @ParentPackage("person") -@Namespace("/person") -package org.apache.struts2.showcase.person; +@Namespace("/person") package org.apache.struts2.showcase.person; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.ParentPackage; diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java index ac829441e..3b71fa68e 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java @@ -20,6 +20,12 @@ */ package org.apache.struts2.showcase.source; +import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.util.ClassLoaderUtil; +import org.apache.struts2.ServletActionContext; +import org.apache.struts2.util.ServletContextAware; + +import javax.servlet.ServletContext; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -29,211 +35,201 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; - -import org.apache.struts2.ServletActionContext; -import org.apache.struts2.util.ServletContextAware; - -import com.opensymphony.xwork2.ActionSupport; -import com.opensymphony.xwork2.util.ClassLoaderUtil; - /** * Processes configuration, page, and action class paths to create snippets * of the files for display. */ public class ViewSourceAction extends ActionSupport implements ServletContextAware { - private String page; - private String className; - private String config; + private String page; + private String className; + private String config; - private List pageLines; - private List classLines; - private List configLines; + private List pageLines; + private List classLines; + private List configLines; - private int configLine; - private int padding = 10; + private int configLine; + private int padding = 10; - private ServletContext servletContext; + private ServletContext servletContext; - public String execute() throws MalformedURLException, IOException { + public String execute() throws MalformedURLException, IOException { - if (page != null) { + if (page != null) { - InputStream in = ClassLoaderUtil.getResourceAsStream(page.substring(page.indexOf("//")+1), getClass()); - page = page.replace("//", "/"); + InputStream in = ClassLoaderUtil.getResourceAsStream(page.substring(page.indexOf("//") + 1), getClass()); + page = page.replace("//", "/"); - if (in == null) { - in = servletContext.getResourceAsStream(page); - while (in == null && page.indexOf('/', 1) > 0) { - page = page.substring(page.indexOf('/', 1)); - in = servletContext.getResourceAsStream(page); - } - } - pageLines = read(in, -1); + if (in == null) { + in = servletContext.getResourceAsStream(page); + while (in == null && page.indexOf('/', 1) > 0) { + page = page.substring(page.indexOf('/', 1)); + in = servletContext.getResourceAsStream(page); + } + } + pageLines = read(in, -1); - if (in != null) { - in.close(); - } - } + if (in != null) { + in.close(); + } + } - if (className != null) { - className = "/"+className.replace('.', '/') + ".java"; - InputStream in = getClass().getResourceAsStream(className); - if (in == null) { - in = servletContext.getResourceAsStream("/WEB-INF/src"+className); - } - classLines = read(in, -1); + if (className != null) { + className = "/" + className.replace('.', '/') + ".java"; + InputStream in = getClass().getResourceAsStream(className); + if (in == null) { + in = servletContext.getResourceAsStream("/WEB-INF/src" + className); + } + classLines = read(in, -1); - if (in != null) { - in.close(); - } - } + if (in != null) { + in.close(); + } + } - String rootPath = ServletActionContext.getServletContext().getRealPath("/"); - - if (config != null && (rootPath == null || config.startsWith(rootPath))) { - int pos = config.lastIndexOf(':'); - configLine = Integer.parseInt(config.substring(pos+1)); - config = config.substring(0, pos).replace("//", "/"); - configLines = read(new URL(config).openStream(), configLine); - } - return SUCCESS; - } + String rootPath = ServletActionContext.getServletContext().getRealPath("/"); + + if (config != null && (rootPath == null || config.startsWith(rootPath))) { + int pos = config.lastIndexOf(':'); + configLine = Integer.parseInt(config.substring(pos + 1)); + config = config.substring(0, pos).replace("//", "/"); + configLines = read(new URL(config).openStream(), configLine); + } + return SUCCESS; + } - /** - * @param className the className to set - */ - public void setClassName(String className) { - if (className != null && className.trim().length()>0) { - this.className = className; - } - } + /** + * @param className the className to set + */ + public void setClassName(String className) { + if (className != null && className.trim().length() > 0) { + this.className = className; + } + } - /** - * @param config the config to set - */ - public void setConfig(String config) { - if (config != null && config.trim().length()>0) { - this.config = config; - } - } + /** + * @param config the config to set + */ + public void setConfig(String config) { + if (config != null && config.trim().length() > 0) { + this.config = config; + } + } - /** - * @param page the page to set - */ - public void setPage(String page) { - if (page != null && page.trim().length()>0) { - this.page = page; - } - } + /** + * @param page the page to set + */ + public void setPage(String page) { + if (page != null && page.trim().length() > 0) { + this.page = page; + } + } - /** - * @param padding the padding to set - */ - public void setPadding(int padding) { - this.padding = padding; - } + /** + * @param padding the padding to set + */ + public void setPadding(int padding) { + this.padding = padding; + } + /** + * @return the classLines + */ + public List getClassLines() { + return classLines; + } - /** - * @return the classLines - */ - public List getClassLines() { - return classLines; - } + /** + * @return the configLines + */ + public List getConfigLines() { + return configLines; + } - /** - * @return the configLines - */ - public List getConfigLines() { - return configLines; - } + /** + * @return the pageLines + */ + public List getPageLines() { + return pageLines; + } - /** - * @return the pageLines - */ - public List getPageLines() { - return pageLines; - } + /** + * @return the className + */ + public String getClassName() { + return className; + } - /** - * @return the className - */ - public String getClassName() { - return className; - } + /** + * @return the config + */ + public String getConfig() { + return config; + } - /** - * @return the config - */ - public String getConfig() { - return config; - } + /** + * @return the page + */ + public String getPage() { + return page; + } - /** - * @return the page - */ - public String getPage() { - return page; - } + /** + * @return the configLine + */ + public int getConfigLine() { + return configLine; + } - /** - * @return the configLine - */ - public int getConfigLine() { - return configLine; - } + /** + * @return the padding + */ + public int getPadding() { + return padding; + } - /** - * @return the padding - */ - public int getPadding() { - return padding; - } + /** + * Reads in a strea, optionally only including the target line number + * and its padding + * + * @param in The input stream + * @param targetLineNumber The target line number, negative to read all + * @return A list of lines + */ + private List read(InputStream in, int targetLineNumber) { + List snippet = null; + if (in != null) { + snippet = new ArrayList(); + int startLine = 0; + int endLine = Integer.MAX_VALUE; + if (targetLineNumber > 0) { + startLine = targetLineNumber - padding; + endLine = targetLineNumber + padding; + } + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - /** - * Reads in a strea, optionally only including the target line number - * and its padding - * - * @param in The input stream - * @param targetLineNumber The target line number, negative to read all - * @return A list of lines - */ - private List read(InputStream in, int targetLineNumber) { - List snippet = null; - if (in != null) { - snippet = new ArrayList(); - int startLine = 0; - int endLine = Integer.MAX_VALUE; - if (targetLineNumber > 0) { - startLine = targetLineNumber - padding; - endLine = targetLineNumber + padding; - } - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + int lineno = 0; + String line; + while ((line = reader.readLine()) != null) { + lineno++; + if (lineno >= startLine && lineno <= endLine) { + snippet.add(line); + } + } + } catch (Exception ex) { + // ignoring as snippet not available isn't a big deal + } + } + return snippet; + } - int lineno = 0; - String line; - while ((line = reader.readLine()) != null) { - lineno++; - if (lineno >= startLine && lineno <= endLine) { - snippet.add(line); - } - } - } catch (Exception ex) { - // ignoring as snippet not available isn't a big deal - } - } - return snippet; - } - - public void setServletContext(ServletContext arg0) { - this.servletContext = arg0; - } + public void setServletContext(ServletContext arg0) { + this.servletContext = arg0; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/actionPrefix/SubmitAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/actionPrefix/SubmitAction.java index a8b350c85..7ae6257eb 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/actionPrefix/SubmitAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/actionPrefix/SubmitAction.java @@ -24,19 +24,24 @@ import com.opensymphony.xwork2.ActionSupport; public class SubmitAction extends ActionSupport { - private static final long serialVersionUID = -7832803019378213087L; + private static final long serialVersionUID = -7832803019378213087L; - private String text; + private String text; - public String getText() { return text; } - public void setText(String text) { this.text = text; } + public String getText() { + return text; + } - public String execute() throws Exception { - return SUCCESS; - } + public void setText(String text) { + this.text = text; + } - public String alternateMethod() { - return "methodPrefixResult"; - } + public String execute() throws Exception { + return SUCCESS; + } + + public String alternateMethod() { + return "methodPrefixResult"; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/actiontag/ActionTagDemo.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/actiontag/ActionTagDemo.java index 6de46d258..d39f877a2 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/actiontag/ActionTagDemo.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/actiontag/ActionTagDemo.java @@ -26,13 +26,13 @@ import com.opensymphony.xwork2.ActionSupport; */ public class ActionTagDemo extends ActionSupport { - private static final long serialVersionUID = -2749145880590245184L; + private static final long serialVersionUID = -2749145880590245184L; - public String show() throws Exception { - return SUCCESS; - } + public String show() throws Exception { + return SUCCESS; + } - public String doInclude() throws Exception { - return SUCCESS; - } + public String doInclude() throws Exception { + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/AppendIteratorTagDemo.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/AppendIteratorTagDemo.java index a47ee62a0..f3936a49b 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/AppendIteratorTagDemo.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/AppendIteratorTagDemo.java @@ -28,53 +28,49 @@ import com.opensymphony.xwork2.Validateable; */ public class AppendIteratorTagDemo extends ActionSupport implements Validateable { - private static final long serialVersionUID = -6525059998526094664L; + private static final long serialVersionUID = -6525059998526094664L; - private String iteratorValue1; - private String iteratorValue2; + private String iteratorValue1; + private String iteratorValue2; - public void validate() { - if (iteratorValue1 == null || iteratorValue1.trim().length() <= 0 ) { - addFieldError("iteratorValue1", "iterator value 1 cannot be empty"); - } - else if (iteratorValue1.trim().indexOf(",") <= 0) { - addFieldError("iteratorValue1", "iterator value 1 needs to be comma separated"); - } - if (iteratorValue2 == null || iteratorValue2.trim().length() <= 0) { - addFieldError("iteratorValue2", "iterator value 2 cannot be empty"); - } - else if (iteratorValue2.trim().indexOf(",") <= 0) { - addFieldError("iteratorValue2", "iterator value 2 needs to be comma separated"); - } - } + public void validate() { + if (iteratorValue1 == null || iteratorValue1.trim().length() <= 0) { + addFieldError("iteratorValue1", "iterator value 1 cannot be empty"); + } else if (iteratorValue1.trim().indexOf(",") <= 0) { + addFieldError("iteratorValue1", "iterator value 1 needs to be comma separated"); + } + if (iteratorValue2 == null || iteratorValue2.trim().length() <= 0) { + addFieldError("iteratorValue2", "iterator value 2 cannot be empty"); + } else if (iteratorValue2.trim().indexOf(",") <= 0) { + addFieldError("iteratorValue2", "iterator value 2 needs to be comma separated"); + } + } + public String getIteratorValue1() { + return iteratorValue1; + } + + public void setIteratorValue1(String iteratorValue1) { + this.iteratorValue1 = iteratorValue1; + } - public String getIteratorValue1() { - return iteratorValue1; - } - public void setIteratorValue1(String iteratorValue1) { - this.iteratorValue1 = iteratorValue1; - } + public String getIteratorValue2() { + return iteratorValue2; + } + + public void setIteratorValue2(String iteratorValue2) { + this.iteratorValue2 = iteratorValue2; + } + public String input() throws Exception { + return SUCCESS; + } - public String getIteratorValue2() { - return iteratorValue2; - } - public void setIteratorValue2(String iteratorValue2) { - this.iteratorValue2 = iteratorValue2; - } - - - - public String input() throws Exception { - return SUCCESS; - } - - public String submit() throws Exception { - return SUCCESS; - } + public String submit() throws Exception { + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/IteratorGeneratorTagDemo.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/IteratorGeneratorTagDemo.java index f4b74fd2a..0e48519bd 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/IteratorGeneratorTagDemo.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/IteratorGeneratorTagDemo.java @@ -26,44 +26,46 @@ import com.opensymphony.xwork2.ActionSupport; */ public class IteratorGeneratorTagDemo extends ActionSupport { - private static final long serialVersionUID = 6893616642389337039L; + private static final long serialVersionUID = 6893616642389337039L; - private String value; - private Integer count; - private String separator; + private String value; + private Integer count; + private String separator; - public String getValue() { - return value; - } - public void setValue(String value) { - this.value = value; - } + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } - public Integer getCount() { - return count; - } - public void setCount(Integer count) { - this.count = count; - } + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + public String getSeparator() { + return this.separator; + } - public String getSeparator() { - return this.separator; - } - public void setSeparator(String separator) { - this.separator = separator; - } + public void setSeparator(String separator) { + this.separator = separator; + } - public String submit() throws Exception { - return SUCCESS; - } + public String submit() throws Exception { + return SUCCESS; + } - public String input() throws Exception { - return SUCCESS; - } + public String input() throws Exception { + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/MergeIteratorTagDemo.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/MergeIteratorTagDemo.java index 64dbe87b1..cc8fa28de 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/MergeIteratorTagDemo.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/MergeIteratorTagDemo.java @@ -28,54 +28,49 @@ import com.opensymphony.xwork2.Validateable; */ public class MergeIteratorTagDemo extends ActionSupport implements Validateable { - private static final long serialVersionUID = 4401107963952961695L; + private static final long serialVersionUID = 4401107963952961695L; - private String iteratorValue1; - private String iteratorValue2; + private String iteratorValue1; + private String iteratorValue2; - public void validate() { - if (iteratorValue1 == null || iteratorValue1.trim().length() <= 0 ) { - addFieldError("iteratorValue1", "iterator value 1 cannot be empty"); - } - else if (iteratorValue1.trim().indexOf(",") <= 0) { - addFieldError("iteratorValue1", "iterator value 1 needs to be comma separated"); - } - if (iteratorValue2 == null || iteratorValue2.trim().length() <= 0) { - addFieldError("iteratorValue2", "iterator value 2 cannot be empty"); - } - else if (iteratorValue2.trim().indexOf(",") <= 0) { - addFieldError("iteratorValue2", "iterator value 2 needs to be comma separated"); - } - } + public void validate() { + if (iteratorValue1 == null || iteratorValue1.trim().length() <= 0) { + addFieldError("iteratorValue1", "iterator value 1 cannot be empty"); + } else if (iteratorValue1.trim().indexOf(",") <= 0) { + addFieldError("iteratorValue1", "iterator value 1 needs to be comma separated"); + } + if (iteratorValue2 == null || iteratorValue2.trim().length() <= 0) { + addFieldError("iteratorValue2", "iterator value 2 cannot be empty"); + } else if (iteratorValue2.trim().indexOf(",") <= 0) { + addFieldError("iteratorValue2", "iterator value 2 needs to be comma separated"); + } + } + public String getIteratorValue1() { + return this.iteratorValue1; + } - public String getIteratorValue1() { - return this.iteratorValue1; - } - public void setIteratorValue1(String iteratorValue1) { - this.iteratorValue1 = iteratorValue1; - } + public void setIteratorValue1(String iteratorValue1) { + this.iteratorValue1 = iteratorValue1; + } + public String getIteratorValue2() { + return this.iteratorValue2; + } - public String getIteratorValue2() { - return this.iteratorValue2; - } - public void setIteratorValue2(String iteratorValue2) { - this.iteratorValue2 = iteratorValue2; - } + public void setIteratorValue2(String iteratorValue2) { + this.iteratorValue2 = iteratorValue2; + } + public String input() throws Exception { + return SUCCESS; + } - - - public String input() throws Exception { - return SUCCESS; - } - - public String submit() throws Exception { - return SUCCESS; - } + public String submit() throws Exception { + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/SubsetIteratorTagDemo.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/SubsetIteratorTagDemo.java index c4002e908..11b221137 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/SubsetIteratorTagDemo.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tag/nonui/iteratortag/SubsetIteratorTagDemo.java @@ -28,61 +28,56 @@ import com.opensymphony.xwork2.Validateable; */ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable { - private static final long serialVersionUID = -8151855954644052650L; + private static final long serialVersionUID = -8151855954644052650L; - private String iteratorValue; - private Integer count; - private Integer start; + private String iteratorValue; + private Integer count; + private Integer start; - public void validate() { - if (iteratorValue == null || iteratorValue.trim().length() <= 0 ) { - addFieldError("iteratorValue1", "iterator value 1 cannot be empty"); - } - else if (iteratorValue.trim().indexOf(",") <= 0) { - addFieldError("iteratorValue1", "iterator value 1 needs to be comma separated"); - } - } + public void validate() { + if (iteratorValue == null || iteratorValue.trim().length() <= 0) { + addFieldError("iteratorValue1", "iterator value 1 cannot be empty"); + } else if (iteratorValue.trim().indexOf(",") <= 0) { + addFieldError("iteratorValue1", "iterator value 1 needs to be comma separated"); + } + } + public String getIteratorValue() { + return this.iteratorValue; + } - public String getIteratorValue() { - return this.iteratorValue; - } - public void setIteratorValue(String iteratorValue) { - this.iteratorValue = iteratorValue; - } + public void setIteratorValue(String iteratorValue) { + this.iteratorValue = iteratorValue; + } + public Integer getCount() { + return this.count; + } - public Integer getCount() { - return this.count; - } - public void setCount(Integer count) { - this.count = count; - } + public void setCount(Integer count) { + this.count = count; + } + public Integer getStart() { + return this.start; + } - public Integer getStart() { - return this.start; - } - public void setStart(Integer start) { - this.start = start; - } + public void setStart(Integer start) { + this.start = start; + } + public String input() throws Exception { + return SUCCESS; + } - - - public String input() throws Exception { - return SUCCESS; - } - - public String submit() throws Exception { - return SUCCESS; - } - + public String submit() throws Exception { + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/token/TokenAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/token/TokenAction.java index 9d0aa8984..680fde649 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/token/TokenAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/token/TokenAction.java @@ -20,65 +20,64 @@ */ package org.apache.struts2.showcase.token; -import java.util.Date; - import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; +import java.util.Date; + /** * Example to illustrate the token and tokenSession interceptor. - * */ public class TokenAction extends ActionSupport { - private static final long serialVersionUID = 616150375751184884L; + private static final long serialVersionUID = 616150375751184884L; - private int amount; + private int amount; - public String execute() throws Exception { - // transfer from source to destination + public String execute() throws Exception { + // transfer from source to destination - Integer balSource = (Integer) ActionContext.getContext().getSession().get("balanceSource"); - Integer balDest = (Integer) ActionContext.getContext().getSession().get("balanceDestination"); + Integer balSource = (Integer) ActionContext.getContext().getSession().get("balanceSource"); + Integer balDest = (Integer) ActionContext.getContext().getSession().get("balanceDestination"); - Integer newSource = new Integer(balSource.intValue() - amount); - Integer newDest = new Integer(balDest.intValue() + amount); + Integer newSource = new Integer(balSource.intValue() - amount); + Integer newDest = new Integer(balDest.intValue() + amount); - ActionContext.getContext().getSession().put("balanceSource", newSource); - ActionContext.getContext().getSession().put("balanceDestination", newDest); - ActionContext.getContext().getSession().put("time", new Date()); + ActionContext.getContext().getSession().put("balanceSource", newSource); + ActionContext.getContext().getSession().put("balanceDestination", newDest); + ActionContext.getContext().getSession().put("time", new Date()); - Thread.sleep(2000); // to simulate processing time + Thread.sleep(2000); // to simulate processing time - return SUCCESS; - } + return SUCCESS; + } - public String input() throws Exception { - // prepare input form - Integer balSource = (Integer) ActionContext.getContext().getSession().get("balanceSource"); - Integer balDest = (Integer) ActionContext.getContext().getSession().get("balanceDestination"); + public String input() throws Exception { + // prepare input form + Integer balSource = (Integer) ActionContext.getContext().getSession().get("balanceSource"); + Integer balDest = (Integer) ActionContext.getContext().getSession().get("balanceDestination"); - if (balSource == null) { - // first time set up an initial account balance - balSource = new Integer(1200); - ActionContext.getContext().getSession().put("balanceSource", balSource); - } + if (balSource == null) { + // first time set up an initial account balance + balSource = new Integer(1200); + ActionContext.getContext().getSession().put("balanceSource", balSource); + } - if (balDest == null) { - // first time set up an initial account balance - balDest = new Integer(2500); - ActionContext.getContext().getSession().put("balanceDestination", balDest); - } + if (balDest == null) { + // first time set up an initial account balance + balDest = new Integer(2500); + ActionContext.getContext().getSession().put("balanceDestination", balDest); + } - return INPUT; - } + return INPUT; + } - public int getAmount() { - return amount; - } + public int getAmount() { + return amount; + } - public void setAmount(int amount) { - this.amount = amount; - } + public void setAmount(int amount) { + this.amount = amount; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AbstractValidationActionSupport.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AbstractValidationActionSupport.java index 346745d3d..9e04cd094 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AbstractValidationActionSupport.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AbstractValidationActionSupport.java @@ -26,11 +26,11 @@ import com.opensymphony.xwork2.ActionSupport; */ public abstract class AbstractValidationActionSupport extends ActionSupport { - public String submit() throws Exception { - return "success"; - } + public String submit() throws Exception { + return "success"; + } - public String input() throws Exception { - return "input"; - } + public String input() throws Exception { + return "input"; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/FieldValidatorsExampleAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/FieldValidatorsExampleAction.java index e1c4c41bf..ccdaa277f 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/FieldValidatorsExampleAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/FieldValidatorsExampleAction.java @@ -29,77 +29,91 @@ import java.sql.Date; public class FieldValidatorsExampleAction extends AbstractValidationActionSupport { - private static final long serialVersionUID = -4829381083003175423L; + private static final long serialVersionUID = -4829381083003175423L; - private String requiredValidatorField = null; - private String requiredStringValidatorField = null; - private Integer integerValidatorField = null; - private Date dateValidatorField = null; - private String emailValidatorField = null; - private String urlValidatorField = null; - private String stringLengthValidatorField = null; - private String regexValidatorField = null; - private String fieldExpressionValidatorField = null; + private String requiredValidatorField = null; + private String requiredStringValidatorField = null; + private Integer integerValidatorField = null; + private Date dateValidatorField = null; + private String emailValidatorField = null; + private String urlValidatorField = null; + private String stringLengthValidatorField = null; + private String regexValidatorField = null; + private String fieldExpressionValidatorField = null; + public Date getDateValidatorField() { + return dateValidatorField; + } - public Date getDateValidatorField() { - return dateValidatorField; - } - public void setDateValidatorField(Date dateValidatorField) { - this.dateValidatorField = dateValidatorField; - } - public String getEmailValidatorField() { - return emailValidatorField; - } - public void setEmailValidatorField(String emailValidatorField) { - this.emailValidatorField = emailValidatorField; - } - public Integer getIntegerValidatorField() { - return integerValidatorField; - } - public void setIntegerValidatorField(Integer integerValidatorField) { - this.integerValidatorField = integerValidatorField; - } - public String getRegexValidatorField() { - return regexValidatorField; - } - public void setRegexValidatorField(String regexValidatorField) { - this.regexValidatorField = regexValidatorField; - } - public String getRequiredStringValidatorField() { - return requiredStringValidatorField; - } - public void setRequiredStringValidatorField(String requiredStringValidatorField) { - this.requiredStringValidatorField = requiredStringValidatorField; - } - public String getRequiredValidatorField() { - return requiredValidatorField; - } - public void setRequiredValidatorField(String requiredValidatorField) { - this.requiredValidatorField = requiredValidatorField; - } - public String getStringLengthValidatorField() { - return stringLengthValidatorField; - } - public void setStringLengthValidatorField(String stringLengthValidatorField) { - this.stringLengthValidatorField = stringLengthValidatorField; - } - public String getFieldExpressionValidatorField() { - return fieldExpressionValidatorField; - } - public void setFieldExpressionValidatorField( - String fieldExpressionValidatorField) { - this.fieldExpressionValidatorField = fieldExpressionValidatorField; - } + public void setDateValidatorField(Date dateValidatorField) { + this.dateValidatorField = dateValidatorField; + } - public String getUrlValidatorField() { - return urlValidatorField; - } + public String getEmailValidatorField() { + return emailValidatorField; + } - public void setUrlValidatorField(String urlValidatorField) { - this.urlValidatorField = urlValidatorField; - } + public void setEmailValidatorField(String emailValidatorField) { + this.emailValidatorField = emailValidatorField; + } + + public Integer getIntegerValidatorField() { + return integerValidatorField; + } + + public void setIntegerValidatorField(Integer integerValidatorField) { + this.integerValidatorField = integerValidatorField; + } + + public String getRegexValidatorField() { + return regexValidatorField; + } + + public void setRegexValidatorField(String regexValidatorField) { + this.regexValidatorField = regexValidatorField; + } + + public String getRequiredStringValidatorField() { + return requiredStringValidatorField; + } + + public void setRequiredStringValidatorField(String requiredStringValidatorField) { + this.requiredStringValidatorField = requiredStringValidatorField; + } + + public String getRequiredValidatorField() { + return requiredValidatorField; + } + + public void setRequiredValidatorField(String requiredValidatorField) { + this.requiredValidatorField = requiredValidatorField; + } + + public String getStringLengthValidatorField() { + return stringLengthValidatorField; + } + + public void setStringLengthValidatorField(String stringLengthValidatorField) { + this.stringLengthValidatorField = stringLengthValidatorField; + } + + public String getFieldExpressionValidatorField() { + return fieldExpressionValidatorField; + } + + public void setFieldExpressionValidatorField( + String fieldExpressionValidatorField) { + this.fieldExpressionValidatorField = fieldExpressionValidatorField; + } + + public String getUrlValidatorField() { + return urlValidatorField; + } + + public void setUrlValidatorField(String urlValidatorField) { + this.urlValidatorField = urlValidatorField; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction.java index 447b17c79..2b16d9b76 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction.java @@ -27,30 +27,35 @@ package org.apache.struts2.showcase.validation; public class NonFieldValidatorsExampleAction extends AbstractValidationActionSupport { - private static final long serialVersionUID = -524460368233581186L; + private static final long serialVersionUID = -524460368233581186L; - private String someText; - private String someTextRetype; - private String someTextRetypeAgain; + private String someText; + private String someTextRetype; + private String someTextRetypeAgain; - public String getSomeText() { - return someText; - } - public void setSomeText(String someText) { - this.someText = someText; - } - public String getSomeTextRetype() { - return someTextRetype; - } - public void setSomeTextRetype(String someTextRetype) { - this.someTextRetype = someTextRetype; - } - public String getSomeTextRetypeAgain() { - return someTextRetypeAgain; - } - public void setSomeTextRetypeAgain(String someTextRetypeAgain) { - this.someTextRetypeAgain = someTextRetypeAgain; - } + public String getSomeText() { + return someText; + } + + public void setSomeText(String someText) { + this.someText = someText; + } + + public String getSomeTextRetype() { + return someTextRetype; + } + + public void setSomeTextRetype(String someTextRetype) { + this.someTextRetype = someTextRetype; + } + + public String getSomeTextRetypeAgain() { + return someTextRetypeAgain; + } + + public void setSomeTextRetypeAgain(String someTextRetypeAgain) { + this.someTextRetypeAgain = someTextRetypeAgain; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/QuizAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/QuizAction.java index 81e27360b..57a583193 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/QuizAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/QuizAction.java @@ -29,35 +29,35 @@ import com.opensymphony.xwork2.ActionSupport; public class QuizAction extends ActionSupport { - private static final long serialVersionUID = -7505437345373234225L; + private static final long serialVersionUID = -7505437345373234225L; - String name; - int age; - String answer; + String name; + int age; + String answer; - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public int getAge() { - return age; - } + public int getAge() { + return age; + } - public void setAge(int age) { - this.age = age; - } + public void setAge(int age) { + this.age = age; + } - public String getAnswer() { - return answer; - } + public String getAnswer() { + return answer; + } - public void setAnswer(String answer) { - this.answer = answer; - } + public void setAnswer(String answer) { + this.answer = answer; + } } // END SNIPPET: quizAction diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/SubmitApplication.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/SubmitApplication.java index 99bf87479..5a990d01a 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/SubmitApplication.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/SubmitApplication.java @@ -23,38 +23,40 @@ package org.apache.struts2.showcase.validation; import com.opensymphony.xwork2.ActionSupport; /** - * * @version $Date$ $Id$ */ public class SubmitApplication extends ActionSupport { - private String name; - private Integer age; + private String name; + private Integer age; - public void setName(String name) { - this.name = name; - } - public String getName() { - return this.name; - } + public void setName(String name) { + this.name = name; + } - public void setAge(Integer age) { - this.age = age; - } - public Integer getAge() { - return age; - } + public String getName() { + return this.name; + } - public String submitApplication() throws Exception { - return SUCCESS; - } + public void setAge(Integer age) { + this.age = age; + } - public String applicationOk() throws Exception { - addActionMessage("Your application looks ok."); - return SUCCESS; - } - public String cancelApplication() throws Exception { - addActionMessage("So you have decided to cancel the application"); - return SUCCESS; - } + public Integer getAge() { + return age; + } + + public String submitApplication() throws Exception { + return SUCCESS; + } + + public String applicationOk() throws Exception { + addActionMessage("Your application looks ok."); + return SUCCESS; + } + + public String cancelApplication() throws Exception { + addActionMessage("So you have decided to cancel the application"); + return SUCCESS; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/User.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/User.java index 111f8be52..7720a77ef 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/User.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/User.java @@ -26,28 +26,33 @@ import java.sql.Date; */ public class User { - private String name; - private Integer age; - private Date birthday; + private String name; + private Integer age; + private Date birthday; - public Integer getAge() { - return age; - } - public void setAge(Integer age) { - this.age = age; - } - public Date getBirthday() { - return birthday; - } - public void setBirthday(Date birthday) { - this.birthday = birthday; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public Date getBirthday() { + return birthday; + } + + public void setBirthday(Date birthday) { + this.birthday = birthday; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/VisitorValidatorsExampleAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/VisitorValidatorsExampleAction.java index 91391a314..7c13f35b6 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/VisitorValidatorsExampleAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/VisitorValidatorsExampleAction.java @@ -25,17 +25,17 @@ package org.apache.struts2.showcase.validation; public class VisitorValidatorsExampleAction extends AbstractValidationActionSupport { - private static final long serialVersionUID = 4375454086939598216L; + private static final long serialVersionUID = 4375454086939598216L; - private User user; + private User user; - public User getUser() { - return user; - } + public User getUser() { + return user; + } - public void setUser(User user) { - this.user = user; - } + public void setUser(User user) { + this.user = user; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/wait/LongProcessAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/wait/LongProcessAction.java index e449d9f09..8ff6859bb 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/wait/LongProcessAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/wait/LongProcessAction.java @@ -24,27 +24,24 @@ import com.opensymphony.xwork2.ActionSupport; /** * Example to illustrate the execAndWait interceptor. - * */ public class LongProcessAction extends ActionSupport { - private static final long serialVersionUID = 2471910747833998708L; + private static final long serialVersionUID = 2471910747833998708L; - private int time; + private int time; - public int getTime() { - return time; - } + public String execute() throws Exception { + Thread.sleep(time); - public void setTime(int time) { - this.time = time; - } + return SUCCESS; + } - public String execute() throws Exception { - System.err.println("time: " + time); - Thread.sleep(time); - - return SUCCESS; - } + public int getTime() { + return time; + } + public void setTime(int time) { + this.time = time; + } } diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/xslt/JVMAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/xslt/JVMAction.java index d888e2929..059b300af 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/xslt/JVMAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/xslt/JVMAction.java @@ -20,84 +20,84 @@ */ package org.apache.struts2.showcase.xslt; -import java.util.Map; -import java.util.Properties; - import com.opensymphony.xwork2.ActionSupport; - import org.apache.struts2.interceptor.ServletRequestAware; import javax.servlet.http.HttpServletRequest; +import java.util.Map; +import java.util.Properties; public class JVMAction implements ServletRequestAware { - private ImportantInfo info; - private Map environment; + private ImportantInfo info; + private Map environment; - /** Captured only to show that undesired data can creep into the result. */ - private HttpServletRequest servletRequest; + /** + * Captured only to show that undesired data can creep into the result. + */ + private HttpServletRequest servletRequest; - public String execute() { - environment = System.getenv(); - Properties props = System.getProperties(); + public String execute() { + environment = System.getenv(); + Properties props = System.getProperties(); - String classpath = environment.get("CLASSPATH"); - info = new ImportantInfo(classpath, props); + String classpath = environment.get("CLASSPATH"); + info = new ImportantInfo(classpath, props); - return ActionSupport.SUCCESS; - } + return ActionSupport.SUCCESS; + } - public HttpServletRequest getServletRequest() { - return servletRequest; - } + public HttpServletRequest getServletRequest() { + return servletRequest; + } - public void setServletRequest(HttpServletRequest servletRequest) { - this.servletRequest = servletRequest; - } + public void setServletRequest(HttpServletRequest servletRequest) { + this.servletRequest = servletRequest; + } - public Map getEnvironment() { - return environment; - } + public Map getEnvironment() { + return environment; + } - public void setEnvironment(Map environment) { - this.environment = environment; - } + public void setEnvironment(Map environment) { + this.environment = environment; + } - public ImportantInfo getInfo() { - return info; - } + public ImportantInfo getInfo() { + return info; + } - public void setInfo(ImportantInfo info) { - this.info = info; - } + public void setInfo(ImportantInfo info) { + this.info = info; + } - public class ImportantInfo { - private String classpath; - private Properties systemProperties; + public class ImportantInfo { + private String classpath; + private Properties systemProperties; - public ImportantInfo(String classpath, Properties properties) { - this.classpath = classpath; - this.systemProperties = properties; - } + public ImportantInfo(String classpath, Properties properties) { + this.classpath = classpath; + this.systemProperties = properties; + } - public String getClasspath() { - return classpath; - } + public String getClasspath() { + return classpath; + } - public void setClasspath(String classpath) { - this.classpath = classpath; - } + public void setClasspath(String classpath) { + this.classpath = classpath; + } - public Properties getSystemProperties() { - return systemProperties; - } + public Properties getSystemProperties() { + return systemProperties; + } - public void setSystemProperties(Properties systemProperties) { - this.systemProperties = systemProperties; - } - } + public void setSystemProperties(Properties systemProperties) { + this.systemProperties = systemProperties; + } + } } diff --git a/apps/showcase/src/main/resources/log4j.properties b/apps/showcase/src/main/resources/log4j.properties index 1af121eb1..7a86f1ef9 100644 --- a/apps/showcase/src/main/resources/log4j.properties +++ b/apps/showcase/src/main/resources/log4j.properties @@ -11,9 +11,9 @@ # Set root logger level to WARN and append to stdout -log4j.rootLogger=WARN, stdout - +log4j.rootLogger=DEBUG, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. @@ -23,9 +23,14 @@ log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n log4j.logger.noModule=FATAL # OpenSymphony Stuff +log4j.logger.freemarker=INFO log4j.logger.com.opensymphony=INFO -log4j.logger.org.apache.struts2=INFO +log4j.logger.com.opensymphony.xwork2.ognl=ERROR +log4j.logger.org.apache.struts2=WARN +log4j.logger.org.apache.struts2.components=WARN +log4j.logger.org.apache.struts2.dispatcher=WARN +log4j.logger.org.apache.struts2.convention=INFO # Spring Stuff -log4j.logger.org.springframework=INFO +log4j.logger.org.springframework=WARN diff --git a/apps/showcase/src/main/resources/struts-fileupload.xml b/apps/showcase/src/main/resources/struts-fileupload.xml index 283de0986..71071822e 100644 --- a/apps/showcase/src/main/resources/struts-fileupload.xml +++ b/apps/showcase/src/main/resources/struts-fileupload.xml @@ -20,7 +20,7 @@ - multipleUploadUsingList-success.jsp + multiple-success.jsp @@ -29,7 +29,7 @@ - multipleUploadUsingArray-success.jsp + multiple-success.jsp diff --git a/apps/showcase/src/main/resources/struts-hangman.xml b/apps/showcase/src/main/resources/struts-hangman.xml index cc8744d55..6c61a3db9 100644 --- a/apps/showcase/src/main/resources/struts-hangman.xml +++ b/apps/showcase/src/main/resources/struts-hangman.xml @@ -5,9 +5,6 @@ - - /hangman/hangmanMenu.ftl - /hangman/hangmanAjax.ftl diff --git a/apps/showcase/src/main/resources/struts-tags-non-ui.xml b/apps/showcase/src/main/resources/struts-tags-non-ui.xml index df2735b37..20c5a8dbb 100644 --- a/apps/showcase/src/main/resources/struts-tags-non-ui.xml +++ b/apps/showcase/src/main/resources/struts-tags-non-ui.xml @@ -123,5 +123,14 @@ /tags/non-ui/ifTag/testIf.ftl + + + + + + + /tags/non-ui/debug.jsp + + diff --git a/apps/showcase/src/main/resources/struts.xml b/apps/showcase/src/main/resources/struts.xml index 0e505abe4..3c1ebf3a4 100644 --- a/apps/showcase/src/main/resources/struts.xml +++ b/apps/showcase/src/main/resources/struts.xml @@ -9,7 +9,7 @@ - + @@ -65,9 +65,9 @@ - + - + @@ -102,11 +102,11 @@ /empmanager/editSkill.jsp - edit.action?skillName=${currentSkill.name} + list.action /empmanager/editSkill.jsp - edit.action?skillName=${currentSkill.name} + list.action @@ -124,11 +124,11 @@ /empmanager/editEmployee.jsp - edit-${currentEmployee.empId}.action + list.action /empmanager/editEmployee.jsp - edit-${currentEmployee.empId}.action + list.action diff --git a/apps/showcase/src/main/webapp/WEB-INF/applicationContext.xml b/apps/showcase/src/main/webapp/WEB-INF/applicationContext.xml index cec8c6871..c4a105954 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/applicationContext.xml +++ b/apps/showcase/src/main/webapp/WEB-INF/applicationContext.xml @@ -1,117 +1,121 @@ - - + - + + - - - - - - - - - + + - - - - + + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - - - - A popular programming language that is used to create the Struts framework - - - + + + + + A popular programming language that is used to create the Struts framework + + + + - - - - + + + + - - + + diff --git a/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp b/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp index 6bde8f36e..462bd4dd0 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp +++ b/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp @@ -1,106 +1,307 @@ - - + +<%@ page + language="java" + contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" %> <% - response.setHeader("Pragma", "no-cache"); - response.setHeader("Cache-Control", "no-cache"); - response.setDateHeader("Expires", 0); - - // Calculate the view sources url - String sourceUrl = request.getContextPath()+"/viewSource.action"; - com.opensymphony.xwork2.ActionInvocation inv = com.opensymphony.xwork2.ActionContext.getContext().getActionInvocation(); - org.apache.struts2.dispatcher.mapper.ActionMapping mapping = org.apache.struts2.ServletActionContext.getActionMapping(); - if (inv != null) { - com.opensymphony.xwork2.util.location.Location loc = inv.getProxy().getConfig().getLocation(); - sourceUrl += "?config="+(loc != null ? loc.getURI()+":"+loc.getLineNumber() : ""); - sourceUrl += "&className="+inv.getProxy().getConfig().getClassName(); - - if (inv.getResult() != null && inv.getResult() instanceof org.apache.struts2.dispatcher.StrutsResultSupport) { - sourceUrl += "&page="+mapping.getNamespace()+"/"+((org.apache.struts2.dispatcher.StrutsResultSupport)inv.getResult()).getLastFinalLocation(); - } - } else { - sourceUrl += "?page="+request.getServletPath(); - } + response.setHeader("Pragma", "no-cache"); + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expires", 0); + + // Calculate the view sources url + String sourceUrl = request.getContextPath()+"/viewSource.action"; + com.opensymphony.xwork2.ActionInvocation inv = com.opensymphony.xwork2.ActionContext.getContext().getActionInvocation(); + org.apache.struts2.dispatcher.mapper.ActionMapping mapping = org.apache.struts2.ServletActionContext.getActionMapping(); + if (inv != null) { + try { + com.opensymphony.xwork2.util.location.Location loc = inv.getProxy().getConfig().getLocation(); + sourceUrl += "?config="+(loc != null ? loc.getURI()+":"+loc.getLineNumber() : ""); + } catch (Exception e) { + sourceUrl += "?config="; + } + sourceUrl += "&className="+inv.getProxy().getConfig().getClassName(); + + if (inv.getResult() != null && inv.getResult() instanceof org.apache.struts2.dispatcher.StrutsResultSupport) { + sourceUrl += "&page="+mapping.getNamespace()+"/"+((org.apache.struts2.dispatcher.StrutsResultSupport)inv.getResult()).getLastFinalLocation(); + } + } else { + sourceUrl += "?page="+request.getServletPath(); + } %> <%@taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %> <%@taglib prefix="page" uri="http://www.opensymphony.com/sitemesh/page" %> <%@taglib prefix="s" uri="/struts-tags" %> - + - <decorator:title default="Struts Showcase"/> - - + + + + + + + <decorator:title default="Struts2 Showcase"/> + + + + + + + + + + + + + + + + + - + +

- -

+ - + + +


+ + diff --git a/apps/showcase/src/main/webapp/actionchaining/actionChainingResult.jsp b/apps/showcase/src/main/webapp/actionchaining/actionChainingResult.jsp index b16511308..87566e823 100644 --- a/apps/showcase/src/main/webapp/actionchaining/actionChainingResult.jsp +++ b/apps/showcase/src/main/webapp/actionchaining/actionChainingResult.jsp @@ -2,13 +2,22 @@ - Showcase - Action Chaining Result + Struts2 Showcase - Action Chaining Result -

Action Chaining Result:

-
-
-
+ + +
+
+
+
+
+
+
+
+
diff --git a/apps/showcase/src/main/webapp/chat/chatLogin.ftl b/apps/showcase/src/main/webapp/chat/chatLogin.ftl index 12a48b165..439ea6b37 100644 --- a/apps/showcase/src/main/webapp/chat/chatLogin.ftl +++ b/apps/showcase/src/main/webapp/chat/chatLogin.ftl @@ -1,16 +1,27 @@ - - Showcase - Chat - Login + Struts2 Showcase - Chat - Login <@s.head /> - <@s.actionerror /> - <@s.actionmessage /> - <@s.fielderror /> - <@s.form action="login" namespace="/chat" method="POST"> - <@s.textfield name="name" label="Name" required="true" /> - <@s.submit/> - + + +
+
+
+ <@s.actionerror cssClass="alert alert-error"/> + <@s.actionmessage cssClass="alert alert-info"/> + <@s.fielderror cssClass="alert alert-error"/> + + <@s.form action="login" namespace="/chat" method="POST"> + <@s.textfield name="name" label="Name" required="true" /> + <@s.submit cssClass="btn btn-primary"/> + +
+
+
+ diff --git a/apps/showcase/src/main/webapp/chat/roomSelection.ftl b/apps/showcase/src/main/webapp/chat/roomSelection.ftl index 8d273a237..05eaf1721 100644 --- a/apps/showcase/src/main/webapp/chat/roomSelection.ftl +++ b/apps/showcase/src/main/webapp/chat/roomSelection.ftl @@ -1,165 +1,172 @@ - - - - Showcase - Chat - Room Selection - <@sx.head /> - + + + + +
+
+
+ + +
+
+

Operations

+ <@s.url id="url" action="logout" namespace="/chat" /> +
    +
  • <@s.a href="%{#url}">Logout
  • +
+
+ <#if (actionErrors?size gt 0)> +
+

Action Errors

+ <@s.actionerrors /> +
+ +
+

Users Available In Chat

+ <@s.url id="usersAvailableUrl" action="usersAvailable" namespace="/chat/ajax" /> + <@sx.div id="usersAvailable" updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}" + href="%{usersAvailableUrl}" + class="box"> + Initial Loading Users ... + +
+
+ + +
+
+

Rooms Available In Chat

+ <@s.url id="roomsAvailableUrl" action="roomsAvailable" namespace="/chat/ajax" /> + <@sx.div id="roomsAvailable" listenTopics="topicRoomCreated" + updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}" + href="%{roomsAvailableUrl}" > + Initial Loading Rooms ... + +
+ +
+

Create Room In Chat

+ +
+ <@s.form id="createRoomId" action="createRoom" namespace="/chat/ajax" method="POST"> + <@s.textfield label="Room Name" required="true" name="name" /> + <@s.textarea theme="xhtml" label="Room Description" required="true" name="Description" /> + <@sx.submit value="%{'Create Room'}" targets="createRoomResult" afterNotifyTopics="topicRoomCreated" align="left" cssClass="btn btn-primary" /> + +
+
- div.container { - margin-left: auto; - margin-right: auto; - width: 100%; - } - - div.left { - width: 20%; - float: left; - } - - div.right { - width: 20%; - float: right; - } - - div.center { - width: 60%; - float: left; - } - - - - -
- - -
-
-

Operations

- <@s.url id="url" action="logout" namespace="/chat" /> -
    -
  • <@s.a href="%{#url}">Logout
  • -
- <#if (actionErrors?size gt 0)> -
-

Action Errors

- <@s.actionerrors /> -
- -
-

Users Available In Chat

- <@s.url id="usersAvailableUrl" action="usersAvailable" namespace="/chat/ajax" /> - <@sx.div id="usersAvailable" updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}" - href="%{usersAvailableUrl}" - class="box"> - Initial Loading Users ... - -
-
- - -
-
-

Rooms Available In Chat

- <@s.url id="roomsAvailableUrl" action="roomsAvailable" namespace="/chat/ajax" /> - <@sx.div id="roomsAvailable" listenTopics="topicRoomCreated" - updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}" - href="%{roomsAvailableUrl}" > - Initial Loading Rooms ... - -
- -
-

Create Room In Chat

-
- <@s.form id="createRoomId" action="createRoom" namespace="/chat/ajax" method="POST"> - <@s.textfield label="Room Name" required="true" name="name" /> - <@s.textarea theme="xhtml" label="Room Description" required="true" name="Description" /> - <@sx.submit value="%{'Create Room'}" targets="createRoomResult" afterNotifyTopics="topicRoomCreated" align="left" /> - -
-
- -
- +
+
+ diff --git a/apps/showcase/src/main/webapp/chat/showRoom.ftl b/apps/showcase/src/main/webapp/chat/showRoom.ftl index 9f1f1f767..0a82d4802 100644 --- a/apps/showcase/src/main/webapp/chat/showRoom.ftl +++ b/apps/showcase/src/main/webapp/chat/showRoom.ftl @@ -1,161 +1,167 @@ - - - Showcase - Chat - Show Room - <@sx.head /> - - - -
-
-
-

Operation

- <@s.url id="url" action="exitRoom" namespace="/chat"> - <@s.param name="roomName" value="%{roomName}" /> - -
    -
  • <@s.a href="%{#url}">Exit Room
  • -
-
-
-

Users Available In Chat

- <@s.url id="usersAvailableUrl" action="usersAvailable" namespace="/chat/ajax" /> - <@sx.div id="usersAvailable" href="%{usersAvailableUrl}" - updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}"> - Initial Users Available ... - -
-
- -
-
-

Messages Posted In Room [${roomName?default('')?html}]

- <@s.url id="url" value="/chat/ajax/messagesAvailableInRoom.action" includeContext="true"> - <@s.param name="roomName" value="%{roomName}" /> - - <@sx.div id="messagesInRoom" href="%{#url}" includeContext="true" - updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}" - listenTopics="topicMessageSend"> - Initial Messages In Room ... - -
- -
-

Send Messages

- <@s.form id="sendMessageForm" action="sendMessageToRoom" namespace="/chat/ajax" method="POST"> -
- <@s.textarea label="Message"name="message" theme="xhtml" /> - <@s.hidden name="roomName" value="%{roomName}" /> - <@sx.submit id="submit" resultDivId="sendMessageResult" afterNotifyTopics="topicMessageSend" value="%{'Send'}" /> - -
-
- + div.box h3 { + color: white; + background: darkblue; + margin: 3px; + padding: 2px; + } -
-
-

Users Available In Room [${roomName?default('')?html}]

- <@s.url id="url" value="/chat/ajax/usersAvailableInRoom.action" includeContext="true"> - <@s.param name="roomName" value="%{roomName}" /> - - <@sx.div id="usersAvailableInRoom" href="%{#url}" includeContext="true" + div.nobox { + margin: 5px; + } + + table.table { + border: 1px solid darkblue; + width: 98%; + margin: 5px; + } + + table.table tr.tableHeader { + color: white; + background: darkblue; + margin: 3px; + padding: 2px; + font-size: medium; + font-weight: bold; + } + + table.table td.tableSenderColumnOdd { + background: gray; + color: white; + width: 20% + } + + table.table td.tableDateColumnOdd { + background: gray; + color: white; + width: 20%; + } + + table.table td.tableMessageColumnOdd { + background: gray; + color: white; + width: 60%; + } + + table.table td.tableSenderColumnEven { + background: white; + color: gray; + width: 20% + } + + table.table td.tableDateColumnEven { + background: white; + color: gray; + width: 20%; + } + + table.table td.tableMessageColumnEven { + background: white; + color: gray; + width: 60%; + } + + div.container { + margin-left: auto; + margin-right: auto; + width: 100%; + } + + div.left { + width: 20%; + float: left; + } + + div.right { + width: 20%; + float: left; + } + + div.center { + width: 60%; + float: left; + } + + + + + + +
+
+
+
+
+

Operation

+ <@s.url id="url" action="exitRoom" namespace="/chat"> + <@s.param name="roomName" value="%{roomName}" /> + +
    +
  • <@s.a href="%{#url}">Exit Room
  • +
+
+
+

Users Available In Chat

+ <@s.url id="usersAvailableUrl" action="usersAvailable" namespace="/chat/ajax" /> + <@sx.div id="usersAvailable" href="%{usersAvailableUrl}" + updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}"> + Initial Users Available ... + +
+
+ +
+
+

Messages Posted In Room [${roomName?default('')?html}]

+ <@s.url id="url" value="/chat/ajax/messagesAvailableInRoom.action" includeContext="true"> + <@s.param name="roomName" value="%{roomName}" /> + + <@sx.div id="messagesInRoom" href="%{#url}" includeContext="true" + updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}" + listenTopics="topicMessageSend"> + Initial Messages In Room ... + +
+ +
+

Send Messages

+ <@s.form id="sendMessageForm" action="sendMessageToRoom" namespace="/chat/ajax" method="POST"> +
+ <@s.textarea label="Message"name="message" theme="xhtml" /> + <@s.hidden name="roomName" value="%{roomName}" /> + <@sx.submit id="submit" resultDivId="sendMessageResult" afterNotifyTopics="topicMessageSend" value="%{'Send'}" cssClass="btn btn-primary"/> + +
+
+ + +
+
+

Users Available In Room [${roomName?default('')?html}]

+ <@s.url id="url" value="/chat/ajax/usersAvailableInRoom.action" includeContext="true"> + <@s.param name="roomName" value="%{roomName}" /> + + <@sx.div id="usersAvailableInRoom" href="%{#url}" includeContext="true" delay="1" updateFreq="%{@org.apache.struts2.showcase.chat.Constants@UPDATE_FREQ}"> - Initial Users Available In Room ... - + Initial Users Available In Room ... + +
+
+ +
-
- - -
- - +
+
+ diff --git a/apps/showcase/src/main/webapp/continuations/guess.ftl b/apps/showcase/src/main/webapp/continuations/guess.ftl deleted file mode 100644 index 48834c1e8..000000000 --- a/apps/showcase/src/main/webapp/continuations/guess.ftl +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - -<#list actionMessages as msg> - ${msg?html} - - -<@s.form action="guess" method="post"> - <@s.textfield label="Guess" name="guess"/> - <@s.submit value="Guess"/> - - - - diff --git a/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp b/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp index 260fc8505..b0e3e79d1 100644 --- a/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp +++ b/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp @@ -1,48 +1,53 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Conversion - Set + Struts2 Showcase - Conversion - Populate into Struts action class a Set of Address.java Object + -

-An example populating a Set of object (Address.java) into Struts' action (AddressAction.java) +

+
+
-

+

+ An example populating a Set of object (Address.java) into Struts' action (AddressAction.java) +

-See the jsp code here.
-See the code for PersonAction.java here.
-See the code for Person.java here.
+ See the jsp code here.
+ See the code for PersonAction.java here.
+ See the code for Person.java here.
-

+

- - - - - - - - <%-- - The following is how its done statically - --%> - <%-- - - - - - - - --%> + + + + + + + <%-- + The following is how its done statically + --%> + <%-- + + + + + + + --%> + +

+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/conversion/enterOperations.jsp b/apps/showcase/src/main/webapp/conversion/enterOperations.jsp index 5b3a654bd..817e81f0c 100644 --- a/apps/showcase/src/main/webapp/conversion/enterOperations.jsp +++ b/apps/showcase/src/main/webapp/conversion/enterOperations.jsp @@ -1,31 +1,38 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Conversion - Tiger 5 Enum + Struts2 Showcase - Conversion - Tiger 5 Enum + -See the jsp code here.
-See the code for OperationsEnum.java here.
-See the code for OperationsEnumAction.java here.
-See the code for EnumTypeConverter.java here.
-See the properties for OperationsEnumAction-conversion.properties here. -
-
+
+
+
- - - - + See the jsp code here.
+ See the code for OperationsEnum.java here.
+ See the code for OperationsEnumAction.java here.
+ See the code for EnumTypeConverter.java here.
+ See the properties for OperationsEnumAction-conversion.properties here. +
+
+ + + + + + +
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp b/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp index a7fc2dfd6..ba30a7978 100644 --- a/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp +++ b/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp @@ -1,58 +1,67 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Conversion - Populate Object into Struts' action List + Struts2 Showcase - Conversion - Populate Object into Struts' action List + -

-An example populating a list of object (Person.java) into Struts' action (PersonAction.java) +

+
+
-

-See the jsp code here.
-See the code for PersonAction.java here.
-See the code for Person.java here.
+

+ An example populating a list of object (Person.java) into Struts' action (PersonAction.java) +

-

+ See the jsp code here.
+ See the code for PersonAction.java here.
+ See the code for Person.java here.
- - +

- - <%-- - The following is done Dynamically - --%> - - - - - - - - <%-- - The following is done statically:- - --%> - <%-- - - - - - - - --%> - - - + + + + <%-- + The following is done Dynamically + --%> + + + + + + + + <%-- + The following is done statically:- + --%> + <%-- + + + + + + + --%> + + + + +

+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/conversion/index.jsp b/apps/showcase/src/main/webapp/conversion/index.jsp index 6adeed1bf..805d49025 100644 --- a/apps/showcase/src/main/webapp/conversion/index.jsp +++ b/apps/showcase/src/main/webapp/conversion/index.jsp @@ -2,25 +2,34 @@ - -Showcase - Conversion + Struts2 Showcase - Conversion + -
    -
  • - - Populate into the Struts action class a List of Person.java Object -
  • -
  • - - Populate into Struts action class a Set of Address.java Object -
  • -
  • - - Populate into Struts action class a List of OperationEnum.java (Java5 Enum) -
  • -
+
+
+
+
    +
  • + + Populate into the Struts action class a List of Person.java Object +
  • +
  • + + Populate into Struts action class a Set of Address.java Object +
  • +
  • + + Populate into Struts action class a List of OperationEnum.java (Java5 Enum) +
  • +
+ +
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp b/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp index 2f1d4e346..8f2c0c45f 100644 --- a/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp +++ b/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp @@ -1,15 +1,21 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> <%@taglib prefix="s" uri="/struts-tags" %> - - -Showcase - Conversion - Set + Struts2 Showcase - Conversion - Populate into Struts action class a Set of Address.java Object - - ->
-
+ + +
+
+
+ + ->
+
+
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/conversion/showOperations.jsp b/apps/showcase/src/main/webapp/conversion/showOperations.jsp index c4b885903..4cb66792e 100644 --- a/apps/showcase/src/main/webapp/conversion/showOperations.jsp +++ b/apps/showcase/src/main/webapp/conversion/showOperations.jsp @@ -1,17 +1,21 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Conversion - Tiger 5 Enum + Struts2 Showcase - Conversion - Tiger 5 Enum + - -
-
- +
+
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp b/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp index b0b10e1b1..24f9760d9 100644 --- a/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp +++ b/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp @@ -1,17 +1,24 @@ <%@taglib prefix="s" uri="/struts-tags" %> - - -Showcase - Conversion - Populate Object into Struts action List + Struts2 Showcase - Conversion - Populate Object into Struts' action List + - -
-
-
+
+
+
+ +
+
+
+
+
+
diff --git a/apps/showcase/src/main/webapp/empmanager/editEmployee.jsp b/apps/showcase/src/main/webapp/empmanager/editEmployee.jsp index 99bd2faf2..aff2c3e43 100644 --- a/apps/showcase/src/main/webapp/empmanager/editEmployee.jsp +++ b/apps/showcase/src/main/webapp/empmanager/editEmployee.jsp @@ -1,43 +1,56 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> - -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - - <s:property value="#title"/> - - + + + + + + + Struts2 Showcase - CRUD Example - <s:property value="#title"/> + + - -

+ - +
+
+
+ +
+
- - - - - - - - - - - - - - - -

">

+ + + + + + + + + + + + + + + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/empmanager/editSkill.jsp b/apps/showcase/src/main/webapp/empmanager/editSkill.jsp index b3070f1dc..f47390ed2 100644 --- a/apps/showcase/src/main/webapp/empmanager/editSkill.jsp +++ b/apps/showcase/src/main/webapp/empmanager/editSkill.jsp @@ -1,27 +1,42 @@ -<%@ taglib prefix="s" uri="/struts-tags" %> - -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - - - +<%@taglib prefix="s" uri="/struts-tags" %> -<s:property value="#title"/> - + + + + + + + + + + Struts2 Showcase - CRUD Example - <s:property value="#title"/> + -

+ - - - - <%--s:submit name="%{#submitType}" value="%{getText('save')}" /--%> - - -

">

+
+
+
+ +
+
+ + + + + <%--s:submit name="%{#submitType}" value="%{getText('save')}" /--%> + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/empmanager/index.jsp b/apps/showcase/src/main/webapp/empmanager/index.jsp index c3278fe07..0da9091e7 100644 --- a/apps/showcase/src/main/webapp/empmanager/index.jsp +++ b/apps/showcase/src/main/webapp/empmanager/index.jsp @@ -1,21 +1 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - - - -Showcase - CRUD - - -

CRUD

- -

-

    -
  • List available Skills
  • -
  • Create/Edit Skill
  • -
  • List available Employees
  • -
  • Create/Edit Employee
  • -
-

- - - - +<% response.sendRedirect("../employee/list.action"); %> diff --git a/apps/showcase/src/main/webapp/empmanager/listEmployees.jsp b/apps/showcase/src/main/webapp/empmanager/listEmployees.jsp index 356bd0af4..199192415 100644 --- a/apps/showcase/src/main/webapp/empmanager/listEmployees.jsp +++ b/apps/showcase/src/main/webapp/empmanager/listEmployees.jsp @@ -1,26 +1,43 @@ -<%@ taglib prefix="s" uri="/struts-tags" %> - -<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@taglib prefix="s" uri="/struts-tags" %> -Available Employees - + + Struts2 Showcase - CRUD Example + -

Available Employees

- - - - - - - - - - - - - -
IdFirst NameLast Name
">
-

">Create new Employee

-

">Back to Showcase Startpage

+ + +
+
+
+ +
+
+ + + + + + + + + + + + + + + +
IdFirst NameLast Name
">
+ " class="btn btn-primary">Create new Employee +
+
+
diff --git a/apps/showcase/src/main/webapp/empmanager/listSkills.jsp b/apps/showcase/src/main/webapp/empmanager/listSkills.jsp index 3b1f77965..1c20253a2 100644 --- a/apps/showcase/src/main/webapp/empmanager/listSkills.jsp +++ b/apps/showcase/src/main/webapp/empmanager/listSkills.jsp @@ -1,24 +1,41 @@ -<%@ taglib prefix="s" uri="/struts-tags" %> - -<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@taglib prefix="s" uri="/struts-tags" %> -Available Skills - + + Struts2 Showcase - CRUD Example + -

Available Skills

- - - - - - - - - - -
NameDescription
">
- -

">Create new Skill

-

">Back to Showcase Startpage

+ + +
+
+
+ +
+
+ + + + + + + + + + + +
NameDescription
">
+ + " class="btn btn-primary">Create new Skill +
+
+
+ diff --git a/apps/showcase/src/main/webapp/filedownload/index.jsp b/apps/showcase/src/main/webapp/filedownload/index.jsp index 78031ad75..a8b7ef883 100644 --- a/apps/showcase/src/main/webapp/filedownload/index.jsp +++ b/apps/showcase/src/main/webapp/filedownload/index.jsp @@ -1,23 +1,36 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Showcase - Fileupload + Struts2 Showcase - File Download -

File Download Example

+ -
    -
  • - Download image file. - The browser should display the Struts logo. -
  • -
  • - Download ZIP file. - The browser should prompt for a location to save the ZIP file. -
  • -
+ +
+
+
+
+ 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. +
+
+
diff --git a/apps/showcase/src/main/webapp/fileupload/index.jsp b/apps/showcase/src/main/webapp/fileupload/index.jsp deleted file mode 100644 index bbbdb9e20..000000000 --- a/apps/showcase/src/main/webapp/fileupload/index.jsp +++ /dev/null @@ -1,25 +0,0 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - - -Showcase - Fileupload - - - -
    -
  • - - Single File Upload -
  • -
  • - - Multiple File Upload (List) - -
  • -
  • - - Multiple File Upload (Array) -
  • -
- - - \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingArray-success.jsp b/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingArray-success.jsp deleted file mode 100644 index b5980592b..000000000 --- a/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingArray-success.jsp +++ /dev/null @@ -1,37 +0,0 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - - -Insert title here - - - - - - - - - - -
File
- - - - - - - - - -
File Name
- - - - - - - - -
Content Type
- - - \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingArray.jsp b/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingArray.jsp index 611315e42..4c8167c12 100644 --- a/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingArray.jsp +++ b/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingArray.jsp @@ -1,20 +1,32 @@ -<%@ page - language="java" - contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> +<%@ page + language="java" + contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags" %> -Showcase - fileupload - multiple fileupload using List + Struts2 Showcase - Fileupload sample - Multiple fileupload using Array - - - - - - - + + + +
+
+
+ + + + + + + + +
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingList-success.jsp b/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingList-success.jsp deleted file mode 100644 index b5980592b..000000000 --- a/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingList-success.jsp +++ /dev/null @@ -1,37 +0,0 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - - -Insert title here - - - - - - - - - - -
File
- - - - - - - - - -
File Name
- - - - - - - - -
Content Type
- - - \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingList.jsp b/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingList.jsp index d9fc6b19a..a84ef6c7d 100644 --- a/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingList.jsp +++ b/apps/showcase/src/main/webapp/fileupload/multipleUploadUsingList.jsp @@ -5,16 +5,28 @@ <%@ taglib prefix="s" uri="/struts-tags" %> -Showcase - fileupload - multiple fileupload using List + Struts2 Showcase - Fileupload sample - Multiple fileupload using List - - - - - - - + + + +
+
+
+ + + + + + + + +
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/fileupload/upload-success.jsp b/apps/showcase/src/main/webapp/fileupload/upload-success.jsp index 15029cb54..6073d2ac2 100644 --- a/apps/showcase/src/main/webapp/fileupload/upload-success.jsp +++ b/apps/showcase/src/main/webapp/fileupload/upload-success.jsp @@ -5,20 +5,26 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Showcase + Struts2 Showcase - Fileupload sample -

Fileupload sample

+ -

-

    -
  • ContentType:
  • -
  • FileName:
  • -
  • File:
  • -
  • Caption:
  • -
-

+
+
+
+
    +
  • ContentType:
  • +
  • FileName:
  • +
  • File:
  • +
  • Caption:
  • +
+
+
+
diff --git a/apps/showcase/src/main/webapp/fileupload/upload.jsp b/apps/showcase/src/main/webapp/fileupload/upload.jsp index 04150d2cf..cc770c465 100644 --- a/apps/showcase/src/main/webapp/fileupload/upload.jsp +++ b/apps/showcase/src/main/webapp/fileupload/upload.jsp @@ -1,23 +1,27 @@ -<%@ page - language="java" - contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags" %> - Showcase + Struts2 Showcase - Fileupload sample -

Fileupload sample

+ - - - - - - - +
+
+
+ + + + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/freemarker/customFreemarkerManagerUsage.ftl b/apps/showcase/src/main/webapp/freemarker/customFreemarkerManagerUsage.ftl index 21101a846..a1e14cf69 100644 --- a/apps/showcase/src/main/webapp/freemarker/customFreemarkerManagerUsage.ftl +++ b/apps/showcase/src/main/webapp/freemarker/customFreemarkerManagerUsage.ftl @@ -1,12 +1,18 @@ - - Showcase - Freemarker - CustomFreemarkerManager Usage + 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 @@ -20,7 +26,9 @@ Today's Date = ${customFreemarkerManagerUtil.todayDate}
Time now = ${customFreemarkerManagerUtil.getTimeNow()}
- +

+
+
diff --git a/apps/showcase/src/main/webapp/freemarker/index.jsp b/apps/showcase/src/main/webapp/freemarker/index.jsp index c5e2f3055..360c6cb77 100644 --- a/apps/showcase/src/main/webapp/freemarker/index.jsp +++ b/apps/showcase/src/main/webapp/freemarker/index.jsp @@ -1,24 +1,3 @@ - -<%@taglib prefix="s" uri="/struts-tags" %> - - - - Showcase - Freemarker - - - -
    -
  • - - Demo of usage of a Custom Freemarker Manager -
  • -
  • - - Demo of Standard Struts Freemarker Tags -
  • -
- - - +<% response.sendRedirect("/freemarker/customFreemarkerManagerDemo.action"); %> diff --git a/apps/showcase/src/main/webapp/freemarker/standardTags.ftl b/apps/showcase/src/main/webapp/freemarker/standardTags.ftl index 1afc40913..016e189cc 100644 --- a/apps/showcase/src/main/webapp/freemarker/standardTags.ftl +++ b/apps/showcase/src/main/webapp/freemarker/standardTags.ftl @@ -1,4 +1,24 @@ -<@s.form action="test"> - <@s.textfield label="Name" name="name"/> - <@s.select label="Birth Month" headerValue="Select Month" list="months" /> - \ No newline at end of file + + + 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" /> + + +
+
+
+ + diff --git a/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl b/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl index ab84cf9ad..e43329029 100644 --- a/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl +++ b/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl @@ -1,237 +1,246 @@ - - Showcase - Hangman - <@sx.head /> + Struts2 Showcase - Hangman (AJAX) +<@sx.head /> + - + var scripts = div.getElementsByTagName("script"); + for (var i = 0; i < scripts.length; i++) { + eval(scripts[i].innerHTML); + } + } + catch (e) { + alert("dojo error" + e); + dojo.debug("auto-build-widgets error: " + e); + } + }, + mimetype:"text/html" + }); + } + }; + dojo.event.topic.subscribe("topicGuessMade", _listeners, "guessMade"); + - - - - - - - - - - - - - - - - - - - - - - -
- <@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/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"/> + + +
+ + +
+ +
+
-
-

- <@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" /> - - -
- - -
- -
+
diff --git a/apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl b/apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl deleted file mode 100644 index 717339e57..000000000 --- a/apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl +++ /dev/null @@ -1,18 +0,0 @@ - - - - Showcase - Hangman - Menu - - -
    -
  • - <@s.url id="url" action="hangmanNonAjax" namespace="/hangman" /> - <@s.a href="%{#url}">Hangman (Non Ajax) -
  • -
  • - <@s.url id="url" action="hangmanAjax" namespace="/hangman" /> - <@s.a href="%{#url}">Hangman (Ajax - Experimental) -
  • -
- - diff --git a/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl b/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl index 73419f17f..6bfd8eabf 100644 --- a/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl +++ b/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl @@ -1,134 +1,143 @@ - Showcase - Hangman - <@s.head theme="xhtml" /> + 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/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" /> + + + +
+ + +
+ +
+
-
-

- <@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" /> - - - -
- - -
- -
+
diff --git a/apps/showcase/src/main/webapp/help.jsp b/apps/showcase/src/main/webapp/help.jsp index 48f61a676..08d84acc7 100644 --- a/apps/showcase/src/main/webapp/help.jsp +++ b/apps/showcase/src/main/webapp/help.jsp @@ -1,31 +1,32 @@ <%@taglib prefix="s" uri="/struts-tags" %> - Struts ~ Getting Support + Struts2 Showcase . Getting Support -
-

Getting support

+ - - - - - - - - - - - - - -
LinkDescription
User ListUse this mailing list if you encounter problems while developing and using with Struts
Struts 2The Struts 2 website
-
-
- Struts Logo -
+
+
+
+ Struts Logo +
+
+
+ Use this mailing list if you encounter problems while developing and using with Struts. +
+ User List +
+
+
+ The Struts 2 website. +
+ Struts 2 +
+
diff --git a/apps/showcase/src/main/webapp/integration/modelDriven.jsp b/apps/showcase/src/main/webapp/integration/modelDriven.jsp index ce7938b59..dc0b1f4bb 100644 --- a/apps/showcase/src/main/webapp/integration/modelDriven.jsp +++ b/apps/showcase/src/main/webapp/integration/modelDriven.jsp @@ -1,31 +1,44 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@ taglib prefix="s" uri="/struts-tags" %> -Showcase - Struts 1 Integration Example - + Struts2 Showcase - Struts1 Integration + + - - - - - - - - - + +
+
+
+ + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/integration/modelDrivenResult.jsp b/apps/showcase/src/main/webapp/integration/modelDrivenResult.jsp index 550c55815..7d11f4c7c 100644 --- a/apps/showcase/src/main/webapp/integration/modelDrivenResult.jsp +++ b/apps/showcase/src/main/webapp/integration/modelDrivenResult.jsp @@ -1,24 +1,43 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@ taglib prefix="s" uri="/struts-tags" %> -Showcase - Struts 1 Integration Example - + Struts2 Showcase - Struts1 Integration - Result + - - -
-
-
-
+ + + + +
+
+
+ + +
+
+
+
+ +
+
+
diff --git a/apps/showcase/src/main/webapp/interactive/index.jsp b/apps/showcase/src/main/webapp/interactive/index.jsp index 3a38e890b..987a39a89 100644 --- a/apps/showcase/src/main/webapp/interactive/index.jsp +++ b/apps/showcase/src/main/webapp/interactive/index.jsp @@ -120,12 +120,6 @@ } .wc-command { margin: 1px 0 0 0; - border-style: none; - font-family: courier; - color: white; - background-color: black; - width: 100%; - padding: 0px; } .shell { width: 100%; @@ -196,7 +190,7 @@ :->
- OGNL Expression + OGNL Expression diff --git a/apps/showcase/src/main/webapp/jsf/employee/edit.jsp b/apps/showcase/src/main/webapp/jsf/employee/edit.jsp index 717c82536..6f1d219f3 100644 --- a/apps/showcase/src/main/webapp/jsf/employee/edit.jsp +++ b/apps/showcase/src/main/webapp/jsf/employee/edit.jsp @@ -22,85 +22,92 @@ <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %> + + + Struts2 Showcase - JSF Integration - Modify Employee + + - - - - JSF Integration Examples - + - - -

Modify Employee

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - -
- + - +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + +
+
+
+
+ +
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/jsf/employee/list.jsp b/apps/showcase/src/main/webapp/jsf/employee/list.jsp index cad7d1c81..403c92e54 100644 --- a/apps/showcase/src/main/webapp/jsf/employee/list.jsp +++ b/apps/showcase/src/main/webapp/jsf/employee/list.jsp @@ -22,48 +22,54 @@ <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %> + + + Struts2 Showcase - JSF Integration - Available Employees + + - -Available Employees + - -

Available Employees

- - - - - - - - - - - - - - - - - - - - - - - - - -

- - - -

- - - - - + - +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +

+ + + +

+
+
+
+ +
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/jsf/index.jsp b/apps/showcase/src/main/webapp/jsf/index.jsp index 953bd04bc..9685a84f1 100644 --- a/apps/showcase/src/main/webapp/jsf/index.jsp +++ b/apps/showcase/src/main/webapp/jsf/index.jsp @@ -1,24 +1,35 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@ taglib prefix="s" uri="/struts-tags" %> -Showcase - JSF Integration + Struts2 Showcase - JSF Integration + + -

JavaServer Faces Integration

-

-The following pages show how Struts and JSF components can work together, -each doing what they do best. -

+ -

-

    -
  • List available Employees
  • -
  • Create/Edit Employee
  • -
-

+
+
+
+

+ The following pages show how Struts and JSF components can work together, + each doing what they do best. +

+

+

    +
  • List available Employees
  • +
  • Create/Edit Employee
  • +
+

+
+
+
- + \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/modelDriven/modelDriven.jsp b/apps/showcase/src/main/webapp/modelDriven/modelDriven.jsp index 346ffcece..d51533ea0 100644 --- a/apps/showcase/src/main/webapp/modelDriven/modelDriven.jsp +++ b/apps/showcase/src/main/webapp/modelDriven/modelDriven.jsp @@ -1,31 +1,42 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@ taglib prefix="s" uri="/struts-tags" %> -Showcase - Model Driven Example - + Struts2 Showcase - Model Driven Example + + - - - - - - - - - + +
+
+
+ + + + + + + + + + + +
+
+
- + \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/modelDriven/modelDrivenResult.jsp b/apps/showcase/src/main/webapp/modelDriven/modelDrivenResult.jsp index 5b96cca6e..d80b9664d 100644 --- a/apps/showcase/src/main/webapp/modelDriven/modelDrivenResult.jsp +++ b/apps/showcase/src/main/webapp/modelDriven/modelDrivenResult.jsp @@ -1,24 +1,42 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Model Driven Example - + Struts2 Showcase - Model Driven Example - Result + + -
-
-
-
+ +
+
+
+ +
+
+
+
+ +
+
+
- + \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/person/edit-person.jsp b/apps/showcase/src/main/webapp/person/edit-person.jsp index 2f9ec87ee..a7b0d9887 100644 --- a/apps/showcase/src/main/webapp/person/edit-person.jsp +++ b/apps/showcase/src/main/webapp/person/edit-person.jsp @@ -1,43 +1,53 @@ -<%@ taglib prefix="s" uri="/struts-tags" %> - +<%@taglib prefix="s" uri="/struts-tags" %> - Edit Persons (batch-edit) + Struts2 Showcase - Person Manager Example - - + - - - - - - - - - - - - - -
IDFirst NameLast Name
- - - - - -
+
+
+
+ +
+
+ - - - -
    - -
  • Create a new person
  • - -
  • List all people
  • -
+ + + + + + + + + + + + + +
IDFirst NameLast Name
+ + + + + +
+ + +
+
+
diff --git a/apps/showcase/src/main/webapp/person/index.jsp b/apps/showcase/src/main/webapp/person/index.jsp index dd553e371..f7db6cf25 100644 --- a/apps/showcase/src/main/webapp/person/index.jsp +++ b/apps/showcase/src/main/webapp/person/index.jsp @@ -1,16 +1 @@ -<%@ taglib prefix="s" uri="/struts-tags" %> - - - - Acme Corp - - - -
    - -
  • Create a new person
  • - -
  • List all people
  • -
- - +<% response.sendRedirect("list-people.action"); %> \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/person/list-people.ftl b/apps/showcase/src/main/webapp/person/list-people.ftl index 48dd888e0..ac29b176c 100644 --- a/apps/showcase/src/main/webapp/person/list-people.ftl +++ b/apps/showcase/src/main/webapp/person/list-people.ftl @@ -1,30 +1,44 @@ - All People + Struts2 Showcase - Person Manager Example - All People - + -There are ${peopleCount} people... - - - - - -<#list people as person> - - - - - - -
IDName
${person.id?html}${person.name?html}${person.lastName?html}
+
+
+
+ +
+
-
    - <@s.url id="editpersonurl" action="edit-person" /> -
  • <@s.a href="%{editpersonurl}">Edit people
  • - <@s.url id="newpersonurl" action="new-person" method="input" /> -
  • <@s.a href="%{newpersonurl}">Create a new person
  • -
+

There are ${peopleCount} people...

+ + + + + + + + <#list people as person> + + + + + + +
IDNameLast Name
${person.id?html}${person.name?html}${person.lastName?html}
+
+
+
diff --git a/apps/showcase/src/main/webapp/person/new-person.ftl b/apps/showcase/src/main/webapp/person/new-person.ftl index 18ea66f99..6e99f071d 100644 --- a/apps/showcase/src/main/webapp/person/new-person.ftl +++ b/apps/showcase/src/main/webapp/person/new-person.ftl @@ -1,21 +1,49 @@ - New Person + Struts2 Showcase - Person Manager Example - New Person - -<@s.form action="new-person"> - <@s.textfield label="First Name" name="person.name"/> - <@s.textfield label="Last Name" name="person.lastName"/> - <@s.submit value="Create person"/> - + -
    - <@s.url id="editpersonurl" action="edit-person" /> -
  • <@s.a href="%{editpersonurl}">Edit people
  • - <@s.url id="listpeopleurl" action="list-people" /> -
  • <@s.a href="%{listpeopleurl}">List all people
  • -
+
+
+
+ +
+
+ <@s.actionerror cssClass="alert alert-error"/> + <@s.actionmessage cssClass="alert alert-info"/> + <@s.fielderror cssClass="alert alert-error"/> + <@s.form action="new-person" theme="simple" cssClass="form-horizontal"> + Create a new Person +
+ +
+ <@s.textfield id="name" name="person.name" placeholder="First Name"/> +
+
+
+ +
+ <@s.textfield id="lastName" name="person.lastName" placeholder="Last Name"/> +
+
+
+ <@s.submit value="Create person" cssClass="btn btn-primary"/> +
+ +
+
+
diff --git a/apps/showcase/src/main/webapp/showcase.jsp b/apps/showcase/src/main/webapp/showcase.jsp index 9e19ef5f4..bb23e7863 100644 --- a/apps/showcase/src/main/webapp/showcase.jsp +++ b/apps/showcase/src/main/webapp/showcase.jsp @@ -7,58 +7,24 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Showcase + Struts2 Showcase -
-

- The Struts Showcase demonstrates a variety of use cases and tag usages. - Essentially, the application exercises various framework features in isolation. - The Showcase is not meant as a "best practices" example. -

-
    -
  • - For more "by example" solutions, - see the Struts Cookbook pages. -
  • -
-
-

- <%-- THIS LIST IS MAINTAINED IN WEB-INF/decorators/main.jsp TO CREATE THE MENU BAR -- EDIT THERE AND COPY HERE --%> -

+
+
+
-

Sandbox

-

- These examples are under development and may not be fully operational. -

- +
+

Welcome!

+

The Struts Showcase demonstrates a variety of use cases and tag usages. Essentially, the application exercises various framework features in isolation. The Showcase is not meant as a "best practices" example.

+

For more "by example" solutions, see the Struts Cookbook » pages.

+
-

+
+
+
diff --git a/apps/showcase/src/main/webapp/styles/main.css b/apps/showcase/src/main/webapp/styles/main.css index 3085ed369..ae5f08421 100644 --- a/apps/showcase/src/main/webapp/styles/main.css +++ b/apps/showcase/src/main/webapp/styles/main.css @@ -1,5 +1,19 @@ -@import url(layout-navtop-localleft.css); -@import url(layout.css); -@import url(forms.css); -@import url(typo.css); -@import url(tools.css); +body { + padding-top: 60px; + padding-bottom: 40px; +} +.sidebar-nav { + padding: 9px 0; +} +.tdLabel .label, .wwlbl .label { + background-color: #ffffff; + color: #000000; + text-shadow: none; +} +.alert li { + list-style: none; +} +.errorMessage, label.errorLabel { + color: red; +} +label.errorLabel \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tags/index.jsp b/apps/showcase/src/main/webapp/tags/index.jsp deleted file mode 100644 index e0f175318..000000000 --- a/apps/showcase/src/main/webapp/tags/index.jsp +++ /dev/null @@ -1,16 +0,0 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - - - -Showcase - Tags - - -

Tags

- - - - - diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefix.ftl b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefix.ftl index ae41402c5..f87b6d44c 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefix.ftl +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefix.ftl @@ -1,18 +1,24 @@ - - - Showcase - Tags - Non UI - Action Prefix (freemarker) + Struts2 Showcase - Non UI Tags - Action Prefix (Freemarker) - - You have come to this page because you used an 'action' prefix.

- - The text you've entered is ${text?default('')?html}

- - <@s.url id="url" action="actionPrefixExampleUsingFreemarker" namespace="/tags/non-ui/actionPrefix" /> - <@s.a href="%{#url}">Back - +

+ +
+
+
+ +

You have come to this page because you used an action prefix.

+ +

The text you've entered is ${text?default('')?html}

+ + <@s.a href="javascript:history.back();" cssClass="btn btn-info"> Back +

+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl index 857aa05d6..e19d7143b 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/actionPrefixExample.ftl @@ -1,48 +1,58 @@ - - - Showcase - Tags - Non UI - Action Prefix (Freemarker) - - - Action Prefix
- By clicking on 'action prefix' button, the request will go to the action alias 'actionPrefix' - instead of the normal 'submit' action alias.

- - Method Prefix
- By clicking on the 'method prefix' button, the request will cause Struts to invoke 'submit' - action alias's 'alternateMethod' method instead of the default 'execute' method.

- - Redirect Prefix
- By clicking on the 'redirect prefix' button, the request will get redirected to www.google.com - instead

- - Redirect Action Prefix
- By clicking on the 'redirect-action prefix' button, the request will get redirected to - an action alias of 'redirectActionPrefix' instead of 'submit' action alias. Since this is a - redirect (a new request is issue from the client), the text entered will be lost.

- - - <@s.url id="url" action="viewSource" namespace="/tags/non-ui/actionPrefix" /> - The JSP code can be read <@s.a href="%{#url}">here. - - - <@s.form action="submit" namespace="/tags/non-ui/actionPrefix" method="POST"> - - <@s.textfield label="Enter Some Text" name="text" /> - - <@s.submit name="action:actionPrefix" value="%{'action prefix'}" /> - - <@s.submit name="method:alternateMethod" value="%{'method prefix'}" /> - - <@s.submit name="redirect:http://www.google.com" value="%{'redirect prefix'}" /> - - <@s.submit name="redirect-action:redirectActionPrefix" value="%{'redirect-action prefix'}" /> - - <@s.submit value="Normal Submit" /> + + Struts2 Showcase - Non UI Tags - Action Prefix (Freemarker) + + +

- <@s.submit name="action:redirectActionPrefixAction" value="%{'redirect-action without prefix'}" /> +
+
+
- - + Action Prefix
+ By clicking on 'action prefix' button, the request will go to the action alias 'actionPrefix' + instead of the normal 'submit' action alias.

+ + Method Prefix
+ By clicking on the 'method prefix' button, the request will cause Struts to invoke 'submit' + action alias's 'alternateMethod' method instead of the default 'execute' method.

+ + Redirect Prefix
+ By clicking on the 'redirect prefix' button, the request will get redirected to www.google.com + instead

+ + Redirect Action Prefix
+ By clicking on the 'redirect-action prefix' button, the request will get redirected to + an action alias of 'redirectActionPrefix' instead of 'submit' action alias. Since this is a + redirect (a new request is issue from the client), the text entered will be lost.

+ + + <@s.url id="url" action="viewSource" namespace="/tags/non-ui/actionPrefix" /> + The JSP code can be read <@s.a href="%{#url}">here. + + + <@s.form action="submit" namespace="/tags/non-ui/actionPrefix" method="POST"> + + <@s.textfield label="Enter Some Text" name="text" /> + + <@s.submit name="action:actionPrefix" value="%{'action prefix'}" cssClass="btn" /> + + <@s.submit name="method:alternateMethod" value="%{'method prefix'}" cssClass="btn" /> + + <@s.submit name="redirect:http://www.google.com" value="%{'redirect prefix'}" cssClass="btn" /> + + <@s.submit name="redirect-action:redirectActionPrefix" value="%{'redirect-action prefix'}" cssClass="btn" /> + + <@s.submit value="Normal Submit" cssClass="btn" /> + + <@s.submit name="action:redirectActionPrefixAction" value="%{'redirect-action without prefix'}" cssClass="btn" /> + + +

+
+
+ diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/index.jsp b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/index.jsp deleted file mode 100644 index 18a871256..000000000 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/index.jsp +++ /dev/null @@ -1,13 +0,0 @@ - -<%@taglib prefix="s" uri="/struts-tags" %> - - - -Showcase - Tags - Non-Ui - Action Prefix - - -
    - Action Prefix Example (Freemarker)
- - - diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/methodPrefix.ftl b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/methodPrefix.ftl index 1cc41fec9..836bb22f0 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/methodPrefix.ftl +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/methodPrefix.ftl @@ -1,18 +1,24 @@ - - - Showcase - Tags - Non UI - Action Prefix (freemarker) + Struts2 Showcase - Non UI Tags - Action Prefix (Freemarker) + + +
+
+
+ +

You have come to this page because you used an method prefix.

- You have come to this page because you used an 'method' prefix.

- - The text you've enter is ${text?default('')?html}

- - <@s.url id="url" action="actionPrefixExampleUsingFreemarker" namespace="/tags/non-ui/actionPrefix" /> - <@s.a href="%{#url}">Back - +

The text you've enter is ${text?default('')?html}

+ + <@s.a href="javascript:history.back();" cssClass="btn btn-info"> Back +

+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/normalSubmit.ftl b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/normalSubmit.ftl index c183d9726..e30d88c51 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/normalSubmit.ftl +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/normalSubmit.ftl @@ -1,17 +1,24 @@ - - Showcase - Tags - Non UI - Action Prefix (freemarker) + Struts2 Showcase - Non UI Tags - Action Prefix (Freemarker) + + +
+
+
+ +

You have come to this page because you did a normal submit.

- You have come to this page because you did a normal submit.

- - The text you've enter is %{text}

- - <@s.url id="url" action="actionPrefixExampleUsingFreemarker" namespace="/tags/non-ui/prefix" /> - <@s.a href="%{#url}">Back - +

The text you've enter is %{text}

+ + <@s.a href="javascript:history.back();" cssClass="btn btn-info"> Back +

+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/redirectActionPrefix.ftl b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/redirectActionPrefix.ftl index ed460e492..f21fc45ba 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/redirectActionPrefix.ftl +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionPrefix/redirectActionPrefix.ftl @@ -1,21 +1,27 @@ - - - Showcase - Tags - Non UI - Action Prefix (freemarker) + Struts2 Showcase - Non UI Tags - Action Prefix (Freemarker) + + +
+
+
+ +

You have come to this page because you used an 'redirect-action' prefix.

- You have come to this page because you used an 'redirect-action' prefix.

- - Because this is a 'redirect-action', the text will be lost, due to a redirection - implies a new request being issued from the client.

- - The text you've enter is ${text?default('')?html}

- - <@s.url id="url" action="actionPrefixExampleUsingFreemarker" namespace="/tags/non-ui/actionPrefix" /> - <@s.a href="%{#url}">Back - +

Because this is a redirect-action, the text will be lost, due to a redirection + implies a new request being issued from the client.

+ + The text you've enter is ${text?default('')?html}

+ + <@s.a href="javascript:history.back();" cssClass="btn btn-info"> Back +

+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage.jsp b/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage.jsp index bf84a3704..abfa2535b 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage.jsp @@ -1 +1 @@ -

This is INCLUDED by the action tag

+

This is INCLUDED by the action tag

diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage2.jsp b/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage2.jsp index 2b73ee077..6cdc04055 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage2.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage2.jsp @@ -1,2 +1,2 @@ -

This is INCLUDED by the action tag (Page2)

+

This is INCLUDED by the action tag (Page2)

diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage3.jsp b/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage3.jsp index cddd14d8c..4ebbcc744 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage3.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionTag/includedPage3.jsp @@ -1,2 +1,2 @@ -

This is INCLUDED by the action tag (Page3)

+

This is INCLUDED by the action tag (Page3)

diff --git a/apps/showcase/src/main/webapp/tags/non-ui/actionTag/showActionTagDemo.jsp b/apps/showcase/src/main/webapp/tags/non-ui/actionTag/showActionTagDemo.jsp index f7d9976a3..1fb5b44cc 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/actionTag/showActionTagDemo.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/actionTag/showActionTagDemo.jsp @@ -1,43 +1,52 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Non-Ui Tag - Action Tag + Struts2 Showcase - Non-Ui Tag - Action Tag -
-

This is Not - Included by the Action Tag

+ +
+
+
- -
- - - +
+

This is Not - Included by the Action Tag

+
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + + Source +
+
- - - -
- - - -
- - - -
- - - -
- - - -Source - diff --git a/apps/showcase/src/main/webapp/tags/non-ui/date.jsp b/apps/showcase/src/main/webapp/tags/non-ui/date.jsp index 3d9ef6f43..8581d8fd7 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/date.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/date.jsp @@ -1,104 +1,114 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - UI Tags Example: Date - + Struts2 Showcase - Non UI Tags Example - Date - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameFormatOutput
Before datetoString()
Past datetoString()
Now datetoString()
Future datetoString()
After datetoString()
Current dateyyyy/MM/dd hh:mm:ss
Current datedd.MM.yyyy hh:mm:ss
Current time (24h)HH:mm:ss
Before dateMMM, dd yyyy
Before datenice
After datedd.MM.yyyy
After datenice
Past datedd/MM/yyyy hh:mm
Future dateMM-dd-yy
Future date (fallback)fallback
Past datenice
Future datenice
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameFormatOutput
Before datetoString()
Past datetoString()
Now datetoString()
Future datetoString()
After datetoString()
Current dateyyyy/MM/dd hh:mm:ss
Current datedd.MM.yyyy hh:mm:ss
Current time (24h)HH:mm:ss
Before dateMMM, dd yyyy
Before datenice
After datedd.MM.yyyy
After datenice
Past datedd/MM/yyyy hh:mm
Future dateMM-dd-yy
Future date (fallback)fallback
Past datenice
Future datenice
+
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tags/non-ui/debug.jsp b/apps/showcase/src/main/webapp/tags/non-ui/debug.jsp index 88de057b0..26c49a5bd 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/debug.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/debug.jsp @@ -1,20 +1,30 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Non-UI Tags Example: Debug - + Struts2 Showcase - Non UI Tags Example - Debug -

Debug Tag Usage

+ -

- This page shows a simple example of using the debug tag.
- Just add <s:debug /> to your JSP page - and you will see the debug link. -

- Just click on the Debug label to see the Struts ValueStack Debug information. -

- +

+
+
+ +

+ This page shows a simple example of using the debug tag.
+ Just add <s:debug /> to your JSP page + and you will see the debug link. +

+ +

+ Just click on the Debug label to see the Struts ValueStack Debug information. +

+ +

+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tags/non-ui/ifTag/testIf.ftl b/apps/showcase/src/main/webapp/tags/non-ui/ifTag/testIf.ftl index 8d5f7de04..4b9fab29f 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/ifTag/testIf.ftl +++ b/apps/showcase/src/main/webapp/tags/non-ui/ifTag/testIf.ftl @@ -1,611 +1,618 @@ - - TEST IF - + + Struts2 Showcase - Non Ui Tag - Test If Tag (Freemarker) + + -

-This is a simple freemarker template to test the If Tag (using freemarker directive). -There's quite a few combination being tested. The characters in bold and non-bold should be the same. -

- - -1 - Foo - -<@s.if test="true"> - Foo - -<@s.else> - Bar - -
-2 - Bar - -<@s.if test="false"> - Foo - -<@s.else> - Bar - -
-3 - FooFooFoo - -<@s.if test="true"> - Foo - <@s.if test="true"> - FooFoo - - <@s.else> - BarBar - - -<@s.else> - Bar - -
-4 - FooBarBar - -<@s.if test="true"> - Foo - <@s.if test="false"> - FooFoo - - <@s.else> - BarBar - - -
-5 - BarFooFoo - -<@s.if test="false"> - Foo - -<@s.else> - Bar - <@s.if test="true"> - FooFoo - - <@s.else> - BarBar - - -
-6 - BarBarBar - -<@s.if test="false"> - Foo - -<@s.else> - Bar - <@s.if test="false"> - FooFoo - - <@s.else> - BarBar - - -
-7 - Foo - -<@s.if test="true"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - -
-8 - Moo - -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - -<@s.else> - Bar - -
-9 - Bar - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - -
-10 - FooFooFoo - -<@s.if test="true"> - Foo - <@s.if test="true"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - <@s.else> - BarBar - - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - -
-11 - FooMooMoo - -<@s.if test="true"> - Foo - <@s.if test="false"> - FooFoo - - <@s.elseif test="true"> - MooMoo - - <@s.else> - BarBar - - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - -
-12 - FooBarBar - -<@s.if test="true"> - Foo - <@s.if test="false"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - <@s.else> - BarBar - - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - -
-13 - MooFooFoo - -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - <@s.if test="true"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - <@s.else> - BarBar - - -<@s.else> - Bar - -
-14 - MooMooMoo - -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - <@s.if test="false"> - FooFoo - - <@s.elseif test="true"> - MooMoo - - <@s.else> - BarBar - - -<@s.else> - Bar - -
-15 - MooBarBar - -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - <@s.if test="false"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - <@s.else> - BarBar - - -<@s.else> - Bar - -
-16 - BarFooFoo - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - <@s.if test="true"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - <@s.else> - BarBar - - -
-17 - BarMooMoo - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - <@s.if test="false"> - FooFoo - - <@s.elseif test="true"> - MooMoo - - <@s.else> - BarBar - - -
-18 - BarBarBar - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - <@s.if test="false"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - <@s.else> - BarBar - - + -
-19 - Foo - -<@s.if test="true"> - Foo - - -
-20 - ** should not display anything ** - -<@s.if test="false"> - Foo - - -
-21 FooFooFoo - -<@s.if test="true"> - Foo - <@s.if test="true"> - FooFoo - - -<@s.else> - Bar - - -
-22 - Foo - -<@s.if test="true"> - Foo - <@s.if test="false"> - FooFoo - - -<@s.else> - Bar - - -
-23 - BarFooFoo - -<@s.if test="false"> - Foo - -<@s.else> - Bar - <@s.if test="true"> - FooFoo - - - -
-24 - Bar - -<@s.if test="false"> - Foo - -<@s.else> - Bar - <@s.if test="false"> - FooFoo - - - -
-25 - FooFooFoo -<@s.if test="true"> - Foo - <@s.if test="true"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - - -
-26 - FooMooMoo -<@s.if test="true"> - Foo - <@s.if test="false"> - FooFoo - - <@s.elseif test="true"> - MooMoo - - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - - -
-27 - Foo - -<@s.if test="true"> - Foo - <@s.if test="false"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - - -
-28 - MooFooFoo -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - <@s.if test="true"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - -<@s.else> - Bar - - -
-29 - MooMooMoo -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - <@s.if test="false"> - FooFoo - - <@s.elseif test="true"> - MooMoo - - -<@s.else> - Bar - - -
-30 - Moo - -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - <@s.if test="false"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - -<@s.else> - Bar - - -
-31 - BarFooFoo - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - <@s.if test="true"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - - -
-32 - BarMooMoo - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - <@s.if test="false"> - FooFoo - - <@s.elseif test="true"> - MooMoo - - - -
-33 - Bar - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - <@s.if test="false"> - FooFoo - - <@s.elseif test="false"> - MooMoo - - - -
-34 - FooFooFoo - -<@s.if test="true"> - Foo - <@s.if test="true"> - FooFoo - - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - - -
-35 - Foo - -<@s.if test="true"> - Foo - <@s.if test="false"> - FooFoo - - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - - -
-36 - MooFooFoo - -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - <@s.if test="true"> - FooFoo - - -<@s.else> - Bar - - -
-37 - Moo - -<@s.if test="false"> - Foo - -<@s.elseif test="true"> - Moo - <@s.if test="false"> - FooFoo - - -<@s.else> - Bar - - -
-38 - BarFooFoo - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - <@s.if test="true"> - FooFoo - - - -
-39 - Bar - -<@s.if test="false"> - Foo - -<@s.elseif test="false"> - Moo - -<@s.else> - Bar - <@s.if test="false"> - FooFoo - - +
+
+
+

+ This is a simple freemarker template to test the If Tag (using freemarker directive). + There's quite a few combination being tested. The characters in bold and non-bold should be the same. +

+ 1 - Foo - + <@s.if test="true"> + Foo + + <@s.else> + Bar + +
+ 2 - Bar - + <@s.if test="false"> + Foo + + <@s.else> + Bar + +
+ 3 - FooFooFoo - + <@s.if test="true"> + Foo + <@s.if test="true"> + FooFoo + + <@s.else> + BarBar + + + <@s.else> + Bar + +
+ 4 - FooBarBar - + <@s.if test="true"> + Foo + <@s.if test="false"> + FooFoo + + <@s.else> + BarBar + + +
+ 5 - BarFooFoo - + <@s.if test="false"> + Foo + + <@s.else> + Bar + <@s.if test="true"> + FooFoo + + <@s.else> + BarBar + + +
+ 6 - BarBarBar - + <@s.if test="false"> + Foo + + <@s.else> + Bar + <@s.if test="false"> + FooFoo + + <@s.else> + BarBar + + +
+ 7 - Foo - + <@s.if test="true"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + +
+ 8 - Moo - + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + + <@s.else> + Bar + +
+ 9 - Bar - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + +
+ 10 - FooFooFoo - + <@s.if test="true"> + Foo + <@s.if test="true"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + <@s.else> + BarBar + + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + +
+ 11 - FooMooMoo - + <@s.if test="true"> + Foo + <@s.if test="false"> + FooFoo + + <@s.elseif test="true"> + MooMoo + + <@s.else> + BarBar + + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + +
+ 12 - FooBarBar - + <@s.if test="true"> + Foo + <@s.if test="false"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + <@s.else> + BarBar + + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + +
+ 13 - MooFooFoo - + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + <@s.if test="true"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + <@s.else> + BarBar + + + <@s.else> + Bar + +
+ 14 - MooMooMoo - + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + <@s.if test="false"> + FooFoo + + <@s.elseif test="true"> + MooMoo + + <@s.else> + BarBar + + + <@s.else> + Bar + +
+ 15 - MooBarBar - + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + <@s.if test="false"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + <@s.else> + BarBar + + + <@s.else> + Bar + +
+ 16 - BarFooFoo - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + <@s.if test="true"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + <@s.else> + BarBar + + +
+ 17 - BarMooMoo - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + <@s.if test="false"> + FooFoo + + <@s.elseif test="true"> + MooMoo + + <@s.else> + BarBar + + +
+ 18 - BarBarBar - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + <@s.if test="false"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + <@s.else> + BarBar + + +
+ 19 - Foo - + <@s.if test="true"> + Foo + +
+ 20 - ** should not display anything ** - + <@s.if test="false"> + Foo + + +
+ 21 FooFooFoo - + <@s.if test="true"> + Foo + <@s.if test="true"> + FooFoo + + + <@s.else> + Bar + + +
+ 22 - Foo - + <@s.if test="true"> + Foo + <@s.if test="false"> + FooFoo + + + <@s.else> + Bar + + +
+ 23 - BarFooFoo - + <@s.if test="false"> + Foo + + <@s.else> + Bar + <@s.if test="true"> + FooFoo + + + +
+ 24 - Bar - + <@s.if test="false"> + Foo + + <@s.else> + Bar + <@s.if test="false"> + FooFoo + + + +
+ 25 - FooFooFoo + <@s.if test="true"> + Foo + <@s.if test="true"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + + +
+ 26 - FooMooMoo + <@s.if test="true"> + Foo + <@s.if test="false"> + FooFoo + + <@s.elseif test="true"> + MooMoo + + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + + +
+ 27 - Foo - + <@s.if test="true"> + Foo + <@s.if test="false"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + + +
+ 28 - MooFooFoo + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + <@s.if test="true"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + + <@s.else> + Bar + + +
+ 29 - MooMooMoo + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + <@s.if test="false"> + FooFoo + + <@s.elseif test="true"> + MooMoo + + + <@s.else> + Bar + + +
+ 30 - Moo - + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + <@s.if test="false"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + + <@s.else> + Bar + + +
+ 31 - BarFooFoo - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + <@s.if test="true"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + + +
+ 32 - BarMooMoo - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + <@s.if test="false"> + FooFoo + + <@s.elseif test="true"> + MooMoo + + + +
+ 33 - Bar - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + <@s.if test="false"> + FooFoo + + <@s.elseif test="false"> + MooMoo + + + +
+ 34 - FooFooFoo - + <@s.if test="true"> + Foo + <@s.if test="true"> + FooFoo + + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + + +
+ 35 - Foo - + <@s.if test="true"> + Foo + <@s.if test="false"> + FooFoo + + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + + +
+ 36 - MooFooFoo - + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + <@s.if test="true"> + FooFoo + + + <@s.else> + Bar + + +
+ 37 - Moo - + <@s.if test="false"> + Foo + + <@s.elseif test="true"> + Moo + <@s.if test="false"> + FooFoo + + + <@s.else> + Bar + + +
+ 38 - BarFooFoo - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + <@s.if test="true"> + FooFoo + + + +
+ 39 - Bar - + <@s.if test="false"> + Foo + + <@s.elseif test="false"> + Moo + + <@s.else> + Bar + <@s.if test="false"> + FooFoo + + +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/ifTag/testIf.jsp b/apps/showcase/src/main/webapp/tags/non-ui/ifTag/testIf.jsp index a872d0582..c04928332 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/ifTag/testIf.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/ifTag/testIf.jsp @@ -1,616 +1,619 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> - <%@taglib prefix="s" uri="/struts-tags" %> - - - -Test If Tag + Struts2 Showcase - Non Ui Tag - Test If Tag + -

-This is a simple jsp to test the If Tag. There's quite a few combination being tested. -The characters in bold an non-bold should be the same. -

+ + +
+
+
+

+ This is a simple jsp to test the If Tag. There's quite a few combination being tested. + The characters in bold an non-bold should be the same. +

-1 - Foo - - - Foo - - - Bar - -
-2 - Bar - - - Foo - - - Bar - -
-3 - FooFooFoo - - - Foo - - FooFoo - - - BarBar - - - - Bar - -
-4 - FooBarBar - - - Foo - - FooFoo - - - BarBar - - -
-5 - BarFooFoo - - - Foo - - - Bar - - FooFoo - - - BarBar - - -
-6 - BarBarBar - - - Foo - - - Bar - - FooFoo - - - BarBar - - -
-7 - Foo - - - Foo - - - Moo - - - Bar - -
-8 - Moo - - - Foo - - - Moo - - - Bar - -
-9 - Bar - - - Foo - - - Moo - - - Bar - -
-10 - FooFooFoo - - - Foo - - FooFoo - - - MooMoo - - - BarBar - - - - Moo - - - Bar - -
-11 - FooMooMoo - - - Foo - - FooFoo - - - MooMoo - - - BarBar - - - - Moo - - - Bar - -
-12 - FooBarBar - - - Foo - - FooFoo - - - MooMoo - - - BarBar - - - - Moo - - - Bar - -
-13 - MooFooFoo - - - Foo - - - Moo - - FooFoo - - - MooMoo - - - BarBar - - - - Bar - -
-14 - MooMooMoo - - - Foo - - - Moo - - FooFoo - - - MooMoo - - - BarBar - - - - Bar - -
-15 - MooBarBar - - - Foo - - - Moo - - FooFoo - - - MooMoo - - - BarBar - - - - Bar - -
-16 - BarFooFoo - - - Foo - - - Moo - - - Bar - - FooFoo - - - MooMoo - - - BarBar - - -
-17 - BarMooMoo - - - Foo - - - Moo - - - Bar - - FooFoo - - - MooMoo - - - BarBar - - -
-18 - BarBarBar - - - Foo - - - Moo - - - Bar - - FooFoo - - - MooMoo - - - BarBar - - + 1 - Foo - + + Foo + + + Bar + +
+ 2 - Bar - + + Foo + + + Bar + +
+ 3 - FooFooFoo - + + Foo + + FooFoo + + + BarBar + + + + Bar + +
+ 4 - FooBarBar - + + Foo + + FooFoo + + + BarBar + + +
+ 5 - BarFooFoo - + + Foo + + + Bar + + FooFoo + + + BarBar + + +
+ 6 - BarBarBar - + + Foo + + + Bar + + FooFoo + + + BarBar + + +
+ 7 - Foo - + + Foo + + + Moo + + + Bar + +
+ 8 - Moo - + + Foo + + + Moo + + + Bar + +
+ 9 - Bar - + + Foo + + + Moo + + + Bar + +
+ 10 - FooFooFoo - + + Foo + + FooFoo + + + MooMoo + + + BarBar + + + + Moo + + + Bar + +
+ 11 - FooMooMoo - + + Foo + + FooFoo + + + MooMoo + + + BarBar + + + + Moo + + + Bar + +
+ 12 - FooBarBar - + + Foo + + FooFoo + + + MooMoo + + + BarBar + + + + Moo + + + Bar + +
+ 13 - MooFooFoo - + + Foo + + + Moo + + FooFoo + + + MooMoo + + + BarBar + + + + Bar + +
+ 14 - MooMooMoo - + + Foo + + + Moo + + FooFoo + + + MooMoo + + + BarBar + + + + Bar + +
+ 15 - MooBarBar - + + Foo + + + Moo + + FooFoo + + + MooMoo + + + BarBar + + + + Bar + +
+ 16 - BarFooFoo - + + Foo + + + Moo + + + Bar + + FooFoo + + + MooMoo + + + BarBar + + +
+ 17 - BarMooMoo - + + Foo + + + Moo + + + Bar + + FooFoo + + + MooMoo + + + BarBar + + +
+ 18 - BarBarBar - + + Foo + + + Moo + + + Bar + + FooFoo + + + MooMoo + + + BarBar + + -
-19 - Foo - - - Foo - +
+ 19 - Foo - + + Foo + -
-20 - ** should not display anything ** - - - Foo - +
+ 20 - ** should not display anything ** - + + Foo + -
-21 FooFooFoo - - - Foo - - FooFoo - - - - Bar - +
+ 21 FooFooFoo - + + Foo + + FooFoo + + + + Bar + -
-22 - Foo - - - Foo - - FooFoo - - - - Bar - +
+ 22 - Foo - + + Foo + + FooFoo + + + + Bar + -
-23 - BarFooFoo - - - Foo - - - Bar - - FooFoo - - +
+ 23 - BarFooFoo - + + Foo + + + Bar + + FooFoo + + -
-24 - Bar - - - Foo - - - Bar - - FooFoo - - +
+ 24 - Bar - + + Foo + + + Bar + + FooFoo + + -
-25 - FooFooFoo - - Foo - - FooFoo - - - MooMoo - - - - Moo - - - Bar - +
+ 25 - FooFooFoo + + Foo + + FooFoo + + + MooMoo + + + + Moo + + + Bar + -
-26 - FooMooMoo - - Foo - - FooFoo - - - MooMoo - - - - Moo - - - Bar - +
+ 26 - FooMooMoo + + Foo + + FooFoo + + + MooMoo + + + + Moo + + + Bar + -
-27 - Foo - - - Foo - - FooFoo - - - MooMoo - - - - Moo - - - Bar - +
+ 27 - Foo - + + Foo + + FooFoo + + + MooMoo + + + + Moo + + + Bar + -
-28 - MooFooFoo - - Foo - - - Moo - - FooFoo - - - MooMoo - - - - Bar - +
+ 28 - MooFooFoo + + Foo + + + Moo + + FooFoo + + + MooMoo + + + + Bar + -
-29 - MooMooMoo - - Foo - - - Moo - - FooFoo - - - MooMoo - - - - Bar - +
+ 29 - MooMooMoo + + Foo + + + Moo + + FooFoo + + + MooMoo + + + + Bar + -
-30 - Moo - - - Foo - - - Moo - - FooFoo - - - MooMoo - - - - Bar - +
+ 30 - Moo - + + Foo + + + Moo + + FooFoo + + + MooMoo + + + + Bar + -
-31 - BarFooFoo - - - Foo - - - Moo - - - Bar - - FooFoo - - - MooMoo - - +
+ 31 - BarFooFoo - + + Foo + + + Moo + + + Bar + + FooFoo + + + MooMoo + + -
-32 - BarMooMoo - - - Foo - - - Moo - - - Bar - - FooFoo - - - MooMoo - - +
+ 32 - BarMooMoo - + + Foo + + + Moo + + + Bar + + FooFoo + + + MooMoo + + -
-33 - Bar - - - Foo - - - Moo - - - Bar - - FooFoo - - - MooMoo - - +
+ 33 - Bar - + + Foo + + + Moo + + + Bar + + FooFoo + + + MooMoo + + -
-34 - FooFooFoo - - - Foo - - FooFoo - - - - Moo - - - Bar - +
+ 34 - FooFooFoo - + + Foo + + FooFoo + + + + Moo + + + Bar + -
-35 - Foo - - - Foo - - FooFoo - - - - Moo - - - Bar - +
+ 35 - Foo - + + Foo + + FooFoo + + + + Moo + + + Bar + -
-36 - MooFooFoo - - - Foo - - - Moo - - FooFoo - - - - Bar - +
+ 36 - MooFooFoo - + + Foo + + + Moo + + FooFoo + + + + Bar + -
-37 - Moo - - - Foo - - - Moo - - FooFoo - - - - Bar - - -
-38 - BarFooFoo - - - Foo - - - Moo - - - Bar - - FooFoo - - - -
-39 - Bar - - - Foo - - - Moo - - - Bar - - FooFoo - - +
+ 37 - Moo - + + Foo + + + Moo + + FooFoo + + + + Bar + +
+ 38 - BarFooFoo - + + Foo + + + Moo + + + Bar + + FooFoo + + +
+ 39 - Bar - + + Foo + + + Moo + + + Bar + + FooFoo + + +
+
+
- \ No newline at end of file + diff --git a/apps/showcase/src/main/webapp/tags/non-ui/index.jsp b/apps/showcase/src/main/webapp/tags/non-ui/index.jsp deleted file mode 100644 index a37a7f81e..000000000 --- a/apps/showcase/src/main/webapp/tags/non-ui/index.jsp +++ /dev/null @@ -1,24 +0,0 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - - - -Showcase - Tags - Non UI Tags - - -

Non UI Tags

- -
    -
  • Action Tag
  • -
  • Date Tag
  • -
  • Debug Tag
  • -
  • Iterator Generator Tag
  • -
  • Append Iterator Tag -
  • Merge Iterator Demo -
  • Subset Tag -
  • Action Prefix Example
  • -
  • If Tag (JSP)
  • -
  • If Tag (Freemarker)
  • -
- - - diff --git a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/appendIteratorTagDemoResult.jsp b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/appendIteratorTagDemoResult.jsp index 2fcd8fc55..32b9fecc4 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/appendIteratorTagDemoResult.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/appendIteratorTagDemoResult.jsp @@ -1,25 +1,34 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tag - Non UI Tag - AppendIterator Tag + Struts2 Showcase - Non Ui Tag - AppendIterator Tag + + - - - - - - - - - -
-
- - Back To Non-UI Demo - Back To Showcase +
+
+
+ + + + + + + + + +
+
+ + + Back To Input +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp index cc67d7a3f..5ebb9fc10 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp @@ -1,19 +1,29 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tag - Non Ui Tag - Iterator Generator Tag Demo + Struts2 Showcase - Non Ui Tag - Iterator Generator Tag Demo + + - - -
-
-
+
+
+
- Back To Non-UI Demo - Back To Showcase + + +
+
+
+ + + Back To Input +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp index 0244b945c..15cab7dc3 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp @@ -1,25 +1,33 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tags - Non UI Tag - MergeIterator Tag + Struts2 Showcase - Non Ui Tag - MergeIterator Tag + + - - - - - - - - - -
-
+
+
+
+ + - Back To Non-UI Demo - Back To Showcase + + + + + +
+
+ + + Back To Input +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showAppendIteratorTagDemo.jsp b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showAppendIteratorTagDemo.jsp index 838a9a128..259cfc499 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showAppendIteratorTagDemo.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showAppendIteratorTagDemo.jsp @@ -1,19 +1,28 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tag - Non UI Tag - AppendIterator Tag + Struts2 Showcase - Non Ui Tag - AppendIterator Tag + + - - +
+
+
- - - - - + + + + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showIteratorGeneratorTagDemo.jsp b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showIteratorGeneratorTagDemo.jsp index f076828c5..e5a0665f4 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showIteratorGeneratorTagDemo.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showIteratorGeneratorTagDemo.jsp @@ -1,21 +1,29 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tag - Non Ui Tag - Iterator Generator Tag Demo - + Struts2 Showcase - Non Ui Tag - Iterator Generator Tag Demo + + - - - - - - - - - +
+
+
+ + + + + + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showMergeIteratorTagDemo.jsp b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showMergeIteratorTagDemo.jsp index 032e27d46..54d2c38f2 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showMergeIteratorTagDemo.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/showMergeIteratorTagDemo.jsp @@ -1,17 +1,29 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tags - Non UI Tag - MergeIterator Tag + Struts2 Showcase - Non Ui Tag - MergeIterator Tag + + - - - - - +
+
+
+ + + + + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/subsetIteratorTagDemo.jsp b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/subsetIteratorTagDemo.jsp index 84f62495b..e14de242a 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/subsetIteratorTagDemo.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/subsetIteratorTagDemo.jsp @@ -1,20 +1,29 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tags - Non UI Tags - SubsetTag Demo + Struts2 Showcase - Non Ui Tag - SubsetTag Demo + + - - +
+
+
- - - - - - + + + + + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp index 5298d5126..22f8be61d 100644 --- a/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp +++ b/apps/showcase/src/main/webapp/tags/non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp @@ -1,21 +1,30 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tags - Non UI Tags - Subset Tag + Struts2 Showcase - Non Ui Tag - SubsetTag Demo + + - +
+
+
- - -
-
-
+ - Back To Non-UI Demo - Back To Showcase + + +
+
+
+ + Back To Input +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp b/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp index 67d402580..750465d4a 100644 --- a/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp @@ -1,14 +1,24 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tags - UI Tags - Action Tag + Struts2 Showcase - UI Tags - Action Tag + - Example 1: - This example calls an action and includes the output on the page -

- -

+ + +
+
+
+ Example 1: + This example calls an action and includes the output on the page +

+ +

+
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tags/ui/componentTagExample.jsp b/apps/showcase/src/main/webapp/tags/ui/componentTagExample.jsp index eebd6b8fb..dca5b0f33 100644 --- a/apps/showcase/src/main/webapp/tags/ui/componentTagExample.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/componentTagExample.jsp @@ -1,62 +1,69 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tags - UI Tags - Component Tag + Struts2 Showcase - UI Tags - Component Tag + - -This example tries to demonstrates the usage of <s:component ... > tag. -

+

-To have a look at the source of this jsp page click - -here -

- -Example 1: -This example load the template from the webapp context path using -the default (ftl) as its template. - - - -

- -Example 2: -This example load the template from the webapp context path using -jsp as its template (notice the *.jsp extension to the template). - - - -

- -Example 3 -This example load the template from the webapp context path, -using the default template directory and theme (default to -'template' and 'xhtml' respectively) - - - -

- - -Example 4 -This example load the template from the webapp classpath using -a custom themplate directory and theme. - - - -

+

+
+
+

This example tries to demonstrates the usage of <s:component ... > tag.

+

To have a look at the source of this jsp page click + + here +

+ + Example 1: +

This example load the template from the webapp context path using + the default (ftl) as its template. + + + +

+ + Example 2: +

This example load the template from the webapp context path using + jsp as its template (notice the *.jsp extension to the template). + + + +

+ + Example 3 +

This example load the template from the webapp context path, + using the default template directory and theme (default to + 'template' and 'xhtml' respectively) + + + +

+ + + Example 4 +

This example load the template from the webapp classpath using + a custom themplate directory and theme. + + + +

+

+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/datepicker/index.jsp b/apps/showcase/src/main/webapp/tags/ui/datepicker/index.jsp index 4418f151f..db9c7fb0b 100644 --- a/apps/showcase/src/main/webapp/tags/ui/datepicker/index.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/datepicker/index.jsp @@ -1,25 +1,33 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ taglib prefix="s" uri="/struts-tags" %> +<%@taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> - - UI Tags Example - + Struts2 Showcase - UI Tags - Datepicker Tag + - - - - - - - - - - - - -
+ + +
+
+
+ + + + + + + + + + + + +
+
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/example.jsp b/apps/showcase/src/main/webapp/tags/ui/example.jsp index 1ef6f30d7..0e89c03d1 100644 --- a/apps/showcase/src/main/webapp/tags/ui/example.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/example.jsp @@ -1,142 +1,149 @@ -<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> -<%@ taglib prefix="s" uri="/struts-tags" %> +<%@taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> - - UI Tags Example - + Struts2 Showcase - UI Tags Example + + - + - - - +
+
+
+ + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/example.vm b/apps/showcase/src/main/webapp/tags/ui/example.vm index 23c582a1a..23a5d586b 100644 --- a/apps/showcase/src/main/webapp/tags/ui/example.vm +++ b/apps/showcase/src/main/webapp/tags/ui/example.vm @@ -1,34 +1,39 @@ - UI Tags Example - #shead() - #sxhead() + Struts2 Showcase - UI Tags Example (Velocity) + #shead() + #sxhead() - + -#surl ("id=url" "value=index.jsp") -Back to index.jsp! +
+
+
+ #sform ("action=exampleSubmitVelocity" "method=post" "enctype=multipart/form-data") + #stextfield ("label=Name" "name=name") + #sxdatetimepicker ("label=Birthday" "name=birthday") + #sxdatetimepicker ("label=Wake up time" "name=wakeup" "type=time") + #stextarea ("label=Biography" "name=bio" "cols=20" "rows=3") + #sselect ("label=Favourite Color" "list={'Red', 'Blue', 'Green'}" "name=favouriteColor" "emptyOption=true" "headerKey=None" "headerValue=None") + #sselect ("label=Favourite Language" "list=favouriteLanguages" "name=favouriteLanguage" "listKey=key" "listValue=description" "emptyOption=true" "headerKey=None" "headerValue=None") + #scheckboxlist ("label=Friends" "list={'Patrick', 'Jason', 'Jay', 'Toby', 'Rene'}" "name=friends") + #scheckbox ("label=Age 18+" "name=legalAge") + #sdoubleselect ("label=State" "name=region" "list={'North', 'South'}" "value='North'" "doubleValue='Florida'" "doubleList=top == 'North' ? {'Oregon', 'Washington'} : {'Texas', 'Florida'}" "doubleName=state" "headerKey=-1" "headerValue=---------- Please Select ----------" "emptyOption=true" ) + #sdoubleselect ("label=Favourite Vehical" "name=favouriteVehicalType" "list=vehicalTypeList" "listKey=key" "listValue=description" "value='MotorcycleKey'" "doubleValue='YamahaKey'" "doubleList=vehicalSpecificList" "doubleListKey=key" "doubleListValue=description" "doubleName=favouriteVehicalSpecific" "headerKey=-1" "headerValue=---------- Please Select ----------" "emptyOption=true" ) + #sfile ("label=Picture" "name=picture") + #soptiontransferselect ("label=Favourite Cartoons Characters" "name=leftSideCartoonCharacters" "leftTitle=Left Title" "rightTitle=Right Title" "list={'Popeye', 'He-Man', 'Spiderman'}" "multiple=true" "headerKey=headerKey" "headerValue=--- Please Select ---" "emptyOption=true" "doubleList={'Superman', 'Mickey Mouse', 'Donald Duck'}" "doubleName=rightSideCartoonCharacters" "doubleHeaderKey=doubleHeaderKey" "doubleHeaderValue=--- Please Select ---" "doubleEmptyOption=true" "doubleMultiple=true" ) + #ssubmit("cssClass=btn btn-primary") + #sreset("cssClass=btn btn-danger") + #end -#sform ("action=exampleSubmitVelocity" "method=post" "enctype=multipart/form-data") - #stextfield ("label=Name" "name=name") - #sxdatetimepicker ("label=Birthday" "name=birthday") - #sxdatetimepicker ("label=Wake up time" "name=wakeup" "type=time") - #stextarea ("label=Biography" "name=bio" "cols=20" "rows=3") - #sselect ("label=Favourite Color" "list={'Red', 'Blue', 'Green'}" "name=favouriteColor" "emptyOption=true" "headerKey=None" "headerValue=None") - #sselect ("label=Favourite Language" "list=favouriteLanguages" "name=favouriteLanguage" "listKey=key" "listValue=description" "emptyOption=true" "headerKey=None" "headerValue=None") - #scheckboxlist ("label=Friends" "list={'Patrick', 'Jason', 'Jay', 'Toby', 'Rene'}" "name=friends") - #scheckbox ("label=Age 18+" "name=legalAge") - #sdoubleselect ("label=State" "name=region" "list={'North', 'South'}" "value='North'" "doubleValue='Florida'" "doubleList=top == 'North' ? {'Oregon', 'Washington'} : {'Texas', 'Florida'}" "doubleName=state" "headerKey=-1" "headerValue=---------- Please Select ----------" "emptyOption=true" ) - #sdoubleselect ("label=Favourite Vehical" "name=favouriteVehicalType" "list=vehicalTypeList" "listKey=key" "listValue=description" "value='MotorcycleKey'" "doubleValue='YamahaKey'" "doubleList=vehicalSpecificList" "doubleListKey=key" "doubleListValue=description" "doubleName=favouriteVehicalSpecific" "headerKey=-1" "headerValue=---------- Please Select ----------" "emptyOption=true" ) - #sfile ("label=Picture" "name=picture") - #soptiontransferselect ("label=Favourite Cartoons Characters" "name=leftSideCartoonCharacters" "leftTitle=Left Title" "rightTitle=Right Title" "list={'Popeye', 'He-Man', 'Spiderman'}" "multiple=true" "headerKey=headerKey" "headerValue=--- Please Select ---" "emptyOption=true" "doubleList={'Superman', 'Mickey Mouse', 'Donald Duck'}" "doubleName=rightSideCartoonCharacters" "doubleHeaderKey=doubleHeaderKey" "doubleHeaderValue=--- Please Select ---" "doubleEmptyOption=true" "doubleMultiple=true" ) - #ssubmit() - #sreset() -#end - -#sa("href=${url}")Back to index.jsp#end - + #surl ("id=url" "value=index.jsp") + Back to index.jsp +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/exampleSubmited.jsp b/apps/showcase/src/main/webapp/tags/ui/exampleSubmited.jsp index ee7e7a7b5..5ef2126f8 100644 --- a/apps/showcase/src/main/webapp/tags/ui/exampleSubmited.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/exampleSubmited.jsp @@ -1,50 +1,58 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Non-UI Tag - Example Submited + Struts2 Showcase - UI Tags Example - Example Submited + + -

Example Submitted

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - .  - -
- - .  - -
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + .  + +
+ + .  + +
+
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/exampleSubmited.vm b/apps/showcase/src/main/webapp/tags/ui/exampleSubmited.vm index fe510abca..9646a4f53 100644 --- a/apps/showcase/src/main/webapp/tags/ui/exampleSubmited.vm +++ b/apps/showcase/src/main/webapp/tags/ui/exampleSubmited.vm @@ -1,53 +1,61 @@ -Showcase - Non-UI Tag - Example Submited + Struts2 Showcase - UI Tags Example (Velocity) - Example Submited + -

Example Submitted

- - #slabel ("label=Name" "name=name") - #slabel ("label=Birthday" "name=birthday") - - - - - #slabel ("label=Biography" "name=bio") - #slabel ("label=Favourite Color" "name=favouriteColor") - #slabel ("label=Friends" "name=friends") - #slabel ("label=Legal Age" "name=legalAge") - #slabel ("label=Region" "name=region") - #slabel ("label=State" "name=state") - #slabel ("label=Picture" "name=picture") - #slabel ("label=Favourite Language" "name=favouriteLanguage") - #slabel ("label=Favourite Vehical Type" "name=favouriteVehicalType") - #slabel ("label=Favourite Vehical Specific" "name=favouriteVehicalSpecific") - - - - - - - - -
- #sdate ("name=wakeup" "format=hh:mm aa") -
Favourite Cartoon Characters (Left): - #set ( $startCount = 1) - #foreach( $item in $leftSideCartoonCharacters) - $startCount.${item}  - #set ( $startCount = $startCount + 1) - #end -
Favourite Cartoon Characters (Right): - #set ( $startCount = 1) - #foreach( $item in $rightSideCartoonCharacters) - $startCount.${item}  - #set ( $startCount = $startCount + 1) - #end -
+
+
+
-#surl ("id=url" "value=index.jsp") -#sa("href=${url}")Back to index.jsp#end + + #slabel ("label=Name" "name=name") + #slabel ("label=Birthday" "name=birthday") + + + + + #slabel ("label=Biography" "name=bio") + #slabel ("label=Favourite Color" "name=favouriteColor") + #slabel ("label=Friends" "name=friends") + #slabel ("label=Legal Age" "name=legalAge") + #slabel ("label=Region" "name=region") + #slabel ("label=State" "name=state") + #slabel ("label=Picture" "name=picture") + #slabel ("label=Favourite Language" "name=favouriteLanguage") + #slabel ("label=Favourite Vehical Type" "name=favouriteVehicalType") + #slabel ("label=Favourite Vehical Specific" "name=favouriteVehicalSpecific") + + + + + + + + +
+ #sdate ("name=wakeup" "format=hh:mm aa") +
Favourite Cartoon Characters (Left): + #set ( $startCount = 1) + #foreach( $item in $leftSideCartoonCharacters) + $startCount.${item}  + #set ( $startCount = $startCount + 1) + #end +
Favourite Cartoon Characters (Right): + #set ( $startCount = 1) + #foreach( $item in $rightSideCartoonCharacters) + $startCount.${item}  + #set ( $startCount = $startCount + 1) + #end +
+ #surl ("id=url" "value=index.jsp") + #sa("href=${url}")Back to index.jsp#end +
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/index.jsp b/apps/showcase/src/main/webapp/tags/ui/index.jsp deleted file mode 100644 index cd14b48d4..000000000 --- a/apps/showcase/src/main/webapp/tags/ui/index.jsp +++ /dev/null @@ -1,25 +0,0 @@ -<%@taglib prefix="s" uri="/struts-tags" %> - - - - Showcase - Tags - UI Tags - - -

UI Tags

- -
    -
  • UI Example
  • -
  • UI Example (Velocity)
  • -
  • Option Transfer Select UI Example
  • -
  • More Select Box UI Examples
  • -
  • Tree Example (static) -
  • Tree Example (dynamic) -
  • Tree Example (dynamic ajax loading) -
  • Component Tag Example -
  • Action Tag Example
  • -
  • DateTime picker tag - Pick a date
  • -
  • DateTime picker tag - Pick a time
  • - <%--li>UI population using iterator tag -
- - diff --git a/apps/showcase/src/main/webapp/tags/ui/lotsOfOptiontransferselect.jsp b/apps/showcase/src/main/webapp/tags/ui/lotsOfOptiontransferselect.jsp index d267ce583..d4aca42d1 100644 --- a/apps/showcase/src/main/webapp/tags/ui/lotsOfOptiontransferselect.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/lotsOfOptiontransferselect.jsp @@ -1,93 +1,101 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Show Case - Tags - UI Tags - Optiontransferselect - + Struts2 Showcase - UI Tags - Optiontransferselect + + - - - -
- - - -
- - - -
- - - -
+
+
+
- -
- - - + + +
+ + + +
+ + + +
+ + + +
+ + +
+ + +
+
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tags/ui/lotsOfOptiontransferselectSubmit.jsp b/apps/showcase/src/main/webapp/tags/ui/lotsOfOptiontransferselectSubmit.jsp index 04d915b18..03d6adc7c 100644 --- a/apps/showcase/src/main/webapp/tags/ui/lotsOfOptiontransferselectSubmit.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/lotsOfOptiontransferselectSubmit.jsp @@ -1,94 +1,103 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tags - UI Tags - Optiontransferoption Result + Struts2 Showcase - UI Tags - Optiontransferselect Result + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - -
Favourite Cartoons: - - .  - -
Non Favourite Cartoons: - - .  - -
Favourite Cars: - - .  - -
Non Favourite Cars: - - .  - -
Favourite Motorcycles: - - .  - -
Non Favourite Motorcycles: - - .  - -
Favourite Countries: - - .  - -
Non Favourite Countries: - - .  - -
Favourite Sports: - - .  - -
Non Favourite Sports: - - .  - -
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Favourite Cartoons: + + .  + +
Non Favourite Cartoons: + + .  + +
Favourite Cars: + + .  + +
Non Favourite Cars: + + .  + +
Favourite Motorcycles: + + .  + +
Non Favourite Motorcycles: + + .  + +
Favourite Countries: + + .  + +
Non Favourite Countries: + + .  + +
Favourite Sports: + + .  + +
Non Favourite Sports: + + .  + +
+
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/moreSelects.jsp b/apps/showcase/src/main/webapp/tags/ui/moreSelects.jsp index 6b00b3466..39019f043 100644 --- a/apps/showcase/src/main/webapp/tags/ui/moreSelects.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/moreSelects.jsp @@ -1,61 +1,69 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Show Case - Tags - UI Tags - Optiontransferselect - + Struts2 Showcase - UI Tags - More Select Box UI Examples + + - +
+
+
- - -
- - - -
- - - -
+ - + - +
- - -
- -
+ +
+ + + +
+ + + + + + + +
+ + +
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tags/ui/moreSelectsSubmit.jsp b/apps/showcase/src/main/webapp/tags/ui/moreSelectsSubmit.jsp index 7b79c86c3..82a0a70a8 100644 --- a/apps/showcase/src/main/webapp/tags/ui/moreSelectsSubmit.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/moreSelectsSubmit.jsp @@ -1,53 +1,63 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Tags - UI Tags - Select Boxes Result + Struts2 Showcase - UI Tags - More Select Box UI Examples - Result + - - - - - - - - - - - - - - - - - - - - - - -
Prioritised Favourite Cartoon Characters: - - .  - -
Prioritised Favourite Cars: - - .  - -
Prioritised Favourite Countries - - .  - -
Favourite Cities - - .  - -
Favourite Numbers - - .  - -
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Prioritised Favourite Cartoon Characters: + + .  + +
Prioritised Favourite Cars: + + .  + +
Prioritised Favourite Countries + + .  + +
Favourite Cities + + .  + +
Favourite Numbers + + .  + +
+
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/timepicker/index.jsp b/apps/showcase/src/main/webapp/tags/ui/timepicker/index.jsp index fc81079cf..4c98f127b 100644 --- a/apps/showcase/src/main/webapp/tags/ui/timepicker/index.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/timepicker/index.jsp @@ -1,22 +1,31 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ taglib prefix="s" uri="/struts-tags" %> +<%@taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> - - UI Tags Example - + Struts2 Showcase - UI Tags - Timepicker Tag + - - - - - - - - - -
+ + +
+
+
+ + + + + + + + + + +
+
+
+
diff --git a/apps/showcase/src/main/webapp/tags/ui/treeExampleAjaxDynamic.jsp b/apps/showcase/src/main/webapp/tags/ui/treeExampleAjaxDynamic.jsp index 951f5dec0..e858fd5e4 100644 --- a/apps/showcase/src/main/webapp/tags/ui/treeExampleAjaxDynamic.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/treeExampleAjaxDynamic.jsp @@ -1,18 +1,25 @@ <%@taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> - -Showcase - UI Tag Example - Tree Example (Dynamic) - + Struts2 Showcase - UI Tags - Tree Example AJAX (Dynamic) + - - - -
- + +
+
+
+ + +
+ +
+
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tags/ui/treeExampleDynamic.jsp b/apps/showcase/src/main/webapp/tags/ui/treeExampleDynamic.jsp index 5e280434e..07a5adba0 100644 --- a/apps/showcase/src/main/webapp/tags/ui/treeExampleDynamic.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/treeExampleDynamic.jsp @@ -1,46 +1,54 @@ <%@taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> - -Showcase - UI Tag Example - Tree Example (Dynamic) - + Struts2 Showcase - UI Tags - Tree Example (Dynamic) + - - - - - - - -
- - + -
-Please click on any of the tree nodes. +
+
+
+ + + + + + + +
+ + +
+ +
+ Please click on any of the tree nodes. +
+ + +
+
- - - \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tags/ui/treeExampleStatic.jsp b/apps/showcase/src/main/webapp/tags/ui/treeExampleStatic.jsp index 104834946..76ab07414 100644 --- a/apps/showcase/src/main/webapp/tags/ui/treeExampleStatic.jsp +++ b/apps/showcase/src/main/webapp/tags/ui/treeExampleStatic.jsp @@ -2,51 +2,60 @@ <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> -Showcase - UI Tag Example - Tree Example (Static) + Struts2 Showcase - UI Tags - Tree Example (Static) - - - - - - -
- - - - - - - - - - - - - - + +
+
+
-
-Please click on any node on the tree. + + + + + +
+ + + + + + + + + + + + + + +
+ + +
+ Please click on any node on the tree. +
+ + +
+
- - - \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tiles/body.ftl b/apps/showcase/src/main/webapp/tiles/body.ftl index 9baa1b4c0..bdaac0518 100644 --- a/apps/showcase/src/main/webapp/tiles/body.ftl +++ b/apps/showcase/src/main/webapp/tiles/body.ftl @@ -1,10 +1,16 @@ -
-

This example illustrates the freemarker support in the Struts/Tiles Plugin.

+
+
+
+
+

This example illustrates the freemarker support in the Struts/Tiles Plugin.

-

Tiles 2 is an effort to extract the Tiles library from Struts. It is currently housed - in the Sandbox area of the Apache Struts Subversion repository.

+

Tiles 2 is an effort to extract the Tiles library from Struts. It is currently housed + in the Sandbox area of the Apache Struts Subversion repository.

- <@s.form> - <@s.textfield name="Textfield" value="Textfield"/> - + <@s.form> + <@s.textfield name="Textfield" value="Textfield"/> + +
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tiles/body.jsp b/apps/showcase/src/main/webapp/tiles/body.jsp index da89efdbf..095762f14 100644 --- a/apps/showcase/src/main/webapp/tiles/body.jsp +++ b/apps/showcase/src/main/webapp/tiles/body.jsp @@ -1,18 +1,24 @@ <%@taglib prefix="s" uri="/struts-tags" %> -
-

This example illustrates the Struts/Tiles Plugin.

+
+
+
+
+

This example illustrates the Struts/Tiles Plugin.

-

Tiles 2 is an effort to extract the Tiles library from Struts. It is currently housed - in the Sandbox area of the Apache Struts Subversion repository.

+

Tiles 2 is an effort to extract the Tiles library from Struts. It is currently housed + in the Sandbox area of the Apache Struts Subversion repository.

-

Features

- +

Features

+ +
+
+
\ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tiles/header.jsp b/apps/showcase/src/main/webapp/tiles/header.jsp index 38912df9c..d98f0010a 100644 --- a/apps/showcase/src/main/webapp/tiles/header.jsp +++ b/apps/showcase/src/main/webapp/tiles/header.jsp @@ -1 +1,3 @@ -

${title}

+ diff --git a/apps/showcase/src/main/webapp/tiles/layout.ftl b/apps/showcase/src/main/webapp/tiles/layout.ftl index 010d56012..9ce5915b5 100644 --- a/apps/showcase/src/main/webapp/tiles/layout.ftl +++ b/apps/showcase/src/main/webapp/tiles/layout.ftl @@ -1,12 +1,10 @@ <#assign tiles=JspTaglibs["http://tiles.apache.org/tags-tiles"]> <@tiles.importAttribute name="title" scope="request"/> - <@tiles.getAsString name="title"/> + Struts2 Showcase - <@tiles.getAsString name="title"/> <@tiles.insertAttribute name="header"/> -

- <@tiles.insertAttribute name="body"/> -

+ <@tiles.insertAttribute name="body"/>

Notice that this is a layout made in FreeMarker

diff --git a/apps/showcase/src/main/webapp/tiles/layout.jsp b/apps/showcase/src/main/webapp/tiles/layout.jsp index 9caca1183..964d014a8 100644 --- a/apps/showcase/src/main/webapp/tiles/layout.jsp +++ b/apps/showcase/src/main/webapp/tiles/layout.jsp @@ -4,14 +4,10 @@ <%-- Show usage; Used in Header --%> - <tiles:getAsString name="title"/> + Struts2 Showcase - <tiles:getAsString name="title"/> - -

- -

- +

Notice that this is a layout made in JSP

diff --git a/apps/showcase/src/main/webapp/token/doublePost.jsp b/apps/showcase/src/main/webapp/token/doublePost.jsp index fb668c68d..761d44b75 100644 --- a/apps/showcase/src/main/webapp/token/doublePost.jsp +++ b/apps/showcase/src/main/webapp/token/doublePost.jsp @@ -1,15 +1,28 @@ <%@ taglib prefix="s" uri="/struts-tags" %> + Struts2 Showcase - Token Examples - Double post -

- Double post. Struts intercepted this request and prevents the action from executing again. -

+ -

- Click here to return. +

+
+
+ +

+ Double post. Struts intercepted this request and prevents the action from executing again. +

+ +

+ Click here to + return. +

+
+
diff --git a/apps/showcase/src/main/webapp/token/example1.jsp b/apps/showcase/src/main/webapp/token/example1.jsp index 99aa5b809..949567188 100644 --- a/apps/showcase/src/main/webapp/token/example1.jsp +++ b/apps/showcase/src/main/webapp/token/example1.jsp @@ -1,3 +1,43 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Token Examples - Example 1 + + + + + + +
+
+
+ +

+ Example 1: This example illustrates a situation where you can transfer money from + one account to another. We use the token to prevent double posts so the transfer only + happens once. +

+ +

+
Balance of source account: +
Balance of destination account: +

+ + + + + + + +

+
+
+ + + + <%@ taglib prefix="s" uri="/struts-tags" %> Token Examples @@ -5,20 +45,6 @@

Token Example 1

- Example 1: This example illustrates a situation where you can transfer money from - one account to another. We use the token to prevent double posts so the transfer only - happens once. -

- -
Balance of source account: -
Balance of destination account: -

- - - - - - diff --git a/apps/showcase/src/main/webapp/token/example2.jsp b/apps/showcase/src/main/webapp/token/example2.jsp index c3d99c4a0..7042ce836 100644 --- a/apps/showcase/src/main/webapp/token/example2.jsp +++ b/apps/showcase/src/main/webapp/token/example2.jsp @@ -1,24 +1,38 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Token Examples + + Struts2 Showcase - Token Examples - Example 2 + -

Token Example 2

+ - Example 2: This example illustrates a situation where you can transfer money from - one account to another. We use the token to prevent double posts so the transfer only - happens once. This action will redirect after you have submitted the form. -

-
Balance of source account: -
Balance of destination account: -

+

+
+
- - - - - +

+ Example 2: This example illustrates a situation where you can transfer money from + one account to another. We use the token to prevent double posts so the transfer only + happens once. This action will redirect after you have submitted the form. +

+

+ Balance of source account: +
Balance of destination account: +

+ + + + + + + +

+
+
diff --git a/apps/showcase/src/main/webapp/token/example3.jsp b/apps/showcase/src/main/webapp/token/example3.jsp index c624ad6b7..4cf2b5ae6 100644 --- a/apps/showcase/src/main/webapp/token/example3.jsp +++ b/apps/showcase/src/main/webapp/token/example3.jsp @@ -1,24 +1,37 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Token Examples + + Struts2 Showcase - Token Examples - Example 3 + -

Token Example 3

+ - Example 3: This example illustrates a situation where you can transfer money from - one account to another. We use the token to prevent double posts so the transfer only - happens once. This example uses the token session based interceptor and redirect after post. -

-
Balance of source account: -
Balance of destination account: -

+

+
+
- - - - - +

+ Example 3: This example illustrates a situation where you can transfer money from + one account to another. We use the token to prevent double posts so the transfer only + happens once. This example uses the token session based interceptor and redirect after post. +

+

Balance of source account: +
Balance of destination account: +

+ + + + + + + +

+
+
diff --git a/apps/showcase/src/main/webapp/token/example4.ftl b/apps/showcase/src/main/webapp/token/example4.ftl index f890ba30c..e66b0453a 100644 --- a/apps/showcase/src/main/webapp/token/example4.ftl +++ b/apps/showcase/src/main/webapp/token/example4.ftl @@ -1,26 +1,40 @@ - Token Examples + + Struts2 Showcase - Token Examples - Example 4 + -

Token Example 4

+ - Example 4: This example illustrates a situation where you can transfer money from - one account to another. We use the token to prevent double posts so the transfer only - happens once. This page is rendered using freemarker. See the xwork-token.xml where - we must also use the createSession interceptor to be sure that a HttpSession exists - when freemarker renders this webpage, otherwise the @s.token tag causes an exception - while rendering the page. -

-
Balance of source account: <@s.property value="#session.balanceSource"/> -
Balance of destination account: <@s.property value="#session.balanceDestination"/> -

+

+
+
- <@s.form action="transfer4"> - <@s.token/> - <@s.textfield label="Amount" name="amount" required="true" value="400"/> - <@s.submit value="Transfer money"/> - +

+ Example 4: This example illustrates a situation where you can transfer money from + one account to another. We use the token to prevent double posts so the transfer only + happens once. This page is rendered using freemarker. See the xwork-token.xml where + we must also use the createSession interceptor to be sure that a HttpSession exists + when freemarker renders this webpage, otherwise the @s.token tag causes an exception + while rendering the page. +

+ +

Balance of source account: <@s.property value="#session.balanceSource"/> +
Balance of destination account: <@s.property value="#session.balanceDestination"/> + +

+ + <@s.form action="transfer4"> + <@s.token/> + <@s.textfield label="Amount" name="amount" required="true" value="400"/> + <@s.submit value="Transfer money" cssClass="btn btn-primary"/> + +

+
+
diff --git a/apps/showcase/src/main/webapp/token/index.jsp b/apps/showcase/src/main/webapp/token/index.jsp index 12908101b..b65ff4edc 100644 --- a/apps/showcase/src/main/webapp/token/index.jsp +++ b/apps/showcase/src/main/webapp/token/index.jsp @@ -1,33 +1,48 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Token Examples (double post) + + Struts2 Showcase - Token Examples (double post) + -

Token Examples

+ - These examples illustrate Struts build in support of using tokens to prevent double post. -

- You have a web page where user can input data and press a button to submit. - There could be a problem that the user submit the data many times, by either clicking the - button many times, or use the browser back button and then submit the form again. -
A good solution is to use a hidden token in the form. The token is autogenerated and unique - from time to time. This token is then validated with the HttpSession that it is the first time - it is submitted, if not we have a double post and therefore can prevent the second submit action. -

- For more information check out javadoc for org.apache.struts2.interceptor.TokenInterceptor - and org.apache.struts2.interceptor.TokenSessionStoreInterceptor. -
-
Example 1 (token based .jsp example) +

+
+
-
-
Example 2 (as example 1 with redirect after post) +

+ These examples illustrate Struts build in support of using tokens to prevent double post. +

+

+ You have a web page where user can input data and press a button to submit. + There could be a problem that the user submit the data many times, by either clicking the + button many times, or use the browser back button and then submit the form again. +
A good solution is to use a hidden token in the form. The token is autogenerated and unique + from time to time. This token is then validated with the HttpSession that it is the first time + it is submitted, if not we have a double post and therefore can prevent the second submit action. +

+

+ For more information check out javadoc for org.apache.struts2.interceptor.TokenInterceptor + and org.apache.struts2.interceptor.TokenSessionStoreInterceptor. +

-
-
Example 3 (token-session based .jsp example) +
+
Example 1 (token based .jsp example) -
-
Example 4 (token based freemarker example) +
+
Example 2 (as example 1 with redirect after post) +
+
Example 3 (token-session based .jsp example) + +
+
Example 4 (token based freemarker example) +

+
+
diff --git a/apps/showcase/src/main/webapp/token/transferDone.jsp b/apps/showcase/src/main/webapp/token/transferDone.jsp index 8d2746a8a..a67078c2d 100644 --- a/apps/showcase/src/main/webapp/token/transferDone.jsp +++ b/apps/showcase/src/main/webapp/token/transferDone.jsp @@ -1,25 +1,48 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Token Examples (double post) + + Struts2 Showcase - Token Examples - Transfer is Done + -

Token Examples

+ - The transfer is done at -
New balance of source account: -
New balance of destination account: +
+
+
-

- Try using the browser back button and submit the form again. This should result in a double post - that Struts should intercept and handle accordingly. -

- For example 3 (session token) you should notice that the date/time stays the same. This interceptor - catches that this is a double post but doens't display the double post page, but just renders the - web page result from the first post. +

+ The transfer is done at + + + -

- Click here to return. +
New balance of source account: + +
New balance of destination account: + +

+ +

+ Try using the browser back button and submit the form again. This should result in a double post + that Struts should intercept and handle accordingly. + +

+ +

+ For example 3 (session token) you should notice that the date/time stays the same. This interceptor + catches that this is a double post but doens't display the double post page, but just renders the + web page result from the first post. + +

+ Click here to + return. +

+
+
- + \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/validation/clientSideValidationExample.jsp b/apps/showcase/src/main/webapp/validation/clientSideValidationExample.jsp index ed1407120..f199c311b 100644 --- a/apps/showcase/src/main/webapp/validation/clientSideValidationExample.jsp +++ b/apps/showcase/src/main/webapp/validation/clientSideValidationExample.jsp @@ -8,48 +8,57 @@ <%@taglib prefix="s" uri="/struts-tags" %> - - Showcase - Validation - Field Validators Example - - - - - + + Struts2 Showcase - Validation - Field Validators Example + + + - + -

All Field Errors Will Appear Here

- -
+
+
+
-

Field Error due to 'Required String Validator Field' Will Appear Here

- - - -
+ -

Field Error due to 'String Length Validator Field' Will Appear Here

- - stringLengthValidatorField - -
+

All Field Errors Will Appear Here

+ +
- - - - - - - - - - - - +

Field Error due to 'Required String Validator Field' Will Appear Here

+ + + +
- +

Field Error due to 'String Length Validator Field' Will Appear Here

+ + stringLengthValidatorField + +
+ + + + + + + + + + + + + + + - - + +
+
+
+ diff --git a/apps/showcase/src/main/webapp/validation/fieldValidatorsExample.jsp b/apps/showcase/src/main/webapp/validation/fieldValidatorsExample.jsp index 1b8aecca2..f41a4bbe2 100644 --- a/apps/showcase/src/main/webapp/validation/fieldValidatorsExample.jsp +++ b/apps/showcase/src/main/webapp/validation/fieldValidatorsExample.jsp @@ -8,48 +8,55 @@ <%@taglib prefix="s" uri="/struts-tags" %> - - Showcase - Validation - Field Validators Example - - - - - - - - -

All Field Errors Will Appear Here

- -
- -

Field Error due to 'Required String Validator Field' Will Appear Here

- - - -
- -

Field Error due to 'String Length Validator Field' Will Appear Here

- - stringLengthValidatorField - -
- - - - - - - - - - - - - - - - - - - + + Struts2 Showcase - Validation - Field Validators Example + + + + + + +
+
+
+ +

All Field Errors Will Appear Here

+ +
+ +

Field Error due to 'Required String Validator Field' Will Appear Here

+ + + +
+ +

Field Error due to 'String Length Validator Field' Will Appear Here

+ + stringLengthValidatorField + +
+ + + + + + + + + + + + + + + + + + +
+
+
+ diff --git a/apps/showcase/src/main/webapp/validation/footer.jsp b/apps/showcase/src/main/webapp/validation/footer.jsp index 57ce7f097..20fa2ad8b 100644 --- a/apps/showcase/src/main/webapp/validation/footer.jsp +++ b/apps/showcase/src/main/webapp/validation/footer.jsp @@ -5,5 +5,4 @@ -Back To Validation Examples  -Back To Showcase + Back To Validation Examples diff --git a/apps/showcase/src/main/webapp/validation/index.jsp b/apps/showcase/src/main/webapp/validation/index.jsp index 63f51f9cd..661d032bd 100644 --- a/apps/showcase/src/main/webapp/validation/index.jsp +++ b/apps/showcase/src/main/webapp/validation/index.jsp @@ -8,35 +8,44 @@ <%@taglib prefix="s" uri="/struts-tags" %> - - Showcase - Validation - - -

Validation Examples

- - - - - - - - - - - - -
    -
  • Field Validators
  • -
  • Field Validators with client-side JavaScript
  • -
  • Non Field Validator
  • -
  • Store across request using MessageStoreInterceptor (Example)
  • -
  • Validation (ajax)
  • -
  • Validation (basic)
  • -
  • Validation (client)
  • -
  • Validation (client using css_xhtml theme)
  • -
  • Visitor Validator
  • -
  • Back To Showcase -
- + + Struts2 Showcase - Validation + + + + + +
+
+
+ + + + + + + + + + + + +
    +
  • Field Validators
  • +
  • Field Validators with client-side JavaScript
  • +
  • Non Field Validator
  • +
  • Store across request using MessageStoreInterceptor (Example)
  • +
  • Validation (ajax)
  • +
  • Validation (basic)
  • +
  • Validation (client)
  • +
  • Validation (client using css_xhtml theme)
  • +
  • Visitor Validator
  • +
+
+
+
+ diff --git a/apps/showcase/src/main/webapp/validation/nonFieldValidatorsExample.jsp b/apps/showcase/src/main/webapp/validation/nonFieldValidatorsExample.jsp index c1245f1bd..27c8f8b2b 100644 --- a/apps/showcase/src/main/webapp/validation/nonFieldValidatorsExample.jsp +++ b/apps/showcase/src/main/webapp/validation/nonFieldValidatorsExample.jsp @@ -9,30 +9,38 @@ <%@taglib prefix="s" uri="/struts-tags" %> - - Showcase - Validation - Non Field Validator Example - - - - - - - - - - - - - - - - - - - - - - - + + Struts2 Showcase - Validation - Non Field Validator Example + + + + + + +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ diff --git a/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp b/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp index ff76b7a29..9ce9bdb51 100644 --- a/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp +++ b/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp @@ -5,85 +5,100 @@ - Validation - Ajax - + Struts2 Showcase - Validation - Ajax + -
1.Use AJAX validation, and AJAX request (ajaxAfterValidation="true"), if validation succeeds
- -
- Response goes here + -
+
+
+
+
1.Use AJAX validation, and AJAX request (ajaxAfterValidation="true"), if validation succeeds
- - - - - - +
+ Response goes here +
-Submit Form with a link -

+
-Submit Form listening to an event on an element (check to submit) - + + + + + + -



+ Submit Form with a link +

-
2.Use AJAX validation, and regular request (ajaxAfterValidation="false", default), if validation succeeds
-
+ Submit Form listening to an event on an element (check to submit) + - - - - - - +



-Submit Form with a link -

+
2.Use AJAX validation, and regular request (ajaxAfterValidation="false", default), if validation + succeeds
+
-Submit Form listening to an event on an element (check to submit) - + + + + + + + + Submit Form with a link +

+ + Submit Form listening to an event on an element (check to submit) + + +
+
+
- diff --git a/apps/showcase/src/main/webapp/validation/quiz-basic.jsp b/apps/showcase/src/main/webapp/validation/quiz-basic.jsp index 6d75c51d6..e7cb1f9da 100644 --- a/apps/showcase/src/main/webapp/validation/quiz-basic.jsp +++ b/apps/showcase/src/main/webapp/validation/quiz-basic.jsp @@ -4,24 +4,38 @@ - Validation - Basic - + Struts2 Showcase - Validation - Basic + -What is your favorite color? -

+

- - - - - - +
+
+
+

+ What is your favorite color? + +

+ + + + + + + + + + +

+
+
- diff --git a/apps/showcase/src/main/webapp/validation/quiz-client-css.jsp b/apps/showcase/src/main/webapp/validation/quiz-client-css.jsp index ac62bb2b7..c6758935f 100644 --- a/apps/showcase/src/main/webapp/validation/quiz-client-css.jsp +++ b/apps/showcase/src/main/webapp/validation/quiz-client-css.jsp @@ -4,21 +4,34 @@ - Validation - Basic - + Struts2 Showcase - Validation - Basic (CSS Theme) + - - - - - - + +
+
+
+ + + + + + + + + + +
+
+
- + diff --git a/apps/showcase/src/main/webapp/validation/quiz-client.jsp b/apps/showcase/src/main/webapp/validation/quiz-client.jsp index 0517e0569..27268b897 100644 --- a/apps/showcase/src/main/webapp/validation/quiz-client.jsp +++ b/apps/showcase/src/main/webapp/validation/quiz-client.jsp @@ -4,21 +4,34 @@ - Validation - Basic - + Struts2 Showcase - Validation - Basic + - - - - - - + +
+
+
+ + + + + + + + + + +
+
+
- + diff --git a/apps/showcase/src/main/webapp/validation/quiz-success.jsp b/apps/showcase/src/main/webapp/validation/quiz-success.jsp index 738097a6c..58180bba0 100644 --- a/apps/showcase/src/main/webapp/validation/quiz-success.jsp +++ b/apps/showcase/src/main/webapp/validation/quiz-success.jsp @@ -1,14 +1,27 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Quiz submitted! + Struts2 Showcase - Validation - Quiz submitted! + -Thank you, . Your answer has been submitted as: + - +
+
+
+ Thank you, . Your answer has been submitted as: + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestCancel.jsp b/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestCancel.jsp index ba2097864..fd9fb55f3 100644 --- a/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestCancel.jsp +++ b/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestCancel.jsp @@ -1,21 +1,30 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> - -<%@taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="s" uri="/struts-tags" %> - -Insert title here + Struts2 Showcase - Validation - Store Errors Across Request Example + + - - - + -

Application Canceled

- - Try Again +
+
+
+ + + + + + + Try Again + + +
+
+
- diff --git a/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestExample.jsp b/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestExample.jsp index 96d81aa3c..939e0ace1 100644 --- a/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestExample.jsp +++ b/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestExample.jsp @@ -1,44 +1,54 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@ taglib prefix="s" uri="/struts-tags" %> - -Showcase - Validation - Store Errors Across Request Example + Struts2 Showcase - Validation - Store Errors Across Request Example + + -

- This is an example demonstrating the use of MessageStoreInterceptor. - When this form is submited a redirect is issue both when there's a validation - error or not. Normally, when a redirect is issue the action messages / errors and - field errors stored in the action will be lost (due to an action lives - only as long as a request). With a MessageStoreInterceptor in place and - configured, the action errors / messages / field errors will be store and - remains retrieveable even after a redirect. -

- - - -
ActionMessages:
ActionErrors:
+ -

- - - - - - -

-

- Try submitting with an invalid age value, - and note that the browser location changes, - but validation messages are retained. - Because of the redirect, - the input values are not retained. -

+
+
+
+

+ This is an example demonstrating the use of MessageStoreInterceptor. + When this form is submited a redirect is issue both when there's a validation + error or not. Normally, when a redirect is issue the action messages / errors and + field errors stored in the action will be lost (due to an action lives + only as long as a request). With a MessageStoreInterceptor in place and + configured, the action errors / messages / field errors will be store and + remains retrieveable even after a redirect. +

+ + + + +
ActionMessages:
ActionErrors:
+ +

+ + + + + + +

+

+ Try submitting with an invalid age value, + and note that the browser location changes, + but validation messages are retained. + Because of the redirect, + the input values are not retained. +

+ + +
+
+
- diff --git a/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestOk.jsp b/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestOk.jsp index e2ec2a410..6c5ddb13e 100644 --- a/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestOk.jsp +++ b/apps/showcase/src/main/webapp/validation/storeErrorsAcrossRequestOk.jsp @@ -1,23 +1,31 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<%@taglib prefix="s" uri="/struts-tags" %> - +<%@ taglib prefix="s" uri="/struts-tags" %> - -Showcase - Validation - Store Errors Across Request Example + Struts2 Showcase - Validation - Store Errors Across Request Example + + - - - + -

Ok !

- - - Try Again +
+
+
+ + + + + + Try Again + + +
+
+
diff --git a/apps/showcase/src/main/webapp/validation/successClientSideValidationExample.jsp b/apps/showcase/src/main/webapp/validation/successClientSideValidationExample.jsp index 77f111c2d..cb56e9c1f 100644 --- a/apps/showcase/src/main/webapp/validation/successClientSideValidationExample.jsp +++ b/apps/showcase/src/main/webapp/validation/successClientSideValidationExample.jsp @@ -6,12 +6,22 @@ --%> <%@taglib prefix="s" uri="/struts-tags" %> - - Showcase - Validation - SuccessFieldValidatorsExample - -

Success !

- + + Struts2 Showcase - Validation - Success Client Side Validators Example + + + + + + +
+
+
+ +
@@ -47,7 +57,8 @@
Required Validator Field:
- - +
+
+
+ - diff --git a/apps/showcase/src/main/webapp/validation/successFieldValidatorsExample.jsp b/apps/showcase/src/main/webapp/validation/successFieldValidatorsExample.jsp index 5e83be49c..f795bcc46 100644 --- a/apps/showcase/src/main/webapp/validation/successFieldValidatorsExample.jsp +++ b/apps/showcase/src/main/webapp/validation/successFieldValidatorsExample.jsp @@ -5,14 +5,25 @@ @version $Date$ $Id$ --%> -<%@taglib prefix="s" uri="/struts-tags" %> +<%@taglib prefix="s" uri="/struts-tags" %> - Showcase - Validation - SuccessFieldValidatorsExample - -

Success !

- - + + Struts2 Showcase - Validation - Success Field Validators Example + + + + + + +
+
+
+ +
+ @@ -43,6 +54,8 @@
Required Validator Field:
- +
+
+
+ - diff --git a/apps/showcase/src/main/webapp/validation/successNonFieldValidatorsExample.jsp b/apps/showcase/src/main/webapp/validation/successNonFieldValidatorsExample.jsp index bc22e4fa9..40333006d 100644 --- a/apps/showcase/src/main/webapp/validation/successNonFieldValidatorsExample.jsp +++ b/apps/showcase/src/main/webapp/validation/successNonFieldValidatorsExample.jsp @@ -7,12 +7,22 @@ <%@taglib prefix="s" uri="/struts-tags" %> - - Showcase - Validation - SuccessNonFieldValidatorsExample - -

Success !

- + + Struts2 Showcase - Validation - Success Non Field Validators Example + + + + + + +
+
+
+ +
@@ -28,6 +38,8 @@
Some Text:
- +
+
+
+ - diff --git a/apps/showcase/src/main/webapp/validation/successVisitorValidatorsExample.jsp b/apps/showcase/src/main/webapp/validation/successVisitorValidatorsExample.jsp index 90e2b42ad..6eecc629a 100644 --- a/apps/showcase/src/main/webapp/validation/successVisitorValidatorsExample.jsp +++ b/apps/showcase/src/main/webapp/validation/successVisitorValidatorsExample.jsp @@ -6,14 +6,23 @@ --%> - <%@taglib prefix="s" uri="/struts-tags" %> - - Showcase - Validation - SuccessVisitorValidatorsExameple - -

Success !

- + + Struts2 Showcase - Validation - Success Visitor Validators Exameple + + + + + + +
+
+
+ +
@@ -29,7 +38,9 @@
User Name:
- - - +
+ + + + diff --git a/apps/showcase/src/main/webapp/validation/validationExamplesStyles.css b/apps/showcase/src/main/webapp/validation/validationExamplesStyles.css deleted file mode 100644 index 961be7c2b..000000000 --- a/apps/showcase/src/main/webapp/validation/validationExamplesStyles.css +++ /dev/null @@ -1,11 +0,0 @@ -@CHARSET "UTF-8"; - -@CHARSET "UTF-8"; - -.errorMessage { - color: red; -} - -/*.errorLabel { - color: red; -}*/ diff --git a/apps/showcase/src/main/webapp/validation/visitorValidatorsExample.jsp b/apps/showcase/src/main/webapp/validation/visitorValidatorsExample.jsp index b78ce2a77..06ee70e6e 100644 --- a/apps/showcase/src/main/webapp/validation/visitorValidatorsExample.jsp +++ b/apps/showcase/src/main/webapp/validation/visitorValidatorsExample.jsp @@ -7,30 +7,37 @@ <%@taglib prefix="s" uri="/struts-tags" %> - -Showcase - Validation - VisitorValidatorsExample - - - + + Struts2 Showcase - Validation - Visitor Validators Example + - - - + - - - - - - - - - - - +
+
+
+ + + + + + + + + + + + + + + +
+
+
- diff --git a/apps/showcase/src/main/webapp/viewSource.jsp b/apps/showcase/src/main/webapp/viewSource.jsp index 16ccfae0f..84448de01 100644 --- a/apps/showcase/src/main/webapp/viewSource.jsp +++ b/apps/showcase/src/main/webapp/viewSource.jsp @@ -1,40 +1,54 @@ <%@ taglib prefix="s" uri="/struts-tags" %> -<%@ taglib prefix="sx" uri="/struts-dojo-tags" %> View Sources - - -

View Sources

- - -

-
-
-${row.count}: 
-
-
- -

-
+
+
+
+

View Sources

- -${configLine - padding + row.count - 1}: -${configLine - padding + row.count - 1}: -
-
- -

-
-
-${row.count}: 
-
-
- -
+ +
+
+

+
+						
+
+					
+
+
+

+
+						
+
+					
+
+
+

+
+						
+
+					
+
+
+ + + + + + diff --git a/apps/showcase/src/main/webapp/wait/complete.jsp b/apps/showcase/src/main/webapp/wait/complete.jsp index 87a3460cf..9ab7b7884 100644 --- a/apps/showcase/src/main/webapp/wait/complete.jsp +++ b/apps/showcase/src/main/webapp/wait/complete.jsp @@ -1,13 +1,25 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Execute and Wait Examples + + Struts2 Showcase - Execute and Wait Examples - Complete + -

The process is complete

+ - We have processed your request. -

- Click here to return. +

+
+
+ + We have processed your request. +

+ Click here to return. + +

+
+
diff --git a/apps/showcase/src/main/webapp/wait/example1.jsp b/apps/showcase/src/main/webapp/wait/example1.jsp index d3c1d835f..de83f93b8 100644 --- a/apps/showcase/src/main/webapp/wait/example1.jsp +++ b/apps/showcase/src/main/webapp/wait/example1.jsp @@ -1,16 +1,28 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Execute and Wait Examples + + Struts2 Showcase - Execute and Wait Examples - Example 1 + -

Execute and Wait Example 1

- - Example 1: In the form below enter how long time to simulate the process should take. + - - - - +
+
+
+ +

Example 1: In the form below enter how long time to simulate the process should take.

+ + + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/wait/example2.jsp b/apps/showcase/src/main/webapp/wait/example2.jsp index 484636c03..df68dfcbf 100644 --- a/apps/showcase/src/main/webapp/wait/example2.jsp +++ b/apps/showcase/src/main/webapp/wait/example2.jsp @@ -1,17 +1,29 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Execute and Wait Examples + + Struts2 Showcase - Execute and Wait Examples - Example 2 + -

Execute and Wait Example 2

+ - Example 2: As example 1 but uses a delay of 2000 millis before the wait page is shown. Try simulating with - a value of 500 millis to see that no wait page is shown at all. - - - - +
+
+
+

Example 2: As example 1 but uses a delay of 2000 millis before the wait page is shown. Try simulating with + a value of 500 millis to see that no wait page is shown at all.

+ + + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/wait/example3.jsp b/apps/showcase/src/main/webapp/wait/example3.jsp index 3fe65044c..b77baae0c 100644 --- a/apps/showcase/src/main/webapp/wait/example3.jsp +++ b/apps/showcase/src/main/webapp/wait/example3.jsp @@ -1,18 +1,29 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Execute and Wait Examples + + Struts2 Showcase - Execute and Wait Examples - Example 3 + -

Execute and Wait Example 3

+ - Example 3: As example 1 but uses a delay of 3000 millis before the wait page is shown. - While waiting for the wait page it will check every 1000 millis if the background process is already - done. Try simulating with a value of 700 millis to see that the wait page is shown soon thereafter. - - - - +
+
+
+

Example 3: As example 1 but uses a delay of 3000 millis before the wait page is shown. + While waiting for the wait page it will check every 1000 millis if the background process is already + done. Try simulating with a value of 700 millis to see that the wait page is shown soon thereafter.

+ + + + + +
+
+
diff --git a/apps/showcase/src/main/webapp/wait/index.jsp b/apps/showcase/src/main/webapp/wait/index.jsp index 566bc55b4..14f4e1971 100644 --- a/apps/showcase/src/main/webapp/wait/index.jsp +++ b/apps/showcase/src/main/webapp/wait/index.jsp @@ -1,19 +1,34 @@ <%@ taglib prefix="s" uri="/struts-tags" %> - Execute and Wait Examples + + Struts2 Showcase - Execute and Wait Examples + -

Execute and Wait Examples

+ - These examples illustrate Struts build in support for execute and wait. -

- When you have a process that takes a long time your users can be impatient and starts to submit/click again. -
A good solution is to show the user a progress page (wait page) while the process takes it time. -
-
Example 1 (no delay) -
Example 2 (with delay) -
Example 2 (with longer check delay) +

+
+
+ +

+ These examples illustrate Struts build in support for execute and wait. +

+

+ When you have a process that takes a long time your users can be impatient and starts to submit/click again. +
A good solution is to show the user a progress page (wait page) while the process takes it time. +

+ +
+
Example 1 (no delay) +
Example 2 (with delay) +
Example 3 (with longer check delay) +

+
+
diff --git a/apps/showcase/src/main/webapp/wait/wait.jsp b/apps/showcase/src/main/webapp/wait/wait.jsp index 7913943e7..deb8151ed 100644 --- a/apps/showcase/src/main/webapp/wait/wait.jsp +++ b/apps/showcase/src/main/webapp/wait/wait.jsp @@ -1,3 +1,40 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Struts2 Showcase - Execute and Wait Examples - Wait + + + + + + +
+
+
+ +

+ We are processing your request. Please wait. +

+ +
+
+
+ +

+ You can click this link to ">refresh. + + We have processed your request. +

+ Click here to return. + +

+
+
+ + + <%@ taglib prefix="s" uri="/struts-tags" %>