WW-5440 Add missing annotations

This commit is contained in:
Kusal Kithul-Godage
2024-07-13 19:39:13 +10:00
parent 10edbce8d9
commit f9953938f7
123 changed files with 652 additions and 313 deletions
@@ -18,30 +18,30 @@
*/
package org.demo.rest.example;
import java.util.Collection;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.convention.annotation.Result;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.ValidationAwareSupport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;
import java.util.Collection;
@Results({
@Result(name="success", type="redirectAction", params = {"actionName" , "orders"})
})
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>, Validateable{
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>, Validateable {
private static final Logger log = LogManager.getLogger(OrdersController.class);
private Order model = new Order();
private String id;
private Collection<Order> list;
private OrdersService ordersService = new OrdersService();
private final OrdersService ordersService = new OrdersService();
// GET /orders/1
public HttpHeaders show() {
@@ -54,7 +54,7 @@ public class OrdersController extends ValidationAwareSupport implements ModelDri
return new DefaultHttpHeaders("index")
.disableCaching();
}
// GET /orders/1/edit
public String edit() {
return "edit";
@@ -101,13 +101,15 @@ public class OrdersController extends ValidationAwareSupport implements ModelDri
}
}
@StrutsParameter
public void setId(String id) {
if (id != null) {
this.model = ordersService.get(id);
}
this.id = id;
}
@Override
public Object getModel() {
return (list != null ? list : model);
}
@@ -18,11 +18,14 @@
*/
package org.demo.rest.example;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class OrdersService {
private static Map<String,Order> orders = new HashMap<String,Order>();
private static final Map<String,Order> orders = new HashMap<>();
private static int nextId = 6;
static {
orders.put("3", new Order("3", "Bob", 33));
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.ajax.tree.Category;
//START SNIPPET: treeExampleDynamicJavaSelected
@@ -30,7 +31,7 @@ public class DynamicTreeSelectAction extends ActionSupport {
private long nodeId;
private Category currentCategory;
@StrutsParameter
public void setNodeId(long nodeId) {
this.nodeId = nodeId;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -74,6 +75,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteCartoonCharactersKeys;
}
@StrutsParameter
public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) {
_favouriteCartoonCharactersKeys = favouriteCartoonCharacters;
}
@@ -82,6 +84,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _notFavouriteCartoonCharactersKeys;
}
@StrutsParameter
public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) {
_notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters;
}
@@ -108,6 +111,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteCarsKeys;
}
@StrutsParameter
public void setFavouriteCars(List favouriteCars) {
_favouriteCarsKeys = favouriteCars;
}
@@ -116,6 +120,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _notFavouriteCarsKeys;
}
@StrutsParameter
public void setNotFavouriteCars(List notFavouriteCars) {
_notFavouriteCarsKeys = notFavouriteCars;
}
@@ -142,6 +147,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteMotorcyclesKeys;
}
@StrutsParameter
public void setFavouriteMotorcycles(List favouriteMotorcycles) {
_favouriteMotorcyclesKeys = favouriteMotorcycles;
}
@@ -150,6 +156,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _notFavouriteMotorcyclesKeys;
}
@StrutsParameter
public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) {
_notFavouriteMotorcyclesKeys = notFavouriteMotorcycles;
}
@@ -176,6 +183,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteCountriesKeys;
}
@StrutsParameter
public void setFavouriteCountries(List favouriteCountries) {
_favouriteCountriesKeys = favouriteCountries;
}
@@ -184,6 +192,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _notFavouriteCountriesKeys;
}
@StrutsParameter
public void setNotFavouriteCountries(List notFavouriteCountries) {
_notFavouriteCountriesKeys = notFavouriteCountries;
}
@@ -205,6 +214,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteSportsKeys;
}
@StrutsParameter
public void setFavouriteSports(List favouriteSportsKeys) {
this._favouriteSportsKeys = favouriteSportsKeys;
}
@@ -213,6 +223,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _nonFavouriteSportsKeys;
}
@StrutsParameter
public void setNonFavouriteSports(List notFavouriteSportsKeys) {
this._nonFavouriteSportsKeys = notFavouriteSportsKeys;
}
@@ -222,6 +233,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _prioritisedFavouriteCartoonCharacters;
}
@StrutsParameter
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
}
@@ -230,6 +242,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _prioritisedFavouriteCars;
}
@StrutsParameter
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
_prioritisedFavouriteCars = prioritisedFavouriteCars;
}
@@ -239,6 +252,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _prioritisedFavouriteCountries;
}
@StrutsParameter
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
}
@@ -264,12 +278,13 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteCities;
}
@StrutsParameter
public void setFavouriteCities(List favouriteCities) {
this._favouriteCities = favouriteCities;
}
// actions
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*
@@ -36,6 +37,7 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
return this.description1;
}
@StrutsParameter
public void setDescription1(String description1) {
this.description1 = description1;
}
@@ -45,6 +47,7 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
return this.description2;
}
@StrutsParameter
public void setDescription2(String description2) {
this.description2 = description2;
}
@@ -54,6 +57,7 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
return this.description3;
}
@StrutsParameter
public void setDescription3(String description3) {
this.description3 = description3;
}
@@ -63,11 +67,12 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
return this.description4;
}
@StrutsParameter
public void setDescription4(String description4) {
this.description4 = description4;
}
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -75,11 +76,11 @@ public class MoreSelectsAction extends ActionSupport {
return list;
}
public List getPrioritisedFavouriteCartoonCharacters() {
return _prioritisedFavouriteCartoonCharacters;
}
@StrutsParameter
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
}
@@ -88,15 +89,16 @@ public class MoreSelectsAction extends ActionSupport {
return _prioritisedFavouriteCars;
}
@StrutsParameter
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
_prioritisedFavouriteCars = prioritisedFavouriteCars;
}
public List getPrioritisedFavouriteCountries() {
return _prioritisedFavouriteCountries;
}
@StrutsParameter
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
}
@@ -105,6 +107,7 @@ public class MoreSelectsAction extends ActionSupport {
return favouriteNumbers;
}
@StrutsParameter
public void setFavouriteNumbers(List favouriteNumbers) {
this.favouriteNumbers = favouriteNumbers;
}
@@ -129,12 +132,13 @@ public class MoreSelectsAction extends ActionSupport {
return favouriteCities;
}
@StrutsParameter
public void setFavouriteCities(List favouriteCities) {
this.favouriteCities = favouriteCities;
}
// actions
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.ajax.tree.Category;
public class ShowAjaxDynamicTreeAction extends ActionSupport {
@@ -34,6 +35,7 @@ public class ShowAjaxDynamicTreeAction extends ActionSupport {
return nodeId;
}
@StrutsParameter
public void setNodeId(int nodeId) {
this.nodeId = nodeId;
}
@@ -200,6 +200,7 @@ public class UITagExample extends ActionSupport implements Validateable {
return bestFriend;
}
@StrutsParameter
public void setBestFriend(String bestFriend) {
this.bestFriend = bestFriend;
}
@@ -231,6 +232,7 @@ public class UITagExample extends ActionSupport implements Validateable {
this.region = region;
}
@StrutsParameter
public void setPicture(File picture) {
this.picture = picture;
}
@@ -239,10 +241,12 @@ public class UITagExample extends ActionSupport implements Validateable {
return this.picture;
}
@StrutsParameter
public void setPictureContentType(String pictureContentType) {
this.pictureContentType = pictureContentType;
}
@StrutsParameter
public void setPictureFileName(String pictureFileName) {
this.pictureFileName = pictureFileName;
}
@@ -323,6 +327,7 @@ public class UITagExample extends ActionSupport implements Validateable {
return this.description;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof VehicalType)) {
return false;
@@ -331,6 +336,7 @@ public class UITagExample extends ActionSupport implements Validateable {
}
}
@Override
public int hashCode() {
return key.hashCode();
}
@@ -354,6 +360,7 @@ public class UITagExample extends ActionSupport implements Validateable {
return this.description;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof VehicalSpecific)) {
return false;
@@ -362,6 +369,7 @@ public class UITagExample extends ActionSupport implements Validateable {
}
}
@Override
public int hashCode() {
return key.hashCode();
}
@@ -21,6 +21,7 @@ package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.dao.Dao;
import org.apache.struts2.showcase.model.IdEntity;
@@ -40,7 +41,6 @@ public abstract class AbstractCRUDAction extends ActionSupport {
protected abstract Dao getDao();
public Collection getAvailableItems() {
return availableItems;
}
@@ -49,6 +49,7 @@ public abstract class AbstractCRUDAction extends ActionSupport {
return toDelete;
}
@StrutsParameter
public void setToDelete(String[] toDelete) {
this.toDelete = toDelete;
}
@@ -64,11 +65,11 @@ public abstract class AbstractCRUDAction extends ActionSupport {
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]);
}
for (String s : toDelete) {
count = count + getDao().delete(s);
}
if (log.isDebugEnabled()) {
log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted.");
log.debug("AbstractCRUDAction - [delete]: {} items deleted.", count);
}
}
return SUCCESS;
@@ -21,6 +21,7 @@ package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.Preparable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.application.TestDataProvider;
import org.apache.struts2.showcase.dao.Dao;
import org.apache.struts2.showcase.dao.EmployeeDao;
@@ -52,7 +53,7 @@ public class EmployeeAction extends AbstractCRUDAction implements Preparable {
public String execute() throws Exception {
if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) {
setSelectedSkills(new ArrayList<String>());
setSelectedSkills(new ArrayList<>());
Iterator it = getCurrentEmployee().getOtherSkills().iterator();
while (it.hasNext()) {
getSelectedSkills().add(((Skill) it.next()).getName());
@@ -73,10 +74,12 @@ public class EmployeeAction extends AbstractCRUDAction implements Preparable {
return empId;
}
@StrutsParameter
public void setEmpId(Long empId) {
this.empId = empId;
}
@StrutsParameter(depth = 2)
public Employee getCurrentEmployee() {
return currentEmployee;
}
@@ -20,7 +20,11 @@ package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ExampleAction extends ActionSupport {
public static final String CONSTANT = "Struts Rocks!";
@@ -46,7 +50,7 @@ public class ExampleAction extends ActionSupport {
}
public Map<String, Book> getBooks() {
Map<String, Book> books = new HashMap<String, Book>();
Map<String, Book> 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",
@@ -79,4 +83,4 @@ class Book {
public void setAuthor(String author) {
this.author = author;
}
}
}
@@ -21,8 +21,13 @@ package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.interceptor.annotations.After;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.io.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
/**
@@ -62,6 +67,7 @@ public class JSPEvalAction extends ExampleAction {
}
}
@StrutsParameter
public void setJsp(String jsp) {
this.jsp = jsp;
}
@@ -46,6 +46,7 @@ public class SkillAction extends AbstractCRUDAction implements Preparable {
*
* @throws Exception thrown if a system level exception occurs.
*/
@Override
public void prepare() throws Exception {
Skill preFetched = (Skill) fetch(getSkillName(), getCurrentSkill());
if (preFetched != null) {
@@ -64,6 +65,7 @@ public class SkillAction extends AbstractCRUDAction implements Preparable {
return skillName;
}
@StrutsParameter
public void setSkillName(String skillName) {
this.skillName = skillName;
}
@@ -19,6 +19,7 @@
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class ActionChain1 extends ActionSupport {
@@ -26,6 +27,7 @@ public class ActionChain1 extends ActionSupport {
private String actionChain1Property1 = "Property Set In Action Chain 1";
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -34,6 +36,7 @@ public class ActionChain1 extends ActionSupport {
return actionChain1Property1;
}
@StrutsParameter
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
@@ -19,6 +19,7 @@
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class ActionChain2 extends ActionSupport {
@@ -27,6 +28,7 @@ public class ActionChain2 extends ActionSupport {
private String actionChain1Property1;
private String actionChain2Property1 = "Property Set in Action Chain 2";
@Override
public String execute() throws Exception {
return SUCCESS;
}
@@ -35,15 +37,16 @@ public class ActionChain2 extends ActionSupport {
return actionChain1Property1;
}
@StrutsParameter
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String getActionChain2Property1() {
return actionChain2Property1;
}
@StrutsParameter
public void setActionChain2Property1(String actionChain2Property1) {
this.actionChain2Property1 = actionChain2Property1;
}
@@ -19,6 +19,7 @@
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class ActionChain3 extends ActionSupport {
@@ -28,7 +29,7 @@ public class ActionChain3 extends ActionSupport {
private String actionChain2Property1;
private String actionChain3Property1 = "Property set in Action Chain 3";
@Override
public String execute() throws Exception {
return SUCCESS;
}
@@ -37,24 +38,25 @@ public class ActionChain3 extends ActionSupport {
return actionChain1Property1;
}
@StrutsParameter
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String getActionChain2Property1() {
return actionChain2Property1;
}
@StrutsParameter
public void setActionChain2Property1(String actionChain2Property1) {
this.actionChain2Property1 = actionChain2Property1;
}
public String getActionChain3Property1() {
return actionChain3Property1;
}
@StrutsParameter
public void setActionChain3Property1(String actionChain3Property1) {
this.actionChain3Property1 = actionChain3Property1;
}
@@ -21,10 +21,10 @@
package org.apache.struts2.showcase.ajax;
import com.opensymphony.xwork2.Action;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.io.Serializable;
public class AjaxTestAction implements Action, Serializable {
private static int counter = 0;
@@ -46,6 +46,7 @@ public class AjaxTestAction implements Action, Serializable {
return data;
}
@StrutsParameter
public void setData(String data) {
this.data = data;
}
@@ -21,16 +21,18 @@
package org.apache.struts2.showcase.ajax;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.List;
public class AutocompleterExampleAction extends ActionSupport {
private String select;
private List<String> options = new ArrayList<String>();
private final List<String> options = new ArrayList<>();
private static final long serialVersionUID = -8481638176160014396L;
@Override
public String execute() throws Exception {
if ("fruits".equals(select)) {
options.add("apple");
@@ -49,6 +51,7 @@ public class AutocompleterExampleAction extends ActionSupport {
return select;
}
@StrutsParameter
public void setSelect(String select) {
this.select = select;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.ajax;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -51,6 +52,7 @@ public class Example4ShowPanelAction extends ActionSupport {
return gender;
}
@StrutsParameter
public void setGender(String gender) {
this.gender = gender;
}
@@ -59,6 +61,7 @@ public class Example4ShowPanelAction extends ActionSupport {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.ajax;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class Example5Action extends ActionSupport {
@@ -37,6 +38,7 @@ public class Example5Action extends ActionSupport {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -45,6 +47,7 @@ public class Example5Action extends ActionSupport {
return age;
}
@StrutsParameter
public void setAge(Integer age) {
this.age = age;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.ajax.tree;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*/
@@ -28,6 +29,7 @@ public class GetCategory extends ActionSupport {
private long catId;
private Category category;
@Override
public String execute() throws Exception {
if (catId < 1) {
// force the root
@@ -39,6 +41,7 @@ public class GetCategory extends ActionSupport {
return SUCCESS;
}
@StrutsParameter
public void setCatId(long catId) {
this.catId = catId;
}
@@ -24,6 +24,8 @@ package org.apache.struts2.showcase.ajax.tree;
/**
*/
public class Toggle extends GetCategory {
@Override
public String execute() throws Exception {
super.execute();
@@ -50,15 +50,12 @@ public class ChatRoomAction extends ActionSupport {
}
public Callable<String> receiveNewMessages() throws Exception {
return new Callable<String>() {
@Override
public String call() throws Exception {
while (lastIndex >= messages.size()) {
Thread.sleep(3000);
}
newMessages = messages.subList(lastIndex, messages.size());
return SUCCESS;
return () -> {
while (lastIndex >= messages.size()) {
Thread.sleep(3000);
}
newMessages = messages.subList(lastIndex, messages.size());
return SUCCESS;
};
}
@@ -21,11 +21,11 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Map;
import org.apache.struts2.action.SessionAware;
public class ChatLoginAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
@@ -43,6 +43,7 @@ public class ChatLoginAction extends ActionSupport implements SessionAware {
return this.name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class CrudRoomAction extends ActionSupport {
@@ -36,6 +37,7 @@ public class CrudRoomAction extends ActionSupport {
return description;
}
@StrutsParameter
public void setDescription(String description) {
this.description = description;
}
@@ -44,6 +46,7 @@ public class CrudRoomAction extends ActionSupport {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -21,11 +21,11 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Map;
import org.apache.struts2.action.SessionAware;
public class EnterRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
@@ -38,6 +38,7 @@ public class EnterRoomAction extends ActionSupport implements SessionAware {
return this.roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -21,11 +21,11 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Map;
import org.apache.struts2.action.SessionAware;
public class ExitRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
@@ -38,6 +38,7 @@ public class ExitRoomAction extends ActionSupport implements SessionAware {
return roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.List;
@@ -30,13 +31,14 @@ public class MessagesAvailableInRoomAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private String roomName;
private ChatService chatService;
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<ChatMessage>();
private final ChatService chatService;
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<>();
public String getRoomName() {
return this.roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -21,16 +21,16 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Map;
import org.apache.struts2.action.SessionAware;
public class SendMessageToRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private final ChatService chatService;
private String roomName;
private String message;
@@ -45,6 +45,7 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
return this.roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -53,11 +54,12 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
return this.message;
}
@StrutsParameter
public void setMessage(String message) {
this.message = message;
}
@Override
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
try {
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.List;
@@ -29,8 +30,8 @@ public class UsersAvailableInRoomAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private List<User> usersAvailableInRoom = new ArrayList<User>();
private final ChatService chatService;
private List<User> usersAvailableInRoom = new ArrayList<>();
private String roomName;
@@ -43,6 +44,7 @@ public class UsersAvailableInRoomAction extends ActionSupport {
return this.roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -51,6 +53,7 @@ public class UsersAvailableInRoomAction extends ActionSupport {
return usersAvailableInRoom;
}
@Override
public String execute() throws Exception {
try {
usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName);
@@ -34,7 +34,7 @@ public class OperationsEnumAction extends ActionSupport {
private static final long serialVersionUID = -2229489704988870318L;
private List<OperationsEnum> selectedOperations = new LinkedList<OperationsEnum>();
private List<OperationsEnum> selectedOperations = new LinkedList<>();
public String input() throws Exception {
return SUCCESS;
@@ -53,7 +53,6 @@ public class OperationsEnumAction extends ActionSupport {
this.selectedOperations = selectedOperations;
}
public List<OperationsEnum> getAvailableOperations() {
return Arrays.asList(OperationsEnum.values());
}
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.freemarker;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.text.DateFormatSymbols;
@@ -34,6 +35,7 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
private String[] gender;
private String[] months;
@Override
public void prepare() {
months = new DateFormatSymbols().getMonths();
name = StandardTagsAction.class.getName().substring(StandardTagsAction.class.getName().lastIndexOf(".") + 1);
@@ -44,6 +46,7 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -52,15 +55,16 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
return months;
}
@StrutsParameter
public void setMonths(String[] months) {
this.months = months;
}
public String[] getGender() {
return gender;
}
@StrutsParameter
public void setGender(String[] gender) {
this.gender = gender;
}
@@ -21,11 +21,11 @@
package org.apache.struts2.showcase.hangman;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Map;
import org.apache.struts2.action.SessionAware;
public class GuessCharacterAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 9050915577007590674L;
@@ -34,6 +34,7 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
private Character character;
private Hangman hangman;
@Override
public String execute() throws Exception {
hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
hangman.guess(character);
@@ -45,6 +46,7 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
return hangman;
}
@StrutsParameter
public void setCharacter(Character character) {
this.character = character;
}
@@ -30,14 +30,17 @@ public class ModelDrivenAction extends ActionSupport implements ModelDriven {
private static final long serialVersionUID = 1271130427666936592L;
@Override
public String input() throws Exception {
return SUCCESS;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
@Override
public Object getModel() {
return new Gangster();
}
@@ -23,10 +23,10 @@ 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.apache.struts2.interceptor.parameter.StrutsParameter;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@@ -42,13 +42,14 @@ public class EditPersonAction extends ActionSupport {
@Autowired
private PersonManager personManager;
private List<Person> persons = new ArrayList<Person>();
private List<Person> persons = new ArrayList<>();
/**
* A default implementation that does nothing an returns "success".
*
* @return {@link #INPUT}
*/
@Override
public String execute() throws Exception {
persons.addAll(personManager.getPeople());
return INPUT;
@@ -68,6 +69,7 @@ public class EditPersonAction extends ActionSupport {
return "list";
}
@StrutsParameter(depth = 2)
public List<Person> getPersons() {
return persons;
}
@@ -35,8 +35,9 @@ public class ListPeopleAction extends ActionSupport {
@Autowired
private PersonManager personManager;
private List<Person> people = new ArrayList<Person>();
private final List<Person> people = new ArrayList<>();
@Override
public String execute() {
people.addAll(personManager.getPeople());
@@ -23,6 +23,7 @@ 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.apache.struts2.interceptor.parameter.StrutsParameter;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,12 +39,14 @@ public class NewPersonAction extends ActionSupport {
private PersonManager personManager;
private Person person;
@Override
public String execute() {
personManager.createPerson(person);
return "list";
}
@StrutsParameter(depth = 1)
public Person getPerson() {
return person;
}
@@ -23,6 +23,7 @@ package org.apache.struts2.showcase.source;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.struts2.action.ServletContextAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import javax.servlet.ServletContext;
import java.io.BufferedReader;
@@ -98,8 +99,9 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
/**
* @param className the className to set
*/
@StrutsParameter
public void setClassName(String className) {
if (className != null && className.trim().length() > 0) {
if (className != null && !className.trim().isEmpty()) {
this.className = className;
}
}
@@ -107,8 +109,9 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
/**
* @param config the config to set
*/
@StrutsParameter
public void setConfig(String config) {
if (config != null && config.trim().length() > 0) {
if (config != null && !config.trim().isEmpty()) {
this.config = config;
}
}
@@ -116,8 +119,9 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
/**
* @param page the page to set
*/
@StrutsParameter
public void setPage(String page) {
if (page != null && page.trim().length() > 0) {
if (page != null && !page.trim().isEmpty()) {
this.page = page;
}
}
@@ -125,6 +129,7 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
/**
* @param padding the padding to set
*/
@StrutsParameter
public void setPadding(int padding) {
this.padding = padding;
}
@@ -222,6 +227,7 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
return snippet;
}
@Override
public void withServletContext(ServletContext arg0) {
this.servletContext = arg0;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.tag.nonui.actionPrefix;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class SubmitAction extends ActionSupport {
@@ -32,10 +33,12 @@ public class SubmitAction extends ActionSupport {
return text;
}
@StrutsParameter
public void setText(String text) {
this.text = text;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
@@ -23,8 +23,9 @@ import org.apache.struts2.dispatcher.PrepareOperations;
public class DebugTagAction extends ActionSupport {
@Override
public String execute() throws Exception {
PrepareOperations.overrideDevMode(true); // Just for Showcase, explicitly switch on for this action only
return SUCCESS;
}
}
}
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.tag.nonui.iteratortag;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*
@@ -47,25 +48,25 @@ public class AppendIteratorTagDemo extends ActionSupport implements Validateable
}
}
public String getIteratorValue1() {
return iteratorValue1;
}
@StrutsParameter
public void setIteratorValue1(String iteratorValue1) {
this.iteratorValue1 = iteratorValue1;
}
public String getIteratorValue2() {
return iteratorValue2;
}
@StrutsParameter
public void setIteratorValue2(String iteratorValue2) {
this.iteratorValue2 = iteratorValue2;
}
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.tag.nonui.iteratortag;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*/
@@ -37,34 +38,34 @@ public class IteratorGeneratorTagDemo extends ActionSupport {
return value;
}
@StrutsParameter
public void setValue(String value) {
this.value = value;
}
public Integer getCount() {
return count;
}
@StrutsParameter
public void setCount(Integer count) {
this.count = count;
}
public String getSeparator() {
return this.separator;
}
@StrutsParameter
public void setSeparator(String separator) {
this.separator = separator;
}
public String submit() throws Exception {
return SUCCESS;
}
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.tag.nonui.iteratortag;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -33,7 +34,7 @@ public class MergeIteratorTagDemo extends ActionSupport implements Validateable
private String iteratorValue1;
private String iteratorValue2;
@Override
public void validate() {
if (iteratorValue1 == null || iteratorValue1.trim().length() <= 0) {
addFieldError("iteratorValue1", "iterator value 1 cannot be empty");
@@ -47,25 +48,25 @@ public class MergeIteratorTagDemo extends ActionSupport implements Validateable
}
}
public String getIteratorValue1() {
return this.iteratorValue1;
}
@StrutsParameter
public void setIteratorValue1(String iteratorValue1) {
this.iteratorValue1 = iteratorValue1;
}
public String getIteratorValue2() {
return this.iteratorValue2;
}
@StrutsParameter
public void setIteratorValue2(String iteratorValue2) {
this.iteratorValue2 = iteratorValue2;
}
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.tag.nonui.iteratortag;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*
@@ -34,7 +35,7 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
private Integer count;
private Integer start;
@Override
public void validate() {
if (iteratorValue == null || iteratorValue.trim().length() <= 0) {
addFieldError("iteratorValue1", "iterator value 1 cannot be empty");
@@ -43,34 +44,34 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
}
}
public String getIteratorValue() {
return this.iteratorValue;
}
@StrutsParameter
public void setIteratorValue(String iteratorValue) {
this.iteratorValue = iteratorValue;
}
public Integer getCount() {
return this.count;
}
@StrutsParameter
public void setCount(Integer count) {
this.count = count;
}
public Integer getStart() {
return this.start;
}
@StrutsParameter
public void setStart(Integer start) {
this.start = start;
}
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -78,6 +79,4 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
public String submit() throws Exception {
return SUCCESS;
}
}
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.token;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Date;
@@ -76,6 +77,7 @@ public class TokenAction extends ActionSupport {
return amount;
}
@StrutsParameter
public void setAmount(int amount) {
this.amount = amount;
}
@@ -30,6 +30,7 @@ public abstract class AbstractValidationActionSupport extends ActionSupport {
return "success";
}
@Override
public String input() throws Exception {
return "input";
}
@@ -18,8 +18,6 @@
*/
package org.apache.struts2.showcase.validation;
import java.sql.Date;
import com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.EmailValidator;
import com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator;
@@ -29,6 +27,9 @@ import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.annotations.UrlValidator;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.sql.Date;
/**
* <!-- START SNIPPET: ajaxFormSubmit -->
@@ -72,9 +73,10 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@DateRangeFieldValidator(
min="01/01/1990",
max="01/01/2000",
min="01/01/1990",
max="01/01/2000",
message="must be a min 01-01-1990 max 01-01-2000 if supplied")
@StrutsParameter
public void setDateValidatorField(Date dateValidatorField) {
this.dateValidatorField = dateValidatorField;
}
@@ -84,6 +86,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@EmailValidator(message="must be a valid email if supplied")
@StrutsParameter
public void setEmailValidatorField(String emailValidatorField) {
this.emailValidatorField = emailValidatorField;
}
@@ -93,6 +96,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@IntRangeFieldValidator(min="1", max="10", message="must be integer min 1 max 10 if supplied")
@StrutsParameter
public void setIntegerValidatorField(Integer integerValidatorField) {
this.integerValidatorField = integerValidatorField;
}
@@ -102,8 +106,9 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@RegexFieldValidator(
regex="[^<>]+",
regex="[^<>]+",
message="regexValidatorField must match a regexp (.*\\.txt) if specified")
@StrutsParameter
public void setRegexValidatorField(String regexValidatorField) {
this.regexValidatorField = regexValidatorField;
}
@@ -113,6 +118,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@RequiredStringValidator(trim=true, message="required and must be string")
@StrutsParameter
public void setRequiredStringValidatorField(String requiredStringValidatorField) {
this.requiredStringValidatorField = requiredStringValidatorField;
}
@@ -122,6 +128,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@RequiredFieldValidator(message="required")
@StrutsParameter
public void setRequiredValidatorField(String requiredValidatorField) {
this.requiredValidatorField = requiredValidatorField;
}
@@ -131,10 +138,11 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@StringLengthFieldValidator(
minLength="2",
maxLength="4",
trim=true,
minLength="2",
maxLength="4",
trim=true,
message="must be a String of a specific greater than 1 less than 5 if specified")
@StrutsParameter
public void setStringLengthValidatorField(String stringLengthValidatorField) {
this.stringLengthValidatorField = stringLengthValidatorField;
}
@@ -144,10 +152,10 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@FieldExpressionValidator(
expression = "(fieldExpressionValidatorField == requiredValidatorField)",
expression = "(fieldExpressionValidatorField == requiredValidatorField)",
message = "must be the same as the Required Validator Field if specified")
public void setFieldExpressionValidatorField(
String fieldExpressionValidatorField) {
@StrutsParameter
public void setFieldExpressionValidatorField(String fieldExpressionValidatorField) {
this.fieldExpressionValidatorField = fieldExpressionValidatorField;
}
@@ -156,6 +164,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@UrlValidator(message="must be a valid url if supplied")
@StrutsParameter
public void setUrlValidatorField(String urlValidatorField) {
this.urlValidatorField = urlValidatorField;
}
@@ -26,6 +26,7 @@ import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.interceptor.validation.SkipValidation;
import org.hibernate.validator.constraints.ScriptAssert;
import org.hibernate.validator.constraints.URL;
@@ -95,6 +96,7 @@ public class BeanValidationExampleAction extends ActionSupport {
return dateValidatorField;
}
@StrutsParameter
public void setDateValidatorField(Date dateValidatorField) {
this.dateValidatorField = dateValidatorField;
}
@@ -103,6 +105,7 @@ public class BeanValidationExampleAction extends ActionSupport {
return emailValidatorField;
}
@StrutsParameter
public void setEmailValidatorField(String emailValidatorField) {
this.emailValidatorField = emailValidatorField;
}
@@ -111,6 +114,7 @@ public class BeanValidationExampleAction extends ActionSupport {
return integerValidatorField;
}
@StrutsParameter
public void setIntegerValidatorField(Integer integerValidatorField) {
this.integerValidatorField = integerValidatorField;
}
@@ -119,6 +123,7 @@ public class BeanValidationExampleAction extends ActionSupport {
return regexValidatorField;
}
@StrutsParameter
public void setRegexValidatorField(String regexValidatorField) {
this.regexValidatorField = regexValidatorField;
}
@@ -127,6 +132,7 @@ public class BeanValidationExampleAction extends ActionSupport {
return requiredStringValidatorField;
}
@StrutsParameter
public void setRequiredStringValidatorField(String requiredStringValidatorField) {
this.requiredStringValidatorField = requiredStringValidatorField;
}
@@ -135,6 +141,7 @@ public class BeanValidationExampleAction extends ActionSupport {
return requiredValidatorField;
}
@StrutsParameter
public void setRequiredValidatorField(String requiredValidatorField) {
this.requiredValidatorField = requiredValidatorField;
}
@@ -143,6 +150,7 @@ public class BeanValidationExampleAction extends ActionSupport {
return stringLengthValidatorField;
}
@StrutsParameter
public void setStringLengthValidatorField(String stringLengthValidatorField) {
this.stringLengthValidatorField = stringLengthValidatorField;
}
@@ -151,8 +159,8 @@ public class BeanValidationExampleAction extends ActionSupport {
return fieldExpressionValidatorField;
}
public void setFieldExpressionValidatorField(
String fieldExpressionValidatorField) {
@StrutsParameter
public void setFieldExpressionValidatorField(String fieldExpressionValidatorField) {
this.fieldExpressionValidatorField = fieldExpressionValidatorField;
}
@@ -160,6 +168,7 @@ public class BeanValidationExampleAction extends ActionSupport {
return urlValidatorField;
}
@StrutsParameter
public void setUrlValidatorField(String urlValidatorField) {
this.urlValidatorField = urlValidatorField;
}
@@ -20,6 +20,8 @@
*/
package org.apache.struts2.showcase.validation;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*/
@@ -37,6 +39,7 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
return someText;
}
@StrutsParameter
public void setSomeText(String someText) {
this.someText = someText;
}
@@ -45,6 +48,7 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
return someTextRetype;
}
@StrutsParameter
public void setSomeTextRetype(String someTextRetype) {
this.someTextRetype = someTextRetype;
}
@@ -53,6 +57,7 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
return someTextRetypeAgain;
}
@StrutsParameter
public void setSomeTextRetypeAgain(String someTextRetypeAgain) {
this.someTextRetypeAgain = someTextRetypeAgain;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.validation;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*/
@@ -39,6 +40,7 @@ public class QuizAction extends ActionSupport {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -47,6 +49,7 @@ public class QuizAction extends ActionSupport {
return age;
}
@StrutsParameter
public void setAge(int age) {
this.age = age;
}
@@ -55,6 +58,7 @@ public class QuizAction extends ActionSupport {
return answer;
}
@StrutsParameter
public void setAnswer(String answer) {
this.answer = answer;
}
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.validation;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* @version $Date$ $Id$
@@ -30,6 +31,7 @@ public class SubmitApplication extends ActionSupport {
private String name;
private Integer age;
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -38,6 +40,7 @@ public class SubmitApplication extends ActionSupport {
return this.name;
}
@StrutsParameter
public void setAge(Integer age) {
this.age = age;
}
@@ -23,12 +23,15 @@ package org.apache.struts2.showcase.validation;
// START SNIPPET: visitorValidatorsExample
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class VisitorValidatorsExampleAction extends AbstractValidationActionSupport {
private static final long serialVersionUID = 4375454086939598216L;
private User user;
@StrutsParameter(depth = 1)
public User getUser() {
return user;
}
@@ -21,11 +21,9 @@
package org.apache.struts2.showcase.xslt;
import com.opensymphony.xwork2.ActionSupport;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.action.ServletRequestAware;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.Properties;
@@ -72,7 +70,7 @@ public class JVMAction implements ServletRequestAware {
this.info = info;
}
public class ImportantInfo {
public static class ImportantInfo {
private String classpath;
private Properties systemProperties;
@@ -25,10 +25,11 @@ import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.entities.PackageConfig;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.osgi.BundleAccessor;
import org.apache.struts2.osgi.host.OsgiHost;
import org.apache.struts2.osgi.StrutsOsgiListener;
import org.apache.struts2.action.ServletContextAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.osgi.BundleAccessor;
import org.apache.struts2.osgi.StrutsOsgiListener;
import org.apache.struts2.osgi.host.OsgiHost;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -36,9 +37,8 @@ import javax.servlet.ServletContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class BundlesAction extends ActionSupport implements ServletContextAware {
@@ -114,6 +114,7 @@ public class BundlesAction extends ActionSupport implements ServletContextAware
return id;
}
@StrutsParameter
public void setId(String id) {
this.id = id;
}
@@ -21,25 +21,25 @@
package org.apache.struts2.osgi.admin.actions;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.felix.shell.ShellService;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.osgi.DefaultBundleAccessor;
import org.apache.struts2.osgi.interceptor.BundleContextAware;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/**
* This action executes commands on the Felix Shell.
*
*
* The action is BundleContextAware so that if the OSGi interceptor is used the BundleContext
* can be provided for configurations where the DefaultBundleAccessor is insufficient.
*
*
*/
public class ShellAction extends ActionSupport implements BundleContextAware {
private String command;
@@ -77,6 +77,7 @@ public class ShellAction extends ActionSupport implements BundleContextAware {
return command;
}
@StrutsParameter
public void setCommand(String command) {
this.command = command;
}
@@ -33,6 +33,7 @@ import org.osgi.framework.BundleContext;
public class BundlesAction extends ActionSupport implements BundleContextAware {
private BundleContext bundleContext;
@Override
public void withBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
@@ -26,6 +26,7 @@ import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@Namespace("/osgi")
@ResultPath("/content/osgi")
@@ -41,6 +42,7 @@ public class HelloWorldAction extends ActionSupport {
return SUCCESS;
}
@StrutsParameter(depth = 1)
public Message getMessage() {
return message;
}
@@ -60,4 +62,4 @@ public class HelloWorldAction extends ActionSupport {
sb.append("}");
return sb.toString();
}
}
}
@@ -21,7 +21,12 @@ package com.opensymphony.xwork2;
import com.opensymphony.xwork2.interceptor.ValidationAware;
import java.io.Serializable;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* Provides a default implementation of ValidationAware. Returns new collections for
@@ -72,13 +77,7 @@ public class ValidationAwareSupport implements ValidationAware, Serializable {
public synchronized void addFieldError(String fieldName, String errorMessage) {
final Map<String, List<String>> errors = internalGetFieldErrors();
List<String> thisFieldErrors = errors.get(fieldName);
if (thisFieldErrors == null) {
thisFieldErrors = new ArrayList<>();
errors.put(fieldName, thisFieldErrors);
}
List<String> thisFieldErrors = errors.computeIfAbsent(fieldName, k -> new ArrayList<>());
thisFieldErrors.add(errorMessage);
}
@@ -18,11 +18,11 @@
*/
package org.apache.struts2.dispatcher;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import javax.servlet.http.HttpServletRequest;
/**
* A simple action support class that sets properties to be able to serve
@@ -44,6 +44,7 @@ public class DefaultActionSupport extends ActionSupport {
/* (non-Javadoc)
* @see com.opensymphony.xwork2.ActionSupport#execute()
*/
@Override
public String execute() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
String requestedUrl = request.getPathInfo();
@@ -61,9 +62,8 @@ public class DefaultActionSupport extends ActionSupport {
/**
* @param successResultValue The successResultValue to set.
*/
@StrutsParameter
public void setSuccessResultValue(String successResultValue) {
this.successResultValue = successResultValue;
}
}
@@ -20,8 +20,12 @@ package com.opensymphony.xwork2;
import com.opensymphony.xwork2.conversion.impl.ConversionData;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
/**
* Unit test for {@link ActionSupport}.
@@ -334,6 +338,7 @@ public class ActionSupportTest extends XWorkTestCase {
return val;
}
@StrutsParameter
public void setVal(Double val) {
this.val = val;
}
@@ -19,6 +19,8 @@
package com.opensymphony.xwork2;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* ModelDrivenAction
*
@@ -28,9 +30,9 @@ package com.opensymphony.xwork2;
public class ModelDrivenAction extends ActionSupport implements ModelDriven {
private String foo;
private TestBean model = new TestBean();
private final TestBean model = new TestBean();
@StrutsParameter
public void setFoo(String foo) {
this.foo = foo;
}
@@ -42,6 +44,8 @@ public class ModelDrivenAction extends ActionSupport implements ModelDriven {
/**
* @return the model to be pushed onto the ValueStack after the Action itself
*/
@StrutsParameter(depth = 2)
@Override
public Object getModel() {
return model;
}
@@ -18,6 +18,8 @@
*/
package com.opensymphony.xwork2;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* ModelDrivenAnnotationAction
*
@@ -28,9 +30,9 @@ package com.opensymphony.xwork2;
public class ModelDrivenAnnotationAction extends ActionSupport implements ModelDriven {
private String foo;
private AnnotatedTestBean model = new AnnotatedTestBean();
private final AnnotatedTestBean model = new AnnotatedTestBean();
@StrutsParameter
public void setFoo(String foo) {
this.foo = foo;
}
@@ -42,6 +44,8 @@ public class ModelDrivenAnnotationAction extends ActionSupport implements ModelD
/**
* @return the model to be pushed onto the ValueStack after the Action itself
*/
@StrutsParameter(depth = 2)
@Override
public Object getModel() {
return model;
}
@@ -22,6 +22,8 @@ package com.opensymphony.xwork2;
* Need by the ProxyInvocationTest
*/
public class ProxyInvocationAction extends ActionSupport implements ProxyInvocationInterface {
@Override
public String show() {
return "proxyResult";
}
@@ -21,7 +21,12 @@ package com.opensymphony.xwork2;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.inject.Inject;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
@@ -56,7 +61,7 @@ public class SimpleAction extends ActionSupport {
private Map<String, String> existingMap = new HashMap<>();
private List<TestBean> beanList;
public static boolean resultCalled;
@@ -64,11 +69,11 @@ public class SimpleAction extends ActionSupport {
resultCalled = false;
existingMap.put("existingKey", "value");
}
public Map<String,String> getTheProtectedMap() {
return protectedMap;
}
protected Map<String,String> getTheSemiProtectedMap() {
return protectedMap;
}
@@ -81,7 +86,6 @@ public class SimpleAction extends ActionSupport {
return existingMap;
}
public void setBar(int bar) {
this.bar = bar;
}
@@ -187,15 +191,15 @@ public class SimpleAction extends ActionSupport {
public ArrayList<String> getSomeList() {
return someList;
}
public String getIndexedProp(int index) {
return indexedProps.get(index);
}
public void setIndexedProp(int index, String val) {
indexedProps.put(index, val);
}
public void setThrowException(boolean throwException) {
this.throwException = throwException;
@@ -204,7 +208,7 @@ public class SimpleAction extends ActionSupport {
public String commandMethod() throws Exception {
return COMMAND_RETURN_CODE;
}
public Result resultAction() throws Exception {
return new Result() {
public Configuration configuration;
@@ -217,7 +221,7 @@ public class SimpleAction extends ActionSupport {
if (configuration != null)
resultCalled = true;
}
};
}
@@ -251,7 +255,7 @@ public class SimpleAction extends ActionSupport {
return SUCCESS;
}
public long getLongFoo() {
return longFoo;
}
@@ -18,7 +18,18 @@
*/
package com.opensymphony.xwork2;
import com.opensymphony.xwork2.validator.annotations.*;
import com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.DoubleRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.EmailValidator;
import com.opensymphony.xwork2.validator.annotations.ExpressionValidator;
import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.annotations.UrlValidator;
import com.opensymphony.xwork2.validator.annotations.Validations;
import com.opensymphony.xwork2.validator.annotations.ValidatorType;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.Date;
@@ -49,8 +60,6 @@ public class SimpleAnnotationAction extends ActionSupport {
private String aliasSource;
private String aliasDest;
//~ Constructors ///////////////////////////////////////////////////////////
@@ -61,6 +70,7 @@ public class SimpleAnnotationAction extends ActionSupport {
@RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a value for bar.")
@IntRangeFieldValidator(type = ValidatorType.FIELD, min = "6", max = "10", message = "bar must be between ${min} and ${max}, current value is ${bar}.")
@StrutsParameter
public void setBar(int bar) {
this.bar = bar;
}
@@ -70,6 +80,7 @@ public class SimpleAnnotationAction extends ActionSupport {
}
@IntRangeFieldValidator(min = "0", key = "baz.range", message = "Could not find baz.range!")
@StrutsParameter
public void setBaz(int baz) {
this.baz = baz;
}
@@ -83,6 +94,7 @@ public class SimpleAnnotationAction extends ActionSupport {
}
@DoubleRangeFieldValidator(minInclusive = "0.123", key = "baz.range", message = "Could not find percentage.range!")
@StrutsParameter
public void setPercentage(double percentage) {
this.percentage = percentage;
}
@@ -91,10 +103,12 @@ public class SimpleAnnotationAction extends ActionSupport {
this.bean = bean;
}
@StrutsParameter(depth = 2)
public AnnotatedTestBean getBean() {
return bean;
}
@StrutsParameter
public void setBlah(String blah) {
this.blah = blah;
}
@@ -112,6 +126,7 @@ public class SimpleAnnotationAction extends ActionSupport {
}
@DateRangeFieldValidator(min = "12/22/2002", max = "12/25/2002", message = "The date must be between 12-22-2002 and 12-25-2002.")
@StrutsParameter
public void setDate(Date date) {
this.date = date;
}
@@ -120,6 +135,7 @@ public class SimpleAnnotationAction extends ActionSupport {
return date;
}
@StrutsParameter
public void setFoo(int foo) {
this.foo = foo;
}
@@ -128,6 +144,7 @@ public class SimpleAnnotationAction extends ActionSupport {
return foo;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -140,15 +157,16 @@ public class SimpleAnnotationAction extends ActionSupport {
this.settings = settings;
}
@StrutsParameter(depth = 1)
public Properties getSettings() {
return settings;
}
public String getAliasDest() {
return aliasDest;
}
@StrutsParameter
public void setAliasDest(String aliasDest) {
this.aliasDest = aliasDest;
}
@@ -157,11 +175,12 @@ public class SimpleAnnotationAction extends ActionSupport {
return aliasSource;
}
@StrutsParameter
public void setAliasSource(String aliasSource) {
this.aliasSource = aliasSource;
}
@StrutsParameter
public void setSomeList(ArrayList<String> someList) {
this.someList = someList;
}
@@ -170,6 +189,7 @@ public class SimpleAnnotationAction extends ActionSupport {
return someList;
}
@StrutsParameter
public void setThrowException(boolean throwException) {
this.throwException = throwException;
}
@@ -186,7 +206,6 @@ public class SimpleAnnotationAction extends ActionSupport {
return "OK";
}
@Override
@Validations(
requiredFields =
{@RequiredFieldValidator(type = ValidatorType.SIMPLE, fieldName = "customfield", message = "You must enter a value for field.")},
@@ -210,6 +229,7 @@ public class SimpleAnnotationAction extends ActionSupport {
@ExpressionValidator(expression = "foo &gt; 5", message = "Foo must be greater than Bar 5. Foo = ${foo}, Bar = ${bar}.")
}
)
@Override
public String execute() throws Exception {
if (foo == bar) {
return ERROR;
@@ -18,14 +18,16 @@
*/
package com.opensymphony.xwork2;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* A sample action to test validation order.
*
*
* @author tm_jee
* @version $Date$ $Id$
*/
public class ValidationOrderAction extends ActionSupport {
private String username;
private String password;
private String confirmPassword;
@@ -38,9 +40,9 @@ public class ValidationOrderAction extends ActionSupport {
private String email;
private String website;
private String passwordHint;
@Override
public String execute() throws Exception {
return SUCCESS;
@@ -53,7 +55,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setCity(String city) {
this.city = city;
}
@@ -65,7 +67,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}
@@ -77,7 +79,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setCountry(String country) {
this.country = country;
}
@@ -89,7 +91,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setEmail(String email) {
this.email = email;
}
@@ -101,7 +103,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@@ -113,7 +115,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setLastName(String lastName) {
this.lastName = lastName;
}
@@ -125,7 +127,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setPassword(String password) {
this.password = password;
}
@@ -137,7 +139,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setPasswordHint(String passwordHint) {
this.passwordHint = passwordHint;
}
@@ -149,7 +151,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
@@ -161,7 +163,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setProvince(String province) {
this.province = province;
}
@@ -173,7 +175,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setUsername(String username) {
this.username = username;
}
@@ -185,7 +187,7 @@ public class ValidationOrderAction extends ActionSupport {
}
@StrutsParameter
public void setWebsite(String website) {
this.website = website;
}
@@ -20,7 +20,12 @@ package com.opensymphony.xwork2.interceptor;
import com.mockobjects.dynamic.ConstraintMatcher;
import com.mockobjects.dynamic.Mock;
import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.util.ValueStack;
import java.util.Date;
@@ -175,6 +180,7 @@ public class ModelDrivenInterceptorTest extends XWorkTestCase {
public class ModelDrivenAction extends ActionSupport implements ModelDriven {
@Override
public Object getModel() {
return model;
}
@@ -190,22 +190,27 @@ public class ScopedModelDrivenInterceptorTest extends XWorkTestCase {
private String key;
private User model;
@Override
public void setModel(Object model) {
this.model = (User) model;
}
@Override
public void setScopeKey(String key) {
this.key = key;
}
@Override
public String getScopeKey() {
return key;
}
@Override
public User getModel() {
return model;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
@@ -217,22 +222,27 @@ public class ScopedModelDrivenInterceptorTest extends XWorkTestCase {
private String key;
private Equidae model;
@Override
public void setModel(Object model) {
this.model = (Equidae) model;
}
@Override
public void setScopeKey(String key) {
this.key = key;
}
@Override
public String getScopeKey() {
return key;
}
@Override
public Equidae getModel() {
return model;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
@@ -19,21 +19,24 @@
package com.opensymphony.xwork2.interceptor.annotations;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* @author martin.gilday
*
*/
public class AllowingByDefaultAction extends ActionSupport {
@Blocked
private String name;
private String job;
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@StrutsParameter
public void setJob(String job) {
this.job = job;
}
@@ -19,6 +19,7 @@
package com.opensymphony.xwork2.interceptor.annotations;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* @author martin.gilday
@@ -26,15 +27,17 @@ import com.opensymphony.xwork2.ActionSupport;
*/
@BlockByDefault
public class BlockingByDefaultAction extends ActionSupport {
@Allowed
private String name;
private String job;
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@StrutsParameter
public void setJob(String job) {
this.job = job;
}
@@ -19,6 +19,7 @@
package com.opensymphony.xwork2.test;
import com.opensymphony.xwork2.ModelDrivenAction;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -28,12 +29,13 @@ import com.opensymphony.xwork2.ModelDrivenAction;
*/
public class ModelDrivenAction2 extends ModelDrivenAction {
private TestBean2 model = new TestBean2();
private final TestBean2 model = new TestBean2();
/**
* @return the model to be pushed onto the ValueStack after the Action itself
*/
@StrutsParameter(depth = 3)
@Override
public Object getModel() {
return model;
@@ -19,6 +19,7 @@
package com.opensymphony.xwork2.test;
import com.opensymphony.xwork2.ModelDrivenAnnotationAction;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -29,12 +30,13 @@ import com.opensymphony.xwork2.ModelDrivenAnnotationAction;
*/
public class ModelDrivenAnnotationAction2 extends ModelDrivenAnnotationAction {
private AnnotationTestBean2 model = new AnnotationTestBean2();
private final AnnotationTestBean2 model = new AnnotationTestBean2();
/**
* @return the model to be pushed onto the ValueStack after the Action itself
*/
@StrutsParameter(depth = 3)
@Override
public Object getModel() {
return model;
@@ -19,6 +19,7 @@
package com.opensymphony.xwork2.test;
import com.opensymphony.xwork2.SimpleAction;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -31,7 +32,7 @@ public class SimpleAction2 extends SimpleAction {
private int count;
@StrutsParameter
public void setCount(int count) {
this.count = count;
}
@@ -20,6 +20,7 @@ package com.opensymphony.xwork2.test;
import com.opensymphony.xwork2.SimpleAction;
import com.opensymphony.xwork2.util.Bar;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -32,19 +33,24 @@ public class SimpleAction3 extends SimpleAction implements DataAware {
private Bar bar;
private String data;
@Override
public void setBarObj(Bar b) {
bar = b;
}
@StrutsParameter(depth = 1)
@Override
public Bar getBarObj() {
return bar;
}
@StrutsParameter
@Override
public void setData(String data) {
this.data = data;
}
@Override
public String getData() {
return data;
}
@@ -21,6 +21,7 @@ package com.opensymphony.xwork2.test;
import com.opensymphony.xwork2.SimpleAnnotationAction;
import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* SimpleAction2
@@ -35,6 +36,7 @@ public class SimpleAnnotationAction2 extends SimpleAnnotationAction {
@RequiredFieldValidator(message = "You must enter a value for count.")
@IntRangeFieldValidator(min = "0", max = "5", message = "count must be between ${min} and ${max}, current value is ${count}.")
@StrutsParameter
public void setCount(int count) {
this.count = count;
}
@@ -20,6 +20,7 @@ package com.opensymphony.xwork2.test;
import com.opensymphony.xwork2.SimpleAnnotationAction;
import com.opensymphony.xwork2.util.Bar;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -33,19 +34,24 @@ public class SimpleAnnotationAction3 extends SimpleAnnotationAction implements A
private Bar bar;
private String data;
@Override
public void setBarObj(Bar b) {
bar = b;
}
@StrutsParameter(depth = 1)
@Override
public Bar getBarObj() {
return bar;
}
@StrutsParameter
@Override
public void setData(String data) {
this.data = data;
}
@Override
public String getData() {
return data;
}
@@ -20,6 +20,7 @@ package com.opensymphony.xwork2.test.annotations;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.ExpressionValidator;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* <code>ValidateAnnotatedMethodOnlyAction</code>
@@ -34,6 +35,7 @@ public class ValidateAnnotatedMethodOnlyAction extends ActionSupport {
return param1;
}
@StrutsParameter
public void setParam1(String param1) {
this.param1 = param1;
}
@@ -42,6 +44,7 @@ public class ValidateAnnotatedMethodOnlyAction extends ActionSupport {
return param2;
}
@StrutsParameter
public void setParam2(String param2) {
this.param2 = param2;
}
@@ -19,6 +19,7 @@
package com.opensymphony.xwork2.util;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -32,7 +33,7 @@ public class Bar extends ActionSupport {
String title;
int somethingElse;
@StrutsParameter
public void setId(Long id) {
this.id = id;
}
@@ -41,6 +42,7 @@ public class Bar extends ActionSupport {
return this.id;
}
@StrutsParameter
public void setSomethingElse(int somethingElse) {
this.somethingElse = somethingElse;
}
@@ -49,6 +51,7 @@ public class Bar extends ActionSupport {
return somethingElse;
}
@StrutsParameter
public void setTitle(String title) {
this.title = title;
}
@@ -32,6 +32,7 @@ import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
import com.opensymphony.xwork2.test.ModelDrivenAction2;
import com.opensymphony.xwork2.test.TestBean2;
import org.apache.struts2.config.StrutsXmlConfigurationProvider;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.text.DateFormat;
import java.text.ParseException;
@@ -83,6 +84,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase {
public static class MyAction extends ActionSupport {
private Bar testBean2;
@StrutsParameter(depth = 1)
public Bar getBarObj() {
return testBean2;
}
@@ -460,7 +462,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase {
/**
* Test the {@link StrutsLocalizedTextProvider#findText(java.lang.Class, java.lang.String, java.util.Locale, java.lang.String, java.lang.Object[], com.opensymphony.xwork2.util.ValueStack) }
* method for basic correctness.
*
*
* It is the version of the method that will search the class hierarchy resource bundles first, unless {@link StrutsLocalizedTextProvider#searchDefaultBundlesFirst}
* is true (in which case it will search the default resource bundles first). No matter the flag setting, it should search until it finds a match, or fails to find
* a match and returns the default message parameter that was passed.
@@ -611,7 +613,7 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase {
/**
* Attempt to force the resource bundles to be reloaded, even if configuration would otherwise prevent it.
* It will preserve the current reloadBundles state, attempt to force a reload and then restore the
* It will preserve the current reloadBundles state, attempt to force a reload and then restore the
* original reloadBundles value.
*/
public void callReloadBundlesForceReload() {
@@ -625,9 +627,9 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase {
}
/**
* Returns the value of the resource bundles reloaded state from the context, provided that one was
* Returns the value of the resource bundles reloaded state from the context, provided that one was
* previously set. If no value is found, the result will be false (same as if bundles had not been reloaded).
*
*
* @return true if resource bundles reloaded indicator is true, false otherwise (including if value was never set).
*/
public boolean getBundlesReloadedIndicatorValue() {
@@ -25,6 +25,7 @@ import com.opensymphony.xwork2.util.ValueStackFactory;
import com.opensymphony.xwork2.validator.validators.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.validators.RequiredStringValidator;
import com.opensymphony.xwork2.validator.validators.VisitorFieldValidator;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.Collections;
@@ -201,8 +202,10 @@ public class ActionValidatorManagerTest extends XWorkTestCase {
public void setReferenceNumber(String referenceNumber) { this.referenceNumber = referenceNumber; }
public Integer getOrder() { return order; }
@StrutsParameter
public void setOrder(Integer order) { this.order = order; }
@StrutsParameter(depth = 2)
public Customer getCustomer() { return customer; }
public void setCustomer(Customer customer) { this.customer = customer; }
}
@@ -233,4 +236,4 @@ public class ActionValidatorManagerTest extends XWorkTestCase {
public String getPobox() { return pobox; }
public void setPobox(String pobox) { this.pobox = pobox; }
}
}
}
@@ -87,6 +87,7 @@ public class AnnotationValidationAction extends ActionSupport {
messageParams = {"one", "two", "three"})
@VisitorFieldValidator(message = "Foo isn't valid!", key = "visitorfield.key", fieldName = "foo", appendPrefix = false,
shortCircuit = true, messageParams = {"one", "two", "three"})
@Override
public String execute() {
return SUCCESS;
}
@@ -89,6 +89,7 @@ public class AnnotationValidationExpAction extends ActionSupport {
messageParams = {"one", "two", "three"})
@VisitorFieldValidator(message = "Foo isn't valid!", key = "visitorfield.key", fieldName = "foo", appendPrefix = false,
shortCircuit = true, messageParams = {"one", "two", "three"})
@Override
public String execute() {
return SUCCESS;
}
@@ -24,6 +24,7 @@ import com.opensymphony.xwork2.TextProviderFactory;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Arrays;
import java.util.Collection;
@@ -220,6 +221,7 @@ public class StringLengthFieldValidatorTest extends XWorkTestCase {
return this.myField;
}
@StrutsParameter
public void setMyField(String myField) {
this.myField = myField;
}
@@ -228,6 +230,7 @@ public class StringLengthFieldValidatorTest extends XWorkTestCase {
return trimValue;
}
@StrutsParameter
public void setTrimValue(boolean trimValue) {
this.trimValue = trimValue;
}
@@ -236,6 +239,7 @@ public class StringLengthFieldValidatorTest extends XWorkTestCase {
return minLengthValue;
}
@StrutsParameter
public void setMinLengthValue(int minLengthValue) {
this.minLengthValue = minLengthValue;
}
@@ -244,6 +248,7 @@ public class StringLengthFieldValidatorTest extends XWorkTestCase {
return maxLengthValue;
}
@StrutsParameter
public void setMaxLengthValue(int maxLengthValue) {
this.maxLengthValue = maxLengthValue;
}
@@ -252,6 +257,7 @@ public class StringLengthFieldValidatorTest extends XWorkTestCase {
return strings;
}
@StrutsParameter
public void setStrings(String[] strings) {
this.strings = strings;
}
@@ -260,6 +266,7 @@ public class StringLengthFieldValidatorTest extends XWorkTestCase {
return stringCollection;
}
@StrutsParameter
public void setStringCollection(Collection<String> stringCollection) {
this.stringCollection = stringCollection;
}
@@ -19,6 +19,7 @@
package com.opensymphony.xwork2.validator;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -32,6 +33,8 @@ public class VisitorValidatorModelAction extends VisitorValidatorTestAction impl
/**
* @return the model to be pushed onto the ValueStack instead of the Action itself
*/
@StrutsParameter(depth = 2)
@Override
public Object getModel() {
return getBean();
}
@@ -20,6 +20,7 @@ package com.opensymphony.xwork2.validator;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.TestBean;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.Date;
@@ -49,15 +50,16 @@ public class VisitorValidatorTestAction extends ActionSupport {
}
}
public void setBean(TestBean bean) {
this.bean = bean;
}
@StrutsParameter(depth = 2)
public TestBean getBean() {
return bean;
}
@StrutsParameter
public void setContext(String context) {
this.context = context;
}
@@ -70,6 +72,7 @@ public class VisitorValidatorTestAction extends ActionSupport {
this.testBeanArray = testBeanArray;
}
@StrutsParameter(depth = 3)
public TestBean[] getTestBeanArray() {
return testBeanArray;
}
@@ -78,6 +81,7 @@ public class VisitorValidatorTestAction extends ActionSupport {
this.testBeanList = testBeanList;
}
@StrutsParameter(depth = 3)
public List<TestBean> getTestBeanList() {
return testBeanList;
}
@@ -86,6 +90,7 @@ public class VisitorValidatorTestAction extends ActionSupport {
return birthday;
}
@StrutsParameter
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
@@ -41,9 +41,10 @@ public class ExecutionCountTestAction extends ActionSupport {
return executionCount;
}
@Override
public String execute() throws Exception {
executionCount++;
LOG.info("executing ExecutionCountTestAction. Current count is " + executionCount);
LOG.info("executing ExecutionCountTestAction. Current count is {}", executionCount);
return SUCCESS;
}
@@ -68,6 +68,7 @@ public class HttpMethodsTestAction extends ActionSupport implements HttpMethodAw
return "onDelete";
}
@Override
public void setMethod(HttpMethod httpMethod) {
this.httpMethod = httpMethod;
}
@@ -76,6 +77,7 @@ public class HttpMethodsTestAction extends ActionSupport implements HttpMethodAw
return httpMethod;
}
@Override
public String getBadRequestResultName() {
return resultName;
}
@@ -184,6 +184,7 @@ public class TestAction extends ActionSupport {
this.fooInt = fooInt;
}
@Override
public String execute() throws Exception {
if (result == null) {
result = Action.SUCCESS;
@@ -27,6 +27,7 @@ import com.opensymphony.xwork2.security.DefaultAcceptedPatternsChecker;
import com.opensymphony.xwork2.security.DefaultExcludedPatternsChecker;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsInternalTestCase;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.springframework.mock.web.MockHttpServletRequest;
import javax.servlet.http.Cookie;
@@ -503,6 +504,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
private String cookie2;
private String cookie3;
@Override
public void setCookiesMap(Map<String, String> cookies) {
this.cookies = cookies;
}
@@ -515,6 +517,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
return cookie1;
}
@StrutsParameter
public void setCookie1(String cookie1) {
this.cookie1 = cookie1;
}
@@ -523,6 +526,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
return cookie2;
}
@StrutsParameter
public void setCookie2(String cookie2) {
this.cookie2 = cookie2;
}
@@ -531,6 +535,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
return cookie3;
}
@StrutsParameter
public void setCookie3(String cookie3) {
this.cookie3 = cookie3;
}
@@ -543,6 +548,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
private String cookie2;
private String cookie3;
@Override
public void withCookies(Map<String, String> cookies) {
this.cookies = cookies;
}
@@ -555,6 +561,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
return cookie1;
}
@StrutsParameter
public void setCookie1(String cookie1) {
this.cookie1 = cookie1;
}
@@ -563,6 +570,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
return cookie2;
}
@StrutsParameter
public void setCookie2(String cookie2) {
this.cookie2 = cookie2;
}
@@ -571,6 +579,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
return cookie3;
}
@StrutsParameter
public void setCookie3(String cookie3) {
this.cookie3 = cookie3;
}
@@ -27,7 +27,6 @@ import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsInternalTestCase;
import org.apache.struts2.TestAction;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest;
import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
@@ -37,7 +36,6 @@ import org.springframework.mock.web.MockHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
@@ -595,6 +593,7 @@ public class FileUploadInterceptorTest extends StrutsInternalTestCase {
return new MultiPartRequestWrapper(jak, req, tempDir.getAbsolutePath(), new DefaultLocaleProvider());
}
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -605,6 +604,7 @@ public class FileUploadInterceptorTest extends StrutsInternalTestCase {
tempDir.mkdirs();
}
@Override
protected void tearDown() throws Exception {
tempDir.delete();
interceptor.destroy();
@@ -18,13 +18,12 @@
*/
package org.apache.struts2.views.jsp;
import java.util.Iterator;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.util.IteratorGenerator.Converter;
import org.apache.struts2.views.jsp.iterator.IteratorGeneratorTag;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Iterator;
/**
* Test case for IteratorGeneratorTag.
@@ -428,11 +427,7 @@ public class IteratorGeneratorTagTest extends AbstractTagTest {
public Action getAction() {
return new ActionSupport() {
public Converter getMyConverter() {
return new Converter() {
public Object convert(String value) throws Exception {
return "myConverter-"+value;
}
};
return value -> "myConverter-"+value;
}
public int getMyCount() {
@@ -18,18 +18,16 @@
*/
package org.apache.struts2.views.jsp;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.views.jsp.iterator.SortIteratorTag;
import javax.servlet.jsp.JspException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javax.servlet.jsp.JspException;
import org.apache.struts2.views.jsp.iterator.SortIteratorTag;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
/**
* Test case to test SortIteratorTag.
*
@@ -338,13 +336,11 @@ public class SortIteratorTagTest extends AbstractTagTest {
public Action getAction() {
return new ActionSupport() {
public Comparator getComparator() {
return new Comparator() {
public int compare(Object o1, Object o2) {
Integer i1 = (Integer) o1;
Integer i2 = (Integer) o2;
return (o1, o2) -> {
Integer i1 = (Integer) o1;
Integer i2 = (Integer) o2;
return (i1.intValue() - i2.intValue());
}
return (i1 - i2);
};
}
@@ -18,15 +18,14 @@
*/
package org.apache.struts2.views.jsp;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.util.SubsetIteratorFilter.Decider;
import org.apache.struts2.views.jsp.iterator.SubsetIteratorTag;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@@ -641,11 +640,11 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
return new ActionSupport() {
public List getMyList() {
List l = new ArrayList();
l.add(new Integer(1));
l.add(new Integer(2));
l.add(new Integer(3));
l.add(new Integer(4));
l.add(new Integer(5));
l.add(1);
l.add(2);
l.add(3);
l.add(4);
l.add(5);
return l;
}
@@ -660,11 +659,9 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
}
public Decider getMyDecider() {
return new Decider() {
public boolean decide(Object element) throws Exception {
int integer = ((Integer)element).intValue();
return (((integer % 2) == 0)?true:false);
}
return element -> {
int integer = (Integer) element;
return integer % 2 == 0;
};
}
};
@@ -19,6 +19,7 @@
package org.apache.struts2.views.jsp.ui;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*
@@ -30,6 +31,7 @@ public class DoubleValidationAction extends ActionSupport {
return longint;
}
@StrutsParameter
public void setLongint(double longint) {
this.longint = longint;
}
@@ -18,19 +18,18 @@
*/
package org.apache.struts2.views.jsp.ui;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.TestAction;
import org.apache.struts2.views.jsp.AbstractUITagTest;
import org.apache.struts2.views.jsp.ParamTag;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.struts2.views.jsp.AbstractUITagTest;
import org.apache.struts2.views.jsp.ParamTag;
import org.apache.struts2.TestAction;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
/**
* FieldError Tag Test Case.
*
@@ -19,6 +19,7 @@
package org.apache.struts2.views.jsp.ui;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*
@@ -30,6 +31,7 @@ public class IntValidationAction extends ActionSupport {
return longint;
}
@StrutsParameter
public void setLongint(int longint) {
this.longint = longint;
}
@@ -19,6 +19,7 @@
package org.apache.struts.beanvalidation.actions;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.hibernate.validator.constraints.NotBlank;
public class FieldAction extends ActionSupport {
@@ -30,6 +31,7 @@ public class FieldAction extends ActionSupport {
return test;
}
@StrutsParameter
public void setTest(String test) {
this.test = test;
}
@@ -20,6 +20,7 @@ package org.apache.struts.beanvalidation.actions;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts.beanvalidation.constraints.FieldMatch;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
@@ -48,6 +49,7 @@ public class FieldMatchAction extends ActionSupport {
return password;
}
@StrutsParameter
public void setPassword(String password) {
this.password = password;
}
@@ -56,6 +58,7 @@ public class FieldMatchAction extends ActionSupport {
return confirmPassword;
}
@StrutsParameter
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}
@@ -64,6 +67,7 @@ public class FieldMatchAction extends ActionSupport {
return email;
}
@StrutsParameter
public void setEmail(String email) {
this.email = email;
}
@@ -72,6 +76,7 @@ public class FieldMatchAction extends ActionSupport {
return confirmEmail;
}
@StrutsParameter
public void setConfirmEmail(String confirmEmail) {
this.confirmEmail = confirmEmail;
}
@@ -21,14 +21,17 @@ package org.apache.struts.beanvalidation.actions;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts.beanvalidation.models.Person;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import javax.validation.Valid;
public class ModelDrivenAction extends ActionSupport implements ModelDriven<Person>, ModelDrivenActionInterface {
@Valid
private Person model = new Person();
private final Person model = new Person();
@StrutsParameter(depth = 2)
@Override
public Person getModel() {
return model;
}
@@ -22,14 +22,17 @@ import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts.beanvalidation.constraints.ValidationGroup;
import org.apache.struts.beanvalidation.models.Person;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import javax.validation.Valid;
public class ValidateGroupAction extends ActionSupport implements ModelDriven<Person> {
@Valid
private Person model = new Person();
private final Person model = new Person();
@StrutsParameter(depth = 2)
@Override
public Person getModel() {
return model;
}
@@ -67,4 +70,4 @@ public class ValidateGroupAction extends ActionSupport implements ModelDriven<Pe
public String actionLongNameChecks() {
return SUCCESS;
}
}
}

Some files were not shown because too many files have changed in this diff Show More