mirror of
https://github.com/apache/struts.git
synced 2026-08-05 22:56:59 +00:00
Merge remote-tracking branch 'origin/master' into 7.0.x/merge-master-2024-07-20
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -129,11 +129,11 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.htmlunit</groupId>
|
||||
|
||||
+2
-1
@@ -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;
|
||||
}
|
||||
|
||||
+16
-1
@@ -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;
|
||||
}
|
||||
|
||||
+6
-1
@@ -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();
|
||||
}
|
||||
|
||||
+51
-50
@@ -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;
|
||||
|
||||
@@ -33,62 +34,62 @@ import java.util.Collection;
|
||||
|
||||
public abstract class AbstractCRUDAction extends ActionSupport {
|
||||
|
||||
private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class);
|
||||
private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class);
|
||||
|
||||
private Collection availableItems;
|
||||
private String[] toDelete;
|
||||
private Collection availableItems;
|
||||
private String[] toDelete;
|
||||
|
||||
protected abstract Dao getDao();
|
||||
protected abstract Dao getDao();
|
||||
|
||||
public Collection getAvailableItems() {
|
||||
return availableItems;
|
||||
}
|
||||
|
||||
public Collection getAvailableItems() {
|
||||
return availableItems;
|
||||
}
|
||||
public String[] getToDelete() {
|
||||
return toDelete;
|
||||
}
|
||||
|
||||
public String[] getToDelete() {
|
||||
return toDelete;
|
||||
}
|
||||
@StrutsParameter
|
||||
public void setToDelete(String[] toDelete) {
|
||||
this.toDelete = toDelete;
|
||||
}
|
||||
|
||||
public void setToDelete(String[] toDelete) {
|
||||
this.toDelete = toDelete;
|
||||
}
|
||||
public String list() throws Exception {
|
||||
this.availableItems = getDao().findAll();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
|
||||
}
|
||||
return execute();
|
||||
}
|
||||
|
||||
public String list() throws Exception {
|
||||
this.availableItems = getDao().findAll();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
|
||||
}
|
||||
return execute();
|
||||
}
|
||||
public String delete() throws Exception {
|
||||
if (toDelete != null) {
|
||||
int count = 0;
|
||||
for (String s : toDelete) {
|
||||
count = count + getDao().delete(s);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [delete]: {} items deleted.", count);
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String delete() throws Exception {
|
||||
if (toDelete != null) {
|
||||
int count = 0;
|
||||
for (int i = 0, j = toDelete.length; i < j; i++) {
|
||||
count = count + getDao().delete(toDelete[i]);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted.");
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
|
||||
*
|
||||
* @param tryId The id to try to get persistent object for
|
||||
* @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
|
||||
* object for
|
||||
* @return The persistent object, if found. <tt>null</tt> otherwise.
|
||||
*/
|
||||
protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
|
||||
IdEntity result = null;
|
||||
if (tryId != null) {
|
||||
result = getDao().get(tryId);
|
||||
} else if (tryObject != null) {
|
||||
result = getDao().get(tryObject.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
|
||||
*
|
||||
* @param tryId The id to try to get persistent object for
|
||||
* @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
|
||||
* object for
|
||||
* @return The persistent object, if found. <tt>null</tt> otherwise.
|
||||
*/
|
||||
protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
|
||||
IdEntity result = null;
|
||||
if (tryId != null) {
|
||||
result = getDao().get(tryId);
|
||||
} else if (tryObject != null) {
|
||||
result = getDao().get(tryObject.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+3
@@ -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;
|
||||
}
|
||||
|
||||
+4
-1
@@ -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;
|
||||
}
|
||||
|
||||
+5
-3
@@ -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;
|
||||
}
|
||||
|
||||
+4
-1
@@ -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;
|
||||
}
|
||||
|
||||
+3
@@ -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;
|
||||
}
|
||||
|
||||
+4
-2
@@ -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;
|
||||
}
|
||||
|
||||
+6
-4
@@ -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 {
|
||||
|
||||
+5
-2
@@ -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);
|
||||
|
||||
+1
-2
@@ -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());
|
||||
}
|
||||
|
||||
+5
-1
@@ -28,12 +28,16 @@ import org.apache.struts2.dispatcher.multipart.UploadedFile;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Showcase action - mutiple file upload using array.
|
||||
* Showcase action - multiple file upload using array.
|
||||
*/
|
||||
public class MultipleFileUploadUsingArrayAction extends ActionSupport implements UploadedFilesAware {
|
||||
|
||||
private List<UploadedFile> uploadedFiles;
|
||||
|
||||
public List<UploadedFile> getUpload() {
|
||||
return this.uploadedFiles;
|
||||
}
|
||||
|
||||
public String upload() throws Exception {
|
||||
System.out.println("\n\n upload2");
|
||||
System.out.println("files:");
|
||||
|
||||
+5
-1
@@ -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;
|
||||
}
|
||||
|
||||
+4
-2
@@ -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;
|
||||
}
|
||||
|
||||
+4
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.modelDriven;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
import org.apache.struts2.showcase.modelDriven.model.Gangster;
|
||||
|
||||
/**
|
||||
* Action to demonstrate simple model-driven feature of the framework.
|
||||
@@ -30,14 +31,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();
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.struts2.showcase.modelDriven;
|
||||
package org.apache.struts2.showcase.modelDriven.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
+4
-2
@@ -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;
|
||||
}
|
||||
|
||||
+2
-1
@@ -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;
|
||||
}
|
||||
|
||||
+9
-3
@@ -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 jakarta.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;
|
||||
}
|
||||
|
||||
+3
@@ -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;
|
||||
}
|
||||
|
||||
+2
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -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;
|
||||
}
|
||||
|
||||
+5
-4
@@ -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;
|
||||
}
|
||||
|
||||
+5
-4
@@ -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;
|
||||
}
|
||||
|
||||
+6
-7
@@ -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;
|
||||
}
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ public abstract class AbstractValidationActionSupport extends ActionSupport {
|
||||
return "success";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return "input";
|
||||
}
|
||||
|
||||
+20
-11
@@ -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;
|
||||
}
|
||||
|
||||
+11
-2
@@ -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;
|
||||
}
|
||||
|
||||
+5
@@ -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;
|
||||
}
|
||||
|
||||
+3
@@ -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;
|
||||
}
|
||||
|
||||
+3
@@ -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;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class JVMAction implements ServletRequestAware {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public class ImportantInfo {
|
||||
public static class ImportantInfo {
|
||||
private String classpath;
|
||||
private Properties systemProperties;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</action>
|
||||
|
||||
<action name="doMultipleUploadUsingList" class="org.apache.struts2.showcase.fileupload.MultipleFileUploadUsingListAction" method="upload">
|
||||
<result name="input">/WEB-INF/fileupload/multipleUploadUsingList.jsp</result>
|
||||
<result name="input">/WEB-INF/fileupload/multipleUploadUsingList.jsp</result>
|
||||
<result>/WEB-INF/fileupload/multiple-success.jsp</result>
|
||||
</action>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
</action>
|
||||
|
||||
<action name="doMultipleUploadUsingArray" class="org.apache.struts2.showcase.fileupload.MultipleFileUploadUsingArrayAction" method="upload">
|
||||
<result name="input">/WEB-INF/fileupload/multipleUploadUsingArray.jsp</result>
|
||||
<result name="input">/WEB-INF/fileupload/multipleUploadUsingArray.jsp</result>
|
||||
<result>/WEB-INF/fileupload/multiple-success.jsp</result>
|
||||
</action>
|
||||
|
||||
|
||||
@@ -36,6 +36,15 @@
|
||||
|
||||
<constant name="struts.allowlist.enable" value="true" />
|
||||
<constant name="struts.parameters.requireAnnotations" value="true" />
|
||||
<constant name="struts.allowlist.packageNames" value="
|
||||
org.apache.struts2.showcase.model,
|
||||
org.apache.struts2.showcase.modelDriven.model
|
||||
"/>
|
||||
<constant name="struts.allowlist.classes" value="
|
||||
org.apache.struts2.showcase.hangman.Hangman,
|
||||
org.apache.struts2.showcase.hangman.HangmanConstants,
|
||||
org.apache.struts2.showcase.hangman.Vocab
|
||||
"/>
|
||||
|
||||
<constant name="struts.convention.package.locators.basePackage" value="org.apache.struts2.showcase" />
|
||||
<constant name="struts.convention.result.path" value="/WEB-INF" />
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package it.org.apache.struts2.showcase;
|
||||
|
||||
import org.htmlunit.WebClient;
|
||||
import org.htmlunit.html.HtmlForm;
|
||||
import org.htmlunit.html.HtmlPage;
|
||||
import org.htmlunit.html.HtmlSubmitInput;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ConventionTest {
|
||||
|
||||
private WebClient webClient;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
webClient = new WebClient();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
webClient.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listPeople() throws Exception {
|
||||
HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/person/list-people.action");
|
||||
|
||||
assertThat(page.asNormalizedText()).contains(
|
||||
"3\tAlexandru\tPapesco\n" +
|
||||
"4\tJay\tBoss\n" +
|
||||
"5\tRainer\tHermanos\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void editPeople() throws Exception {
|
||||
HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/person/edit-person.action");
|
||||
HtmlForm form = page.getForms().get(0);
|
||||
|
||||
form.getInputByName("persons(1).name").setValue("Lukasz");
|
||||
form.getInputByName("persons(1).lastName").setValue("Lenart");
|
||||
form.getInputByName("persons(2).name").setValue("Kusal");
|
||||
form.getInputByName("persons(2).lastName").setValue("Kithul-Godage");
|
||||
|
||||
HtmlSubmitInput button = form.getInputByValue("Save all persons");
|
||||
page = button.click();
|
||||
|
||||
assertThat(page.asNormalizedText()).contains(
|
||||
"1\tLukasz\tLenart\n" +
|
||||
"2\tKusal\tKithul-Godage\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPerson() throws Exception {
|
||||
HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/person/new-person!input.action");
|
||||
HtmlForm form = page.getForms().get(0);
|
||||
|
||||
form.getInputByName("person.name").type("Lukasz");
|
||||
form.getInputByName("person.lastName").type("Lenart");
|
||||
|
||||
HtmlSubmitInput button = form.getInputByValue("Create person");
|
||||
page = button.click();
|
||||
|
||||
assertThat(page.asNormalizedText()).contains("6\tLukasz\tLenart\n");
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,21 @@
|
||||
package com.opensymphony.xwork2.config;
|
||||
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* ConfigurationUtil
|
||||
*
|
||||
*
|
||||
* @author Jason Carreira Created May 23, 2003 11:22:49 PM
|
||||
*/
|
||||
public class ConfigurationUtil {
|
||||
@@ -83,4 +86,12 @@ public class ConfigurationUtil {
|
||||
|
||||
return parents;
|
||||
}
|
||||
|
||||
public static Set<Class<?>> getAllClassTypes(Class<?> clazz) {
|
||||
HashSet<Class<?>> classes = new HashSet<>();
|
||||
classes.add(clazz);
|
||||
classes.addAll(ClassUtils.getAllSuperclasses(clazz));
|
||||
classes.addAll(ClassUtils.getAllInterfaces(clazz));
|
||||
return classes;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-10
@@ -45,7 +45,6 @@ import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
import com.opensymphony.xwork2.util.location.LocationUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -109,6 +108,11 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid
|
||||
this.valueSubstitutor = valueSubstitutor;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setProviderAllowlist(ProviderAllowlist providerAllowlist) {
|
||||
this.providerAllowlist = providerAllowlist;
|
||||
}
|
||||
|
||||
public XmlDocConfigurationProvider(Document... documents) {
|
||||
this.documents = Arrays.asList(documents);
|
||||
}
|
||||
@@ -135,11 +139,6 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
private void registerAllowlist() {
|
||||
providerAllowlist = configuration.getContainer().getInstance(ProviderAllowlist.class);
|
||||
providerAllowlist.registerAllowlist(this, allowlistClasses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (providerAllowlist != null) {
|
||||
@@ -149,9 +148,8 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid
|
||||
|
||||
protected Class<?> allowAndLoadClass(String className) throws ClassNotFoundException {
|
||||
Class<?> clazz = loadClass(className);
|
||||
allowlistClasses.add(clazz);
|
||||
allowlistClasses.addAll(ClassUtils.getAllSuperclasses(clazz));
|
||||
allowlistClasses.addAll(ClassUtils.getAllInterfaces(clazz));
|
||||
allowlistClasses.addAll(ConfigurationUtil.getAllClassTypes(clazz));
|
||||
providerAllowlist.registerAllowlist(this, allowlistClasses);
|
||||
return clazz;
|
||||
}
|
||||
|
||||
@@ -333,7 +331,6 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid
|
||||
}
|
||||
|
||||
declaredPackages.clear();
|
||||
registerAllowlist();
|
||||
configuration = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,11 @@ import java.lang.annotation.Target;
|
||||
* a HttpRequest parameter.
|
||||
*
|
||||
* @author martin.gilday
|
||||
* @deprecated since 6.6.0, use {@link org.apache.struts2.interceptor.parameter.StrutsParameter}.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Deprecated
|
||||
public @interface Allowed {
|
||||
|
||||
}
|
||||
|
||||
+5
-2
@@ -23,13 +23,13 @@ import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.interceptor.ParameterFilterInterceptor;
|
||||
import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
|
||||
import com.opensymphony.xwork2.util.AnnotationUtils;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import org.apache.struts2.interceptor.parameter.ParametersInterceptor;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,10 @@ import java.util.List;
|
||||
* </p>
|
||||
*
|
||||
* @author martin.gilday
|
||||
* @deprecated since 6.6.0, integrated into {@link ParametersInterceptor} with {@link StrutsParameter} using
|
||||
* {@code struts.parameters.requireAnnotations=true}
|
||||
*/
|
||||
@Deprecated
|
||||
public class AnnotationParameterFilterInterceptor extends AbstractInterceptor {
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -31,9 +31,11 @@ import java.lang.annotation.Target;
|
||||
* To allow access to a field it must be annotated with {@link Allowed}
|
||||
*
|
||||
* @author martin.gilday
|
||||
* @deprecated since 6.6.0, use {@code struts.parameters.requireAnnotations=true} to block all parameters globally.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Deprecated
|
||||
public @interface BlockByDefault {
|
||||
|
||||
}
|
||||
|
||||
@@ -28,9 +28,11 @@ import java.lang.annotation.Target;
|
||||
* a HttpRequest parameter.
|
||||
*
|
||||
* @author martin.gilday
|
||||
* @deprecated since 6.6.0, use {@code struts.parameters.requireAnnotations=true} to block all parameters globally.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Deprecated
|
||||
public @interface Blocked {
|
||||
|
||||
}
|
||||
|
||||
@@ -704,11 +704,6 @@ public class OgnlUtil {
|
||||
return createDefaultContext(root, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that the allowlist capability is not enforced by the {@link OgnlContext} returned by this method. Currently,
|
||||
* this context is only leveraged by some public methods on {@link OgnlUtil} which are called by
|
||||
* {@link OgnlReflectionProvider}.
|
||||
*/
|
||||
protected Map<String, Object> createDefaultContext(Object root, ClassResolver resolver) {
|
||||
if (resolver == null) {
|
||||
resolver = container.getInstance(RootAccessor.class);
|
||||
@@ -716,11 +711,7 @@ public class OgnlUtil {
|
||||
throw new IllegalStateException("Cannot find ClassResolver");
|
||||
}
|
||||
}
|
||||
|
||||
SecurityMemberAccess memberAccess = container.getInstance(SecurityMemberAccess.class);
|
||||
memberAccess.useEnforceAllowlistEnabled(Boolean.FALSE.toString());
|
||||
|
||||
return Ognl.createDefaultContext(root, memberAccess, resolver, defaultConverter);
|
||||
return Ognl.createDefaultContext(root, container.getInstance(SecurityMemberAccess.class), resolver, defaultConverter);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
|
||||
@@ -90,6 +90,7 @@ public class SecurityMemberAccess implements MemberAccess {
|
||||
private Set<String> excludedPackageNames = emptySet();
|
||||
private Set<String> excludedPackageExemptClasses = emptySet();
|
||||
|
||||
private static volatile boolean isDevModeLogged = false;
|
||||
private volatile boolean isDevModeInit;
|
||||
private boolean isDevMode;
|
||||
private Set<String> devModeExcludedClasses = unmodifiableSet(new HashSet<>(singletonList(Object.class.getName())));
|
||||
@@ -536,7 +537,10 @@ public class SecurityMemberAccess implements MemberAccess {
|
||||
return;
|
||||
}
|
||||
isDevModeInit = true;
|
||||
LOG.warn("Working in devMode, using devMode excluded classes and packages!");
|
||||
if (!isDevModeLogged) {
|
||||
LOG.warn("Working in devMode, using devMode excluded classes and packages!");
|
||||
isDevModeLogged = true;
|
||||
}
|
||||
excludedClasses = devModeExcludedClasses;
|
||||
excludedPackageNamePatterns = devModeExcludedPackageNamePatterns;
|
||||
excludedPackageNames = devModeExcludedPackageNames;
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.apache.struts2.dispatcher;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
@@ -44,6 +45,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 +63,8 @@ public class DefaultActionSupport extends ActionSupport {
|
||||
/**
|
||||
* @param successResultValue The successResultValue to set.
|
||||
*/
|
||||
@StrutsParameter
|
||||
public void setSuccessResultValue(String successResultValue) {
|
||||
this.successResultValue = successResultValue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -28,13 +28,14 @@ import java.util.Set;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
* Allows {@link ConfigurationProvider}s to register classes that should be allowed to be used in OGNL expressions.
|
||||
* Allows registration of classes that should be allowed to be used in OGNL expressions, using a key to identify the
|
||||
* source of the allowlist.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*/
|
||||
public class ProviderAllowlist {
|
||||
|
||||
private final Map<ConfigurationProvider, Set<Class<?>>> allowlistMap;
|
||||
private final Map<Object, Set<Class<?>>> allowlistMap;
|
||||
private Set<Class<?>> allowlistClasses;
|
||||
|
||||
public ProviderAllowlist() {
|
||||
@@ -42,24 +43,40 @@ public class ProviderAllowlist {
|
||||
reconstructAllowlist();
|
||||
}
|
||||
|
||||
public synchronized void registerAllowlist(ConfigurationProvider configurationProvider, Set<Class<?>> allowlist) {
|
||||
Set<Class<?>> existingAllowlist = allowlistMap.get(configurationProvider);
|
||||
public synchronized void registerAllowlist(Object key, Set<Class<?>> allowlist) {
|
||||
Set<Class<?>> existingAllowlist = allowlistMap.get(key);
|
||||
if (existingAllowlist != null) {
|
||||
clearAllowlist(configurationProvider);
|
||||
clearAllowlist(key);
|
||||
}
|
||||
this.allowlistMap.put(configurationProvider, new HashSet<>(allowlist));
|
||||
this.allowlistMap.put(key, new HashSet<>(allowlist));
|
||||
this.allowlistClasses.addAll(allowlist);
|
||||
}
|
||||
|
||||
public synchronized void clearAllowlist(ConfigurationProvider configurationProvider) {
|
||||
Set<Class<?>> allowlist = allowlistMap.get(configurationProvider);
|
||||
/**
|
||||
* @deprecated since 6.6.0, use {@link #registerAllowlist(Object, Set)}
|
||||
*/
|
||||
@Deprecated
|
||||
public synchronized void registerAllowlist(ConfigurationProvider configurationProvider, Set<Class<?>> allowlist) {
|
||||
registerAllowlist((Object) configurationProvider, allowlist);
|
||||
}
|
||||
|
||||
public synchronized void clearAllowlist(Object key) {
|
||||
Set<Class<?>> allowlist = allowlistMap.get(key);
|
||||
if (allowlist == null) {
|
||||
return;
|
||||
}
|
||||
this.allowlistMap.remove(configurationProvider);
|
||||
this.allowlistMap.remove(key);
|
||||
reconstructAllowlist();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 6.6.0, use {@link #clearAllowlist(Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
public synchronized void clearAllowlist(ConfigurationProvider configurationProvider) {
|
||||
clearAllowlist((Object) configurationProvider);
|
||||
}
|
||||
|
||||
public Set<Class<?>> getProviderAllowlist() {
|
||||
return unmodifiableSet(allowlistClasses);
|
||||
}
|
||||
|
||||
@@ -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 > 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;
|
||||
}
|
||||
|
||||
+7
-1
@@ -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;
|
||||
}
|
||||
|
||||
+10
@@ -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;
|
||||
}
|
||||
|
||||
+6
-3
@@ -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;
|
||||
}
|
||||
|
||||
+6
-3
@@ -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;
|
||||
}
|
||||
|
||||
+3
@@ -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;
|
||||
}
|
||||
|
||||
+6
-4
@@ -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() {
|
||||
|
||||
+4
-1
@@ -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;
|
||||
}
|
||||
|
||||
+1
@@ -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;
|
||||
}
|
||||
|
||||
+7
@@ -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();
|
||||
}
|
||||
|
||||
+6
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ public class TestAction extends ActionSupport {
|
||||
this.fooInt = fooInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
if (result == null) {
|
||||
result = Action.SUCCESS;
|
||||
|
||||
+1
-1
@@ -25,4 +25,4 @@ public class JakartaMultiPartRequestTest extends AbstractMultiPartRequestTest {
|
||||
return new JakartaMultiPartRequest();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user