http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/annotations.md ---------------------------------------------------------------------- diff --git a/source/core-developers/annotations.md b/source/core-developers/annotations.md new file mode 100644 index 0000000..7f7f03c --- /dev/null +++ b/source/core-developers/annotations.md @@ -0,0 +1,116 @@ +--- +layout: core-developers +title: Annotations +--- + +# Annotations + +In many places, applications can use Java 5 annotations as an alternative to XML and Java properties configuration\. This page serves as a reference for all annotations across the framework\. + +####Action Annotations#### + + +Since 2\.1, these annotations are provided by the _Convention Plugin_ \. Codebehind and Zero Config plugins are deprecated from 2\.1 on\. + +| + +Action annotations are available when the framework scans the classpath for Action classes, rather than specifying individual mappings through XML configuration\. See the _Convention Plugin_ page for information on how to set up classpath scanning to allow the use of Action annotations\. + +|Annotation|Description| +|----------|-----------| +|_Actions Annotation_ |Group of @Action annotations, maps multiple URLs to the same action| +|_Action Annotation_ |Defines the URL of an action| +|_InterceptorRefs Annotation_ |Gropup of @InterceptorRef annotations| +|_InterceptorRef Annotation_ |Interceptor, or interceptor stack to be applied to at action| +|_Results Annotation_ |Group of @Result annotations| +|[Result Annotation](result-annotation.html)|Defines a result for an action| +|[Namespace Annotation](namespace-annotation.html)|Set the path of the action URL (used to overwrite the default)| +|_ResultPath Annotation_ |Set where the results are located (used to overwrite the default)| +|[ParentPackage Annotation](parent-package-annotation.html)|Set the parent package of the actions (used to overwrite the default)| +|_ExceptionMappings_ |Group of @ExceptionMapping annotations| +|_ExceptionMapping_ |Defines an exception mapping| + +####Workflow Annotations#### + +|Annotation|Description| +|----------|-----------| +|[InputConfig Annotation](input-config-annotation.html)|Defines what method to execute, or result to be returned if there are validation errors| + +####Interceptor Annotations#### + +To use these annotations, you have to specify the [AnnotationWorkflowInterceptor](annotation-workflow-interceptor.html) to your interceptor stack\. + +|Annotation|Description| +|----------|-----------| +|[After Annotation](after-annotation.html)|Marks a action method that needs to be executed after the result\.| +|[Before Annotation](before-annotation.html)|Marks a action method that needs to be executed before the main action method\.| +|[BeforeResult Annotation](before-result-annotation.html)|Marks a action method that needs to be executed before the result\.| + +####Validation Annotations#### + +To use annotation\-based validation, annotate the class or interface with [Validation Annotation](validation-annotation.html). + +|Annotation|Description| +|----------|-----------| +|[ConversionErrorFieldValidator Annotation](conversion-error-field-validator-annotation.html)|Checks if there are any conversion errors for a field\.| +|[DateRangeFieldValidator Annotation](date-range-field-validator-annotation.html)|Checks that a date field has a value within a specified range\.| +|[DoubleRangeFieldValidator Annotation](double-range-field-validator-annotation.html)|Checks that a double field has a value within a specified range\.| +|[EmailValidator Annotation](email-validator-annotation.html)|Checks that a field is a valid e\-mail address\.| +|[ExpressionValidator Annotation](expression-validator-annotation.html)|Validates an expression\.| +|[FieldExpressionValidator Annotation](field-expression-validator-annotation.html)|Uses an OGNL expression to perform its validator\.| +|[IntRangeFieldValidator Annotation](int-range-field-validator-annotation.html)|Checks that a numeric field has a value within a specified range\.| +|[RegexFieldValidator Annotation](regex-field-validator-annotation.html)|Validates a regular expression for a field\.| +|[RequiredFieldValidator Annotation](required-field-validator-annotation.html)|Checks that a field is non\-null\.| +|[RequiredStringValidator Annotation](required-string-validator-annotation.html)|Checks that a String field is not empty\.| +|[StringLengthFieldValidator Annotation](string-length-field-validator-annotation.html)|Checks that a String field is of the right length\.| +|[UrlValidator Annotation](url-validator-annotation.html)|Checks that a field is a valid URL\.| +|[Validation Annotation](validation-annotation.html)|Marker annotation for validation at Type level\.| +|[Validations Annotation](validations-annotation.html)|Used to group validation annotations\.| +|[VisitorFieldValidator Annotation](visitor-field-validator-annotation.html)|Invokes the validation for a property's object type\.| +|[CustomValidator Annotation](custom-validator-annotation.html)|Use this annotation for your custom validator types\.| + +#####Resources##### + ++ [Validation using Annotations](http://arsenalist\.com/2007/05/10/struts\-2\-validation\-using\-annotations/)^[http://arsenalist\.com/2007/05/10/struts\-2\-validation\-using\-annotations/] (arsenalist) + +####Type Conversion Annotations#### + +By default, type conversion for Maps and Collections using generics is directly supported\. + +In short, instead of specifying the types found in collections and maps as documented in [Type Conversion](type-conversion.html), **the collection's generic type is used**\. By using annotations, an application should be able to avoid using any + +~~~~~~~ +ClassName-conversion.properties +~~~~~~~ + files\. + +To use annotation\-based type conversion, annotate the class or interface with the [Conversion Annotation](conversion-annotation.html). + +|Annotation|Description| +|----------|-----------| +|[Conversion Annotation](conversion-annotation.html)|Marker annotation for type conversions at Type level\.| +|[CreateIfNull Annotation](create-if-null-annotation.html)|For Collection and Map types: Create the types within the Collection or Map, if null\.| +|[Element Annotation](element-annotation.html)|For Generic types: Specify the element type for Collection types and Map values\.| +|[Key Annotation](key-annotation.html)|For Generic types: Specify the key type for Map keys\.| +|[KeyProperty Annotation](key-property-annotation.html)|For Generic types: Specify the key property name value\.| +|[TypeConversion Annotation](type-conversion-annotation.html)|Used for class and application wide conversion rules\.| + +####Tiles Annotations#### + +The _Tiles Plugin_ provides it's own set of Annotations\. They can be used to keep + +~~~~~~~ +tiles.xml +~~~~~~~ + short\. Instead tiles definitions can be created by annotating actions\. + +|Annotation|Description| +|----------|-----------| +|TilesDefinition|Represents a \<definition\> element in tiles\.xml| +|TilesDefinitions|A list of TilesDefinition Annotations| +|TilesPutAttribute|Represents a \<put\-attribute\> element in tiles\.xml| +|TilesPutListAttribute|Represents a \<put\-list\-attribute\> element in tiles\.xml| +|TilesAddAttribute|Represents a \<add\-attribute\> element in tiles\.xml| +|TilesAddListAttribute|Represents a \<add\-list\-attribute\> element in tiles\.xml| + +Â \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/application-servers.md ---------------------------------------------------------------------- diff --git a/source/core-developers/application-servers.md b/source/core-developers/application-servers.md new file mode 100644 index 0000000..e368168 --- /dev/null +++ b/source/core-developers/application-servers.md @@ -0,0 +1,30 @@ +--- +layout: core-developers +title: Application Servers +--- + +# Application Servers + +The framework is known to work well with most application servers\. If a server's name is linked, then there may be some extra steps to obtain full functionality\. + ++ Jetty + ++ JRun + ++ OC4J + ++ Orion + ++ Resin + ++ [SunOne 7.0](sunone-7-0.html) + ++ [JBoss 5](jboss-5.html) + ++ [WebLogic](weblogic.html) + ++ [WebLogic 6.1](weblogic-6-1.html) + ++ [WebSphere](websphere.html) + ++ [Glassfish 2\.x](glassfish-2-x.html) http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/attachments/att1607_overview.png ---------------------------------------------------------------------- diff --git a/source/core-developers/attachments/att1607_overview.png b/source/core-developers/attachments/att1607_overview.png new file mode 100644 index 0000000..a116c7b Binary files /dev/null and b/source/core-developers/attachments/att1607_overview.png differ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/attachments/att1846_nutshell.GIF ---------------------------------------------------------------------- diff --git a/source/core-developers/attachments/att1846_nutshell.GIF b/source/core-developers/attachments/att1846_nutshell.GIF new file mode 100644 index 0000000..f2b3e36 Binary files /dev/null and b/source/core-developers/attachments/att1846_nutshell.GIF differ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/attachments/att2475_Struts2-Architecture.png ---------------------------------------------------------------------- diff --git a/source/core-developers/attachments/att2475_Struts2-Architecture.png b/source/core-developers/attachments/att2475_Struts2-Architecture.png new file mode 100644 index 0000000..dc4d5dd Binary files /dev/null and b/source/core-developers/attachments/att2475_Struts2-Architecture.png differ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/attachments/struts2-arch.png ---------------------------------------------------------------------- diff --git a/source/core-developers/attachments/struts2-arch.png b/source/core-developers/attachments/struts2-arch.png new file mode 100644 index 0000000..a9979bf Binary files /dev/null and b/source/core-developers/attachments/struts2-arch.png differ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/basic-validation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/basic-validation.md b/source/core-developers/basic-validation.md new file mode 100644 index 0000000..dffeab0 --- /dev/null +++ b/source/core-developers/basic-validation.md @@ -0,0 +1,63 @@ +--- +layout: core-developers +title: Basic Validation +--- + +# Basic Validation + +Let's configure a basic validation workflow, step by step\. + +#####Step 1##### + +Create the input form\. + +~~~~~~~ +{snippet:id=basicValidation|javadoc=false|lang=xml|url=struts2/apps/showcase/src/main/webapp/WEB-INF/validation/quiz-basic.jsp} +~~~~~~~ + +#####Step 2##### + +Create the Action class\. + +~~~~~~~ +{snippet:id=quizAction|javadoc=false|lang=java|url=struts2/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/QuizAction.java} +~~~~~~~ + +#####Step 3##### + +Create the validators\. The + +~~~~~~~ +validation.xml +~~~~~~~ + format is either + +~~~~~~~ +<ActionClassName>-validation.xml +~~~~~~~ + or + +~~~~~~~ +<ActionClassName>-<ActionAliasName>-validation.xml +~~~~~~~ +\. + +~~~~~~~ +{snippet:id=quizValidators|javadoc=false|lang=xml|url=struts2/apps/showcase/src/main/resources/org/apache/struts2/showcase/validation/QuizAction-validation.xml} +~~~~~~~ + +#####Step 4##### + +Make sure there is a result for "input" listed in the struts\.xml for when the validation fails: + + +~~~~~~~ +<action name="HelloWorld" class="tutorial.HelloWorld"> +<result name="success">/tutorial/createconfirm.jsp</result> +<result name="error">/tutorial/error.jsp</result> +<result name="input">/tutorial/create.jsp</result> +</action> + +~~~~~~~ + +If you don't have this, you'll get a: "No result defined for action xxx\.xxx\.tutorial\.HellowWorld and result input" error http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/bean-configuration.md ---------------------------------------------------------------------- diff --git a/source/core-developers/bean-configuration.md b/source/core-developers/bean-configuration.md new file mode 100644 index 0000000..cef07d4 --- /dev/null +++ b/source/core-developers/bean-configuration.md @@ -0,0 +1,63 @@ +--- +layout: core-developers +title: Bean Configuration +--- + +# Bean Configuration + +Internally, the framework uses its own _dependency injection_ container\. The container loads key framework objects, so that any piece of the framework can be replaced, extended, or removed in a standard, consistent way\. _Plugins_ , in particular, leverage this capability to extend the framework to provide support for third\-party libraries like _Spring_ or _Sitemesh_ \. + + (ok) Most applications won't need to extend the Bean Configuration\. + +#####Beans##### + +The bean element has one required attribute, + +~~~~~~~ +class +~~~~~~~ +, which specifies the Java class to be created or manipulated\. A bean can either + +1. be created by the framework's container and injected into internal framework objects, or + +2. have values injected to its static methods + +The first use, object injection, is generally accompanied by the + +~~~~~~~ +type +~~~~~~~ + attribute, which tells the container which interface this object implements\. + +The second use, value injection, is good for allowing objects not created by the container to receive framework constants\. Objects using value inject must define the the + +~~~~~~~ +static +~~~~~~~ + attribute\. + +| Attribute | Required | Description | +|-----------|----------|-------------| +| class |**yes**| the name of the bean class | +| type | no | the primary Java interface this class implements | +| name | no | the unique name of this bean; must be unique among other beans that specify the same type| +| scope | no | the scope of the bean; must be either default, singleton, request, session, thread| +| static | no | whether to inject static methods or not; shouldn't be true when the type is specified | +| optional | no | whether the bean is optional or not | + +__Sample usage__ + +**Bean Example (struts\.xml)** + + +~~~~~~~ + +<struts> + + <bean type="com.opensymphony.xwork2.ObjectFactory" name="myfactory" class="com.company.myapp.MyObjectFactory" /> + + ... + +</struts> + +~~~~~~~ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/before-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/before-annotation.md b/source/core-developers/before-annotation.md new file mode 100644 index 0000000..6c5c707 --- /dev/null +++ b/source/core-developers/before-annotation.md @@ -0,0 +1,38 @@ +--- +layout: core-developers +title: Before Annotation +--- + +# Before Annotation + +####Before Annotation#### + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.interceptor.annotations.Before} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.interceptor.annotations.Before} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.interceptor.annotations.Before} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.interceptor.annotations.Before} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/before-result-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/before-result-annotation.md b/source/core-developers/before-result-annotation.md new file mode 100644 index 0000000..3969db1 --- /dev/null +++ b/source/core-developers/before-result-annotation.md @@ -0,0 +1,38 @@ +--- +layout: core-developers +title: BeforeResult Annotation +--- + +# BeforeResult Annotation + +####BeforeResult Annotation#### + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.interceptor.annotations.BeforeResult} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.interceptor.annotations.BeforeResult} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.interceptor.annotations.BeforeResult} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.interceptor.annotations.BeforeResult} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/chain-result.md ---------------------------------------------------------------------- diff --git a/source/core-developers/chain-result.md b/source/core-developers/chain-result.md new file mode 100644 index 0000000..4258ff4 --- /dev/null +++ b/source/core-developers/chain-result.md @@ -0,0 +1,29 @@ +--- +layout: core-developers +title: Chain Result +--- + +# Chain Result + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.ActionChainResult} +~~~~~~~ + +####Parameters#### + + + +~~~~~~~ +{snippet:id=params|javadoc=true|url=com.opensymphony.xwork2.ActionChainResult} +~~~~~~~ + +####Examples#### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.ActionChainResult} +~~~~~~~ + http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/chaining-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/chaining-interceptor.md b/source/core-developers/chaining-interceptor.md new file mode 100644 index 0000000..d26b6dd --- /dev/null +++ b/source/core-developers/chaining-interceptor.md @@ -0,0 +1,134 @@ +--- +layout: core-developers +title: Chaining Interceptor +--- + +# Chaining Interceptor + +#####Description##### + +An interceptor that copies all the properties of every object in the value stack to the currently executing object, except for any object that implements [Unchainable](http://struts\.apache\.org/maven/xwork\-core/apidocs/com/opensymphony/xwork2/Unchainable\.html)^[http://struts\.apache\.org/maven/xwork\-core/apidocs/com/opensymphony/xwork2/Unchainable\.html]\. A collection of optional + +~~~~~~~ +includes +~~~~~~~ + and + +~~~~~~~ +excludes +~~~~~~~ + may be provided to control how and which parameters are copied\. Only + +~~~~~~~ +includes +~~~~~~~ + or + +~~~~~~~ +excludes +~~~~~~~ + may be specified\. Specifying both results in undefined behavior\. See the javadocs for [ReflectionProvider\#copy(Object, Object, java\.util\.Map, java\.util\.Collection, java\.util\.Collection)](http://struts\.apache\.org/maven/xwork\-core/apidocs/com/opensymphony/xwork2/util/reflection/ReflectionProvider\.html\#copy(java\.lang\.Object, java\.lang\.Object, java\.util\.Map, java\.util\.Collection, java\.util\.Collection))^[http://struts\.apache\.org/maven/xwork\-core/apidocs/com/opensymphony/xwork2/util/reflection/ReflectionProvider\.html\#copy(java\.lang\.Object, java\.lang\.Object, java\.util\.Map, java\.util\.Collection, java\.util\.Collection)] for more information\. + + + +| It is important to remember that this interceptor does nothing if there are no objects already on the stack\. This means two things: + +| + +| + +| 1. you can safely apply it to all your actions without any worry of adverse affects. + +| + +| 2. it is up to you to ensure an object exists in the stack prior to invoking this action. The most typical way this is done is through the use of the <b>chain</b> result type, which combines with this interceptor to make up the action chaining feature. + +| + +| + + By default Errors, Field errors and Message aren't copied during chaining, to change the behaviour you can specify the below three constants in struts\.properties or struts\.xml: + ++ + +~~~~~~~ +struts.xwork.chaining.copyErrors +~~~~~~~ + \- set to true to copy Action Errors + ++ + +~~~~~~~ +struts.xwork.chaining.copyFieldErrors +~~~~~~~ + \- set to true to copy Field Errors + ++ + +~~~~~~~ +struts.xwork.chaining.copyMessages +~~~~~~~ + \- set to true to copy Action Messages + +__Example:__ + + + +~~~~~~~ +<constant name="struts.xwork.chaining.copyErrors" value="true"/> +~~~~~~~ + +#####Parameters##### + ++ + +~~~~~~~ +excludes +~~~~~~~ +  (optional) \- the list of parameter names to exclude from copying (all others will be included) + ++ + +~~~~~~~ +includes +~~~~~~~ + (optional) \- the list of parameter names to include when copying (all others will be excluded) + +#####Extending the Interceptor##### + +There are no known extension points to this interceptor\. + +#####Examples##### + +Simple example how to chain two actions + + +~~~~~~~ +<action name="someAction" class="com.examples.SomeAction"> + <interceptor-ref name="basicStack"/> + <result name="success" type="chain">otherAction</result> +</action> + +<action name="otherAction" class="com.examples.OtherAction"> + <interceptor-ref name="chain"/> + <interceptor-ref name="basicStack"/> + <result name="success">good_result.ftl</result> +</action> +~~~~~~~ + +This examples chains two actions but only one property from first action is copied to another + + +~~~~~~~ +<action name="someAction" class="com.examples.SomeAction"> + <interceptor-ref name="basicStack"/> + <result name="success" type="chain">otherAction</result> +</action> + +<action name="otherAction" class="com.examples.OtherAction"> + <interceptor-ref name="chainStack"> + <param name="chain.includes">prop1</param> + </interceptor-ref> + <result name="success">good_result.ftl</result> +</action> +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/checkbox-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/checkbox-interceptor.md b/source/core-developers/checkbox-interceptor.md new file mode 100644 index 0000000..db3aec9 --- /dev/null +++ b/source/core-developers/checkbox-interceptor.md @@ -0,0 +1,61 @@ +--- +layout: core-developers +title: Checkbox Interceptor +--- + +# Checkbox Interceptor + + + +~~~~~~~ +org.apache.struts2.interceptor.CheckboxInterceptor +~~~~~~~ + is in the + +~~~~~~~ +defaultStack +~~~~~~~ +\. It checks each form parameter submitted to the action and if it finds one with a prefix of + +~~~~~~~ +_checkbox +~~~~~~~ + it inserts a value for a parameter whose name is derived from the suffix to + +~~~~~~~ +_checkbox +~~~~~~~ + if it does not exist\. The default value inserted is + +~~~~~~~ +false +~~~~~~~ + but this can be changed by setting the + +~~~~~~~ +uncheckedValue +~~~~~~~ + parameter on the interceptor\. + +This means that a checkbox can be accompanied by a hidden input with the same name but a prefix of + +~~~~~~~ +_checkbox +~~~~~~~ + so that if the checkbox is not checked on the form the action will still receive a value rather than the default HTML action of not providing a value for unchecked checkboxes\. + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=org.apache.struts2.interceptor.CheckboxInterceptor} +~~~~~~~ + +#####Extending the Interceptor##### + + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=org.apache.struts2.interceptor.CheckboxInterceptor} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/client-side-validation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/client-side-validation.md b/source/core-developers/client-side-validation.md new file mode 100644 index 0000000..0d64788 --- /dev/null +++ b/source/core-developers/client-side-validation.md @@ -0,0 +1,88 @@ +--- +layout: core-developers +title: Client Side Validation +--- + +# Client Side Validation + +The framework adds support for client\-side validation on top of the standard validation framework\. + +Client\-side validation can be enabled on a per\-form basis by specifying + +~~~~~~~ +validate="true" +~~~~~~~ + in the _form_ tag\. + + +~~~~~~~ +<s:form name="test" action="javascriptValidation" validate="true"> + ... +</s:form> + +~~~~~~~ + +If a + +~~~~~~~ +name +~~~~~~~ + for the form is not given, the action mapping name will be used as the form name\. Otherwise, a correct + +~~~~~~~ +action +~~~~~~~ + and + +~~~~~~~ +namespace +~~~~~~~ + attributes must be provided to the + +~~~~~~~ +<saf:form> +~~~~~~~ + tag\. + +**Referencing "submitProfile" in the "/user" namespace** + + +~~~~~~~ +<s:form namespace="/user" action="submitProfile" validate="true"> + ... +</s:form> + +~~~~~~~ + +Technically, the form's action attribute can refer to a "path" that includes the namespace and action as a URI\. But, client\-side validation **requires** that the action name and namespeact to be set separately\. + +**Won't work with client\-side validation\!** + + +~~~~~~~ +<s:form action="/user/submitProfile.action" validate="true"> + ... +</s:form> + +~~~~~~~ + +All the usual [validation configuration](#PAGE_14292) steps apply to client\-side validation\. Client\-side validation uses the same validation rules as server\-side validation\. If server\-side validation doesn't work, then client\-side validation won't work either\. + +**(i) The left hand doesn't know \.\.\.** + + +> + +> + +> The required attribute on many _Struts Tags_ is not integrated with client\-side validation\! The tag attribute is used by certain themes (like xhtml) to put a visual marker (usually '\*') next to the field\. The tag doesn't know if the validation system actually "requires" the field or not\. + +> + +#####Client Side Validation Types##### + +There are two styles of client side validation\. + +|[Pure JavaScript Client Side Validation](pure-java-script-client-side-validation.html)|Used by the _xhtml theme_ and _css\_xhtml theme_ | +|-----------------------------------------------------|--------------------------------------------------| +|[AJAX Client Side Validation](ajax-client-side-validation.html)|Used by the _ajax theme_ | http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/client-validation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/client-validation.md b/source/core-developers/client-validation.md new file mode 100644 index 0000000..22b876c --- /dev/null +++ b/source/core-developers/client-validation.md @@ -0,0 +1,85 @@ +--- +layout: core-developers +title: Client Validation +--- + +# Client Validation + +Let's create a Client\-Side validation workflow, step by step\. + +(information) The + +~~~~~~~ +validate +~~~~~~~ + attribute is set to + +~~~~~~~ +true +~~~~~~~ +\. + +(information) Some themes do not support client\-side validation\. + +#####Step 1##### + +Create the form\. + +~~~~~~~ +{snippet:id=clientValidation|lang=xml|javadoc=false|url=struts2/apps/showcase/src/main/webapp/WEB-INF/validation/quiz-client.jsp} +~~~~~~~ +(information) This case uses the default xhtml theme, so the + +~~~~~~~ +<s:head > +~~~~~~~ + tag is used to link a style sheet\. + +#####Step 2##### + +Create the Action class\. + +~~~~~~~ +{snippet:id=quizAction|javadoc=false|lang=java|url=struts2/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/QuizAction.java} +~~~~~~~ + +__Step 3__ + +Create the + +~~~~~~~ +validation.xml +~~~~~~~ + to configure the validators to be used\. + +~~~~~~~ +{snippet:id=quizValidators|javadoc=false|lang=xml|url=struts2/apps/showcase/src/main/resources/org/apache/struts2/showcase/validation/QuizAction-validation.xml} +~~~~~~~ + +__Action and Namespace__ + +A correct action and namespace attributes must be provided to the \<s:form\> tag\. For example, if the action named "quizClient" is defined in the "/validation" namespace, the form must be configured as: + + +~~~~~~~ +<s:form method="post" validate="true" action="quizClient" namespace="/validation"> + <s:textfield label="Name" name="name"/> + <s:textfield label="Age" name="age"/> + <s:textfield label="Favorite color" name="answer"/> + <s:submit/> +</s:form> + +~~~~~~~ + +While the following will "work" in the sense that the form will function correctly, **client\-side validation will not**\. That is because Struts must know the exact namespace and action (rather than a URL) to properly support validation\. + + +~~~~~~~ +<s:form method="post" validate="true" action="/validation/quizClient.action"> + <s:textfield label="Name" name="name"/> + <s:textfield label="Age" name="age"/> + <s:textfield label="Favorite color" name="answer"/> + <s:submit/> +</s:form> + +~~~~~~~ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/conditionalvisitor-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/conditionalvisitor-validator.md b/source/core-developers/conditionalvisitor-validator.md new file mode 100644 index 0000000..51db45f --- /dev/null +++ b/source/core-developers/conditionalvisitor-validator.md @@ -0,0 +1,30 @@ +--- +layout: core-developers +title: conditionalvisitor validator +--- + +# conditionalvisitor validator + +####Description#### + + + +~~~~~~~ +{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator} +~~~~~~~ + +####Parameters#### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator} +~~~~~~~ + +####Examples#### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/configuration-elements.md ---------------------------------------------------------------------- diff --git a/source/core-developers/configuration-elements.md b/source/core-developers/configuration-elements.md new file mode 100644 index 0000000..dc0f315 --- /dev/null +++ b/source/core-developers/configuration-elements.md @@ -0,0 +1,50 @@ +--- +layout: core-developers +title: Configuration Elements +--- + +# Configuration Elements + +A web application uses a deployment descriptor to initialize resources like servlets and taglibs\. The deployment descriptor is formatted as a XML document and named + +~~~~~~~ +web.xml +~~~~~~~ +\. + +Likewise, the framework uses a configuration file to initialize its own resources\. These resources include: + ++ _Interceptors_ that can preprocess and postprocess a request + ++ _Action classes_ that can call business logic and data access code + ++ _Results_ that can prepare views, like JavaServer Pages and FreeMarker templates + +At runtime, there is a single configuration for an application\. Prior to runtime, the configuration is defined through one or more XML documents, including the default + +~~~~~~~ +struts.xml +~~~~~~~ + document\. There are several elements that can be configured, including packages, namespaces, includes, actions, results, interceptors, and exceptions\. + +(light\-on) See [struts\.xml](struts-xml.html) for a working example\. + +## Administrative Elements + +- [Bean Configuration](bean-configuration.html) +- [Constant Configuration](constant-configuration.html) +- [Package Configuration](package-configuration.html) +- [Namespace Configuration](namespace-configuration.html) +- [Include Configuration](include-configuration.html) + +## Request Handling Elements + +- [Interceptor Configuration](include-configuration.html) +- [Action Configuration](action-configuration.html) + - [Wildcard Mappings](wildcard-mappings.html) +- [Result Configuration](result-configuration.html) +- [Unknown Handlers](unknown-handlers.html) + +## Error Handling + +- [Exception Configuration](exceptio-configuration.html) http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/configuration-files.md ---------------------------------------------------------------------- diff --git a/source/core-developers/configuration-files.md b/source/core-developers/configuration-files.md new file mode 100644 index 0000000..b2efcab --- /dev/null +++ b/source/core-developers/configuration-files.md @@ -0,0 +1,53 @@ +--- +layout: core-developers +title: Configuration Files +--- + +# Configuration Files + +From a Struts developer point of view, the one required configuration file used by the framework is + +~~~~~~~ +web.xml +~~~~~~~ +\. From here, you have full control over how Struts configures both itself and your application\. By default, Struts will load a set of internal configuration files to configure itself, then another set to configure your application, however it is possible to build an entire Struts application without writing a single configuration file other than + +~~~~~~~ +web.xml +~~~~~~~ +\. + +The table lists the files that you can use to configure the framework for your application\. Some configuration files can be reloaded dynamically\. Dynamic reloading makes interactive development possible\. See [Reloading configuration](reloading-configuration.html) for more\. + +| File | Optional | Location (relative to webapp) | Purpose | +|------|----------|-------------------------------|---------| +|[web.xml](web-xml.html)| no | /WEB\-INF/ | Web deployment descriptor to include all necessary framework components | +|[struts.xml](struts-xml.html)| yes | /WEB\-INF/classes/ | Main configuration, contains result/view types, action mappings, interceptors, and so forth \ +| +|[struts.properties](struts-properties.html)| yes | /WEB\-INF/classes/ | Framework properties | +|[struts\-default\.xml](struts-default-xml.html)| yes | /WEB\-INF/lib/struts2\-core\.jar | Default configuration provided by Struts | +|[struts\-default\.vm](struts-default-vm.html)| yes | /WEB\-INF/classes/ | Default macros referenced by velocity\.properties| +| struts\-plugin\.xml | yes | At the root of a plugin JAR| Optional configuration files for _Plugins_ in the same format as struts\.xml\. | +|[velocity\.properties](velocity-properties.html)| yes | /WEB\-INF/classes/ | Override the default _Velocity_ configuration | + +####Static Content#### + +Common static content that is needed by the framework (JavaScript and CSS files, etc\.) is served automatically by the FilterDispatcher filter\. Any request starting with " + +~~~~~~~ +/struts/ +~~~~~~~ +" denotes that static content is required, and then mapping the value after " + +~~~~~~~ +/struts/ +~~~~~~~ +" to common packages in the framework and, optionally in the application's class path\. + +By default, the following packages are searched: + ++ org\.apache\.struts2\.static + ++ template + +Additional packages can be specified by providing a comma separated list to the configuration parameter named "packages" (configured in web\.xml for the FilterDispatcher filter)\. When specifying additional static content, you should be careful not to expose sensitive configuration information (such as the password to a database)\. http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/configuration-provider-and-configuration.md ---------------------------------------------------------------------- diff --git a/source/core-developers/configuration-provider-and-configuration.md b/source/core-developers/configuration-provider-and-configuration.md new file mode 100644 index 0000000..c2a6f7e --- /dev/null +++ b/source/core-developers/configuration-provider-and-configuration.md @@ -0,0 +1,109 @@ +--- +layout: core-developers +title: Configuration Provider & Configuration +--- + +# Configuration Provider & Configuration + +The ConfigurationProvider interface describes the framework's configuration\. By default, the framework loads its configurations via an XML document by using the + +~~~~~~~ +StrutsXmlConfigurationProvider +~~~~~~~ +\. The provider can be configured through a Dispatcher's [DispatcherListener](dispatcher-listener.html)\. + +####Example#### + + + +~~~~~~~ + static { + Dispatcher.addDispatcherListener(new DispatcherListener() { + .... + public void dispatcherInitialized(Dispatcher du) { + ConfigurationManager confManager = du.getConfigurationManager(); + confManager.addConfigurationProvider( ... ); + } + .... + }); + } + +~~~~~~~ + +####Configuration provider#### + + + +~~~~~~~ +ConfigurationProvider +~~~~~~~ + is the basic piece of configuration used to tie all the options together in + +~~~~~~~ +ConfigurationManager +~~~~~~~ +\. There is few different implementations that are already used internally by the Apache Struts: + ++ + +~~~~~~~ +XmlConfigurationProvider +~~~~~~~ + \- proprietary XWork implementation which are using + +~~~~~~~ +xwork.xml +~~~~~~~ + file as source of configuration + ++ + +~~~~~~~ +StrutsXmlConfigurationProvider +~~~~~~~ + \- primary configuration provider, represents + +~~~~~~~ +struts.xml +~~~~~~~ + and + +~~~~~~~ +struts-plugin.xml +~~~~~~~ + files + ++ + +~~~~~~~ +PropertiesConfigurationProvider +~~~~~~~ + \- used to load + +~~~~~~~ +struts.properties +~~~~~~~ + ++ + +~~~~~~~ +ServletContextAwareConfigurationProvider +~~~~~~~ + \- marking interface allowing to inject + +~~~~~~~ +ServletContext +~~~~~~~ + into provider + +To inject your custom configuration provider use + +~~~~~~~ +configProviders +~~~~~~~ + + +~~~~~~~ +<init-param/> +~~~~~~~ + in [web.xml](web-xml.html) http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/constant-configuration.md ---------------------------------------------------------------------- diff --git a/source/core-developers/constant-configuration.md b/source/core-developers/constant-configuration.md new file mode 100644 index 0000000..3dea987 --- /dev/null +++ b/source/core-developers/constant-configuration.md @@ -0,0 +1,130 @@ +--- +layout: core-developers +title: Constant Configuration +--- + +# Constant Configuration + + +Constants provide a simple way to customize a Struts application by defining key settings that modify framework and plugin behavior\. There are two key roles for constants\. First, they are used to override settings like the maximum file upload size or whether the Struts framework should be in "devMode" or not, and so on\. Second, they specify which [Bean](#PAGE_29601) implementation, among multiple implementations of a given type, should be chosen\. + +Constants can be declared in multiple files\. By default, constants are searched for in the following order, allowing for subsequent files to override previous ones: + +1. [struts-default.xml](struts-default-xml.html) + +2. struts-plugin.xml + +3. [struts.xml](struts-xml.html) + +4. [struts.properties](struts-properties.html) + +5. [web.xml](web-xml.html) + + (\!) The + +~~~~~~~ +struts.properties +~~~~~~~ + file is provided for backward\-compatiblity with WebWork\. + +#####Constant##### + +In the various XML variants, the constant element has two required attributes: + +~~~~~~~ +name +~~~~~~~ + and + +~~~~~~~ +value +~~~~~~~ +\. + +|Attribute|Required|Description| +|---------|--------|-----------| +|name|**yes**|the name of the constant| +|value|**yes**|the value of the constant| + +In the [struts.properties](struts-properties.html) file, each entry is treated as a constant\. + +In the [web.xml](web-xml.html) file, any FilterDispatcher initialization parameters are loaded as constants\. + +__Value substitution__ + +Since Apache Struts 2\.5\.6 it is possible to use value substitution when defining + +~~~~~~~ +constant +~~~~~~~ +s in + +~~~~~~~ +struts.xml +~~~~~~~ + file\. You can also define a default value if given System property or ENV variable is missing, see example below: + + +~~~~~~~ +<struts> + <constant name="os" value="Current OS = ${os.name}"/> + + + <constant name="struts.devMode" value="${env.STRUTS_DEV_MODE:false}"/> +</struts> +~~~~~~~ + +Note: substitution is limited to System properties and ENV variables and works only for + +~~~~~~~ +constant +~~~~~~~ +s (as for now)\. + +__Sample usage__ + +**Constant Example (struts\.xml)** + + +~~~~~~~ +<struts> + + <constant name="struts.devMode" value="true" /> + + ... + +</struts> + +~~~~~~~ + +**Constant Example (struts\.properties)** + + +~~~~~~~ +struts.devMode = true + +~~~~~~~ + +**Constant Example (web\.xml)** + + +~~~~~~~ +<web-app id="WebApp_9" version="2.4" + xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> + + <filter> + <filter-name>struts</filter-name> + <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> + <init-param> + <param-name>struts.devMode</param-name> + <param-value>true</param-value> + </init-param> + </filter> + + ... + +</web-app> + +~~~~~~~ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/conversion-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/conversion-annotation.md b/source/core-developers/conversion-annotation.md new file mode 100644 index 0000000..e3cdcda --- /dev/null +++ b/source/core-developers/conversion-annotation.md @@ -0,0 +1,38 @@ +--- +layout: core-developers +title: Conversion Annotation +--- + +# Conversion Annotation + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.conversion.annotations.Conversion} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.conversion.annotations.Conversion} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.conversion.annotations.Conversion} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.conversion.annotations.Conversion} +~~~~~~~ + +Check also [TypeConversion Annotation](type-conversion-annotation.html) for more examples! \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/conversion-error-field-validator-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/conversion-error-field-validator-annotation.md b/source/core-developers/conversion-error-field-validator-annotation.md new file mode 100644 index 0000000..00608b0 --- /dev/null +++ b/source/core-developers/conversion-error-field-validator-annotation.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: ConversionErrorFieldValidator Annotation +--- + +# ConversionErrorFieldValidator Annotation + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/conversion-error-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/conversion-error-interceptor.md b/source/core-developers/conversion-error-interceptor.md new file mode 100644 index 0000000..d713fbf --- /dev/null +++ b/source/core-developers/conversion-error-interceptor.md @@ -0,0 +1,46 @@ +--- +layout: core-developers +title: Conversion Error Interceptor +--- + +# Conversion Error Interceptor + +The Struts 2 conversion error interceptor is a subclass of the XWork 2 conversion error interceptor\. + +From the Javadocs of the XWork 2 interceptor: + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor} +~~~~~~~ + +From the Javadocs of the Struts 2 interceptor: + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=org.apache.struts2.interceptor.StrutsConversionErrorInterceptor} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=org.apache.struts2.interceptor.StrutsConversionErrorInterceptor} +~~~~~~~ + +#####Extending the Interceptor##### + + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=org.apache.struts2.interceptor.StrutsConversionErrorInterceptor} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.StrutsConversionErrorInterceptor} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/conversion-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/conversion-validator.md b/source/core-developers/conversion-validator.md new file mode 100644 index 0000000..a28e6eb --- /dev/null +++ b/source/core-developers/conversion-validator.md @@ -0,0 +1,58 @@ +--- +layout: core-developers +title: conversion validator +--- + +# conversion validator + +####Description#### + + + +~~~~~~~ +{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator} +~~~~~~~ + +####Parameters#### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator} +~~~~~~~ + +####Examples#### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator} +~~~~~~~ + +####Repopulating Field upon conversion Error#### + + + +~~~~~~~ +{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport} +~~~~~~~ + + +~~~~~~~ +{snippet:id=exampleJspPage|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport} +~~~~~~~ + + +~~~~~~~ +{snippet:id=exampleXwork|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport} +~~~~~~~ + + +~~~~~~~ +{snippet:id=exampleJava|lang=java|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport} +~~~~~~~ + + +~~~~~~~ +{snippet:id=exampleValidation|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/cookie-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/cookie-interceptor.md b/source/core-developers/cookie-interceptor.md new file mode 100644 index 0000000..030be7a --- /dev/null +++ b/source/core-developers/cookie-interceptor.md @@ -0,0 +1,33 @@ +--- +layout: core-developers +title: Cookie Interceptor +--- + +# Cookie Interceptor + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=org.apache.struts2.interceptor.CookieInterceptor} +~~~~~~~ + +Parameters + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=org.apache.struts2.interceptor.CookieInterceptor} +~~~~~~~ + +Extending the Interceptor + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=org.apache.struts2.interceptor.CookieInterceptor} +~~~~~~~ + +Examples + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.CookieInterceptor} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/cookie-provider-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/cookie-provider-interceptor.md b/source/core-developers/cookie-provider-interceptor.md new file mode 100644 index 0000000..744d316 --- /dev/null +++ b/source/core-developers/cookie-provider-interceptor.md @@ -0,0 +1,33 @@ +--- +layout: core-developers +title: CookieProvider Interceptor +--- + +# CookieProvider Interceptor + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=org.apache.struts2.interceptor.CookieProviderInterceptor} +~~~~~~~ + +Parameters + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=org.apache.struts2.interceptor.CookieProviderInterceptor} +~~~~~~~ + +Extending the Interceptor + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=org.apache.struts2.interceptor.CookieProviderInterceptor} +~~~~~~~ + +Examples + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.CookieProviderInterceptor} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/create-if-null-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/create-if-null-annotation.md b/source/core-developers/create-if-null-annotation.md new file mode 100644 index 0000000..59c8bea --- /dev/null +++ b/source/core-developers/create-if-null-annotation.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: CreateIfNull Annotation +--- + +# CreateIfNull Annotation + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.util.CreateIfNull} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.util.CreateIfNull} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.util.CreateIfNull} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.util.CreateIfNull} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/create-session-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/create-session-interceptor.md b/source/core-developers/create-session-interceptor.md new file mode 100644 index 0000000..2502e44 --- /dev/null +++ b/source/core-developers/create-session-interceptor.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: Create Session Interceptor +--- + +# Create Session Interceptor + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=org.apache.struts2.interceptor.CreateSessionInterceptor} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=org.apache.struts2.interceptor.CreateSessionInterceptor} +~~~~~~~ + +#####Extending the Interceptor##### + + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=org.apache.struts2.interceptor.CreateSessionInterceptor} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.CreateSessionInterceptor} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/custom-validator-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/custom-validator-annotation.md b/source/core-developers/custom-validator-annotation.md new file mode 100644 index 0000000..ee91438 --- /dev/null +++ b/source/core-developers/custom-validator-annotation.md @@ -0,0 +1,40 @@ +--- +layout: core-developers +title: CustomValidator Annotation +--- + +# CustomValidator Annotation + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.CustomValidator} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.CustomValidator} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.CustomValidator} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.validator.annotations.CustomValidator} +~~~~~~~ + +#####Adding Parameters##### + +Use the [ValidationParameter annotation](validation-parameter-annotation.html) to add custom parameter values. http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/date-range-field-validator-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/date-range-field-validator-annotation.md b/source/core-developers/date-range-field-validator-annotation.md new file mode 100644 index 0000000..ed41b03 --- /dev/null +++ b/source/core-developers/date-range-field-validator-annotation.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: DateRangeFieldValidator Annotation +--- + +# DateRangeFieldValidator Annotation + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/date-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/date-validator.md b/source/core-developers/date-validator.md new file mode 100644 index 0000000..c06bed9 --- /dev/null +++ b/source/core-developers/date-validator.md @@ -0,0 +1,35 @@ +--- +layout: core-developers +title: date validator +--- + +# date validator + +####Description#### + + + +~~~~~~~ +{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator} +~~~~~~~ + +####Parameters#### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator} +~~~~~~~ + +**(\!) Warning** + + +> \{snippet:id=parameters\-warning|javadoc=true|url=com\.opensymphony\.xwork2\.validator\.validators\.DateRangeFieldValidator\} + +####Examples#### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/debugging-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/debugging-interceptor.md b/source/core-developers/debugging-interceptor.md new file mode 100644 index 0000000..257fbac --- /dev/null +++ b/source/core-developers/debugging-interceptor.md @@ -0,0 +1,33 @@ +--- +layout: core-developers +title: DebuggingInterceptor +--- + +# DebuggingInterceptor + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=org.apache.struts2.interceptor.debugging.DebuggingInterceptor} +~~~~~~~ + + +~~~~~~~ +{snippet:id=remarks|javadoc=true|url=org.apache.struts2.interceptor.debugging.DebuggingInterceptor} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=org.apache.struts2.interceptor.debugging.DebuggingInterceptor} +~~~~~~~ + +#####Example##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|url=org.apache.struts2.interceptor.debugging.DebuggingInterceptor} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/debugging.md ---------------------------------------------------------------------- diff --git a/source/core-developers/debugging.md b/source/core-developers/debugging.md new file mode 100644 index 0000000..eb2304d --- /dev/null +++ b/source/core-developers/debugging.md @@ -0,0 +1,121 @@ +--- +layout: core-developers +title: Debugging +--- + +# Debugging + +Modern IDEs provide excellent support for debugging\. In addition, the framework provides support for inspecting framework\-specific objects at runtime\. + +The [Debugging Interceptor](debugging-interceptor.html) provides three debugging modes to provide insight into the data behind the page\. The + +~~~~~~~ +xml +~~~~~~~ + mode formats relevant framework objects as an XML document\. The + +~~~~~~~ +console +~~~~~~~ + mode provides a OGNL command line that accepts entry of runtime expressions, and the + +~~~~~~~ +browser +~~~~~~~ + mode adds an interactive page that display objects from the Value Stack\. + +To use the debugging, first be sure that + +~~~~~~~ +struts.devMode +~~~~~~~ + is set to + +~~~~~~~ +true +~~~~~~~ + is enabled through the [struts\.properties](struts-properties.html) file or + +~~~~~~~ +struts.xml +~~~~~~~ + file, like: + + +~~~~~~~ +<constant name="struts.devMode" value="true" /> + +~~~~~~~ + +Then, whenever a page needs debugging, add + +~~~~~~~ +?debug=xml +~~~~~~~ + or + +~~~~~~~ +?debug=console +~~~~~~~ + or + +~~~~~~~ +?debug=browser +~~~~~~~ + to the URL\. + + +~~~~~~~ +- <debug> + <parameters /> +- <context> +- <struts.actionMapping> + <class>class org.apache.struts2.dispatcher.mapper.ActionMapping</class> + <name>showcase</name> + <namespace>/</namespace> + </struts.actionMapping> + <attr /> + <__devMode>true</__devMode> + <report.conversion.errors>false</report.conversion.errors> + </context> + <request /> + <session /> +- <valueStack> +- <value> + <actionErrors /> + <actionMessages /> + <class>class com.opensymphony.xwork2.ActionSupport</class> + <errorMessages /> + <errors /> + <fieldErrors /> +- <locale> + <ISO3Country>USA</ISO3Country> + <ISO3Language>eng</ISO3Language> + <class>class java.util.Locale</class> + <country>US</country> + <displayCountry>United States</displayCountry> + <displayLanguage>English</displayLanguage> + <displayName>English (United States)</displayName> + <displayVariant /> + <language>en</language> + <variant /> + </locale> + </value> +- <value> + <class>class com.opensymphony.xwork2.DefaultTextProvider</class> + </value> + </valueStack> + </debug> + +~~~~~~~ + + + +| For ?debug=xml use Internet Explorer or an [IE tab in FireFox](http://ietab\.mozdev\.org/)^[http://ietab\.mozdev\.org/] + +| + + +For ?debug=console you may need to relax any popup blockers + +| \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/default-workflow-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/default-workflow-interceptor.md b/source/core-developers/default-workflow-interceptor.md new file mode 100644 index 0000000..4d92781 --- /dev/null +++ b/source/core-developers/default-workflow-interceptor.md @@ -0,0 +1,41 @@ +--- +layout: core-developers +title: Default Workflow Interceptor +--- + +# Default Workflow Interceptor + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor} +~~~~~~~ + + +~~~~~~~ +{snippet:id=javadocDefaultWorkflowInterceptor|javadoc=true|url=com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor} +~~~~~~~ + +#####Extending the Interceptor##### + + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/dependency-injection.md ---------------------------------------------------------------------- diff --git a/source/core-developers/dependency-injection.md b/source/core-developers/dependency-injection.md new file mode 100644 index 0000000..6a2e494 --- /dev/null +++ b/source/core-developers/dependency-injection.md @@ -0,0 +1,16 @@ +--- +layout: core-developers +title: Dependency Injection +--- + +# Dependency Injection + +Dependency injection removes the responsibility for object creation and object linking from the objects themselves to a factory\. The factory is often provided by an Inversion of Control (IoC) container\. For an overview of Inversion of Control containers and the Dependency Injection pattern, please see [Martin Fowler's article](http://www\.martinfowler\.com/articles/injection\.html)^[http://www\.martinfowler\.com/articles/injection\.html]\. + +| + +Internally, the framework uses its own dependency injection container that is very similar to Google Guice\. Both were originally developed by [Bob Lee](http://blog\.crazybob\.org/)^[http://blog\.crazybob\.org/]\. Plugins are available to integrate applications with other IoC containers (e\.g\. _Spring Plugin_ , _Plexus Plugin_ )\. An application can even use a local copy of Google Guice for dependency injection needs\. + +(information) Actions can still be instantiated via Spring configuration by way of the _Spring Plugin_ , but Spring is entirely optional\. + + (\!) The WebWork/XWork IoC container utilized by WebWork 2\.1 is not supported by Struts 2\. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/development-mode.md ---------------------------------------------------------------------- diff --git a/source/core-developers/development-mode.md b/source/core-developers/development-mode.md new file mode 100644 index 0000000..332e107 --- /dev/null +++ b/source/core-developers/development-mode.md @@ -0,0 +1,99 @@ +--- +layout: core-developers +title: Development Mode +--- + +# Development Mode (aka "devMode") + +Please turn this option off before deploying application to a production environment \- it can expose sensitive data of your application\! + +> + +Struts 2 has a setting (which can be set to + +~~~~~~~ +true +~~~~~~~ + or + +~~~~~~~ +false +~~~~~~~ + in [struts\.properties](struts-properties.html)) called devMode (= development mode)\. When this setting is enabled, Struts 2 will provide additional logging and debug information, which can significantly speed up development\. + + + +| You can also set this constant in your struts\.xml file: \<constant name="struts\.devMode" value="true" /\>\. + +| + +| + +| This is the preferred method\. See [Constant Configuration](constant-configuration.html) for more information\. + +| + +####What does it do?#### + ++ When enabled, Struts 2 will reload your **resource bundles on every request** (meaning you can change your \.properties files, save them, and see the changes reflected on the next request)\. + Note: this option can also be set standalone via + +~~~~~~~ +struts.i18n.reload = true +~~~~~~~ + ++ It will also **reload your xml configuration files** ([struts.xml](struts-xml.html)), your **validation files**, and so on, on every request\. This is useful for testing or fine\-tuning your configuration without having to redeploy your application every time\. + Note: this option can also be set standalone via + +~~~~~~~ +struts.configuration.xml.reload = true +~~~~~~~ + ++ And thirdly, perhaps the setting which is less widely known, and therefore a source of much confusion: it will **raise the level of debug or normally ignorable problems to errors**\. For example: when you **submit a field which cannot be set on an action** 'someUnknownField', it will normally be ignored\. However, when you're in development mode, **an exception will be thrown**, telling you an invalid field was submitted\. This is very useful for debugging or testing large forms, but can also be confusing if you're relying on parameters in your request that are not set on the action, but which you are using directly in your view layer (**warning**: bad practice, you should always validate input from the web)\. + +####Don't forget\.\.\.#### + +By default, the development mode is disabled, because it has a significant impact on [performance](performance-tuning.html), since the entire configuration will be reloaded on every request\. + +####Page rendering is slow#### + +If you experience slow page rendering when + +~~~~~~~ +devMode +~~~~~~~ + is on it's mostly because Freemarker cache is disabled during + +~~~~~~~ +devMode +~~~~~~~ +\. You can explicit enable cache and any other options disabled by + +~~~~~~~ +devMode +~~~~~~~ +, see example below: + + +~~~~~~~ +<constant name="struts.devMode" value="true" /> +<constant name="struts.i18n.reload" value="false"/> +<constant name="struts.configuration.xml.reload" value="false"/> +<constant name="struts.freemarker.templatesCache" value="true"/> +<constant name="struts.freemarker.templatesCache.updateDelay" value="120"/> +<constant name="struts.freemarker.mru.max.strong.size" value="120"/> + +~~~~~~~ + +As you can see, you can switch + +~~~~~~~ +devMode +~~~~~~~ + on and still have production options on as well\. + + + +| Please remember to use production optimized options which can be different than these used during development (especially cache related)\! + +| http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/dispatcher-listener.md ---------------------------------------------------------------------- diff --git a/source/core-developers/dispatcher-listener.md b/source/core-developers/dispatcher-listener.md new file mode 100644 index 0000000..456db3c --- /dev/null +++ b/source/core-developers/dispatcher-listener.md @@ -0,0 +1,29 @@ +--- +layout: core-developers +title: DispatcherListener +--- + +# DispatcherListener + +Use a DispatcherListener object to execute code when a Dispatcher is initalized or destroyed\. A DispatcherListener is an easy way to associate customizable components like a [ConfigurationManager](configuration-provider-and-configuration.html) with a Dispatcher\. + +####Example#### + + + +~~~~~~~ + + static { + Dispatcher.addDispatcherListener(new DispatcherListener() { + public void dispatcherInitialized(Dispatcher du) { + // do something to Dispatcher after it is initialized eg. + du.setConfigurationManager(....); + } + + public void dispatcherDestroyed(Dispatcher du) { + // do some cleanup after Dispatcher is destroyed. + } + }); + } + +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/dispatcher-result.md ---------------------------------------------------------------------- diff --git a/source/core-developers/dispatcher-result.md b/source/core-developers/dispatcher-result.md new file mode 100644 index 0000000..f3f4279 --- /dev/null +++ b/source/core-developers/dispatcher-result.md @@ -0,0 +1,28 @@ +--- +layout: core-developers +title: Dispatcher Result +--- + +# Dispatcher Result + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=org.apache.struts2.result.ServletDispatcherResult} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=params|javadoc=true|url=org.apache.struts2.result.ServletDispatcherResult} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.result.ServletDispatcherResult} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/dispatcher.md ---------------------------------------------------------------------- diff --git a/source/core-developers/dispatcher.md b/source/core-developers/dispatcher.md new file mode 100644 index 0000000..4a1e727 --- /dev/null +++ b/source/core-developers/dispatcher.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: Dispatcher +--- + +# Dispatcher + +###Description### + +Dispatcher is the main point of control which dispatch request execution to given actions\. It is used by [filters](web-xml.html) / servlet / listener / portlet to set up and run Struts environment\. + +####Error handling#### + +When exception occurs (misconfiguration or some internal error), Dispatcher will pass handling to + +~~~~~~~ +DispatcherErrorHandler +~~~~~~~ + which by default uses + +~~~~~~~ +HttpServletResponse#sendError +~~~~~~~ + to report error back to client\. It will be 404 or 500 by default (depends on exception type)\. + +If you need a different type of handling you can implement your own + +~~~~~~~ +DispatcherErrorHandler +~~~~~~~ + and register it with Dispatcher using extension point + +~~~~~~~ +struts.dispatcher.errorHandler +~~~~~~~ +, see _Plugins_ for how to register your own implementation of internal mechanism\. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/double-range-field-validator-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/double-range-field-validator-annotation.md b/source/core-developers/double-range-field-validator-annotation.md new file mode 100644 index 0000000..bf271ac --- /dev/null +++ b/source/core-developers/double-range-field-validator-annotation.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: DoubleRangeFieldValidator Annotation +--- + +# DoubleRangeFieldValidator Annotation + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.DoubleRangeFieldValidator} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.DoubleRangeFieldValidator} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.DoubleRangeFieldValidator} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.validator.annotations.DoubleRangeFieldValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/double-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/double-validator.md b/source/core-developers/double-validator.md new file mode 100644 index 0000000..0c9a3d4 --- /dev/null +++ b/source/core-developers/double-validator.md @@ -0,0 +1,35 @@ +--- +layout: core-developers +title: double validator +--- + +# double validator + +####Description#### + + + +~~~~~~~ +{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator} +~~~~~~~ + +####Parameters#### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator} +~~~~~~~ + +**(\!) Warning** + + +> \{snippet:id=parameters\-warning|javadoc=true|url=com\.opensymphony\.xwork2\.validator\.validators\.DoubleRangeFieldValidator\} + +####Examples#### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/element-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/element-annotation.md b/source/core-developers/element-annotation.md new file mode 100644 index 0000000..6ed8f83 --- /dev/null +++ b/source/core-developers/element-annotation.md @@ -0,0 +1,43 @@ +--- +layout: core-developers +title: Element Annotation +--- + +# Element Annotation + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.util.Element} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.util.Element} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.util.Element} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ + +// The key property for User objects within the users collection is the <code>userName</code> attribute. +@Element( value = com.acme.User.class ) +private Map userMap; + +@Element( value = com.acme.User.class ) +public List userList; + +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/email-validator-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/email-validator-annotation.md b/source/core-developers/email-validator-annotation.md new file mode 100644 index 0000000..5fbd8b2 --- /dev/null +++ b/source/core-developers/email-validator-annotation.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: EmailValidator Annotation +--- + +# EmailValidator Annotation + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.EmailValidator} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.EmailValidator} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.EmailValidator} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.validator.annotations.EmailValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/email-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/email-validator.md b/source/core-developers/email-validator.md new file mode 100644 index 0000000..590020e --- /dev/null +++ b/source/core-developers/email-validator.md @@ -0,0 +1,35 @@ +--- +layout: core-developers +title: email validator +--- + +# email validator + +####Description#### + + + +~~~~~~~ +{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.EmailValidator} +~~~~~~~ + +####Parameters#### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.EmailValidator} +~~~~~~~ + +**(\!) Warning** + + +> \{snippet:id=parameters\-warning|javadoc=true|url=com\.opensymphony\.xwork2\.validator\.validators\.EmailValidator\} + +####Examples#### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.EmailValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/exceptio-configuration.md ---------------------------------------------------------------------- diff --git a/source/core-developers/exceptio-configuration.md b/source/core-developers/exceptio-configuration.md new file mode 100644 index 0000000..b98b1be --- /dev/null +++ b/source/core-developers/exceptio-configuration.md @@ -0,0 +1,190 @@ +--- +layout: core-developers +title: Exception Configuration +--- + +# Exception Configuration + +Exception mappings is a powerful feature for dealing with an Action class that throws an Exception\. The core idea is that an Exception thrown during the Action method can be automatically caught and mapped to a predefined Result\. This declarative strategy is especially useful for frameworks, like Hibernate and Acegi, that throw RuntimeExceptions\. + +As with many other parts of the framework, an Interceptor is needed to activate the exception mapping functionality\. Below is a snippet from + +~~~~~~~ +struts-default.xml +~~~~~~~ + which has the exception mapping already activated\. + +**snippet of struts\-default\.xml** + + +~~~~~~~ + +... +<interceptors> + ... + <interceptor name="exception" class="com.opensymphony.xwork.interceptor.ExceptionMappingInterceptor"/> + ... +</interceptors> + +<interceptor-stack name="defaultStack"> + <interceptor-ref name="exception"/> + <interceptor-ref name="alias"/> + <interceptor-ref name="servlet-config"/> + <interceptor-ref name="prepare"/> + <interceptor-ref name="i18n"/> + <interceptor-ref name="chain"/> + <interceptor-ref name="debugging"/> + <interceptor-ref name="profiling"/> + <interceptor-ref name="scoped-model-driven"/> + <interceptor-ref name="model-driven"/> + <interceptor-ref name="fileUpload"/> + <interceptor-ref name="checkbox"/> + <interceptor-ref name="static-params"/> + <interceptor-ref name="params"/> + <interceptor-ref name="conversionError"/> + <interceptor-ref name="validation"> + <param name="excludeMethods">input,back,cancel,browse</param> + </interceptor-ref> + <interceptor-ref name="workflow"> + <param name="excludeMethods">input,back,cancel,browse</param> + </interceptor-ref> +</interceptor-stack> +... + +~~~~~~~ + +To use exception mapping, we simply need to map Exceptions to specific Results\. The framework provides two ways to declare an exception mapping + +~~~~~~~ +<exception-mapping/> +~~~~~~~ + \- globally or for a specific action mapping\. The exception mapping element takes two attributes, + +~~~~~~~ +exception +~~~~~~~ + and + +~~~~~~~ +result +~~~~~~~ +\. + +When declaring an exception mapping, the Interceptor will find the closest class inheritance match between the Exception thrown and the Exception declared\. The Interceptor will examine all declared mappings applicable to the action mapping, first local and then global mappings\. If a match is found, the Result is processed, just as if it had been returned by the Action\. + +(information) This process follows the same rules as a Result returned from an Action\. It first looks for the Result in the local action mapping, and if not found, it looks for a global Result\. + +Below is an example of global and local exception mappings\. + +**snippet from struts\.xml** + + +~~~~~~~ + +<struts> + <package name="default"> + ... + <global-results> + <result name="login" type="redirect">/Login.action</result> + <result name="Exception">/Exception.jsp</result> + </global-results> + + <global-exception-mappings> + <exception-mapping exception="java.sql.SQLException" result="SQLException"/> + <exception-mapping exception="java.lang.Exception" result="Exception"/> + </global-exception-mappings> + ... + <action name="DataAccess" class="com.company.DataAccess"> + <exception-mapping exception="com.company.SecurityException" result="login"/> + <result name="SQLException" type="chain">SQLExceptionAction</result> + <result>/DataAccess.jsp</result> + </action> + ... + </package> +</xwork> + +~~~~~~~ + +In the example above, here is what happens based upon each Exception: + ++ A + +~~~~~~~ +java.sql.SQLException +~~~~~~~ + will chain to the + +~~~~~~~ +SQLExceptionAction +~~~~~~~ + (action mapping not shown) + ++ A + +~~~~~~~ +com.company.SecurityException +~~~~~~~ + will redirect to + +~~~~~~~ +Login.action +~~~~~~~ + ++ Any other exception that extends + +~~~~~~~ +java.lang.Exception +~~~~~~~ + will return the + +~~~~~~~ +/Exception.jsp +~~~~~~~ + page + +#####Exception Values on the ValueStack##### + +By default, the + +~~~~~~~ +ExceptionMappingInterceptor +~~~~~~~ + adds the following values to the Value Stack: + +| exception | The exception object itself | +|-----------|-----------------------------| +| exceptionStack | The value from the stack trace | + +**Sample JSP using Error and Exception Values** + + +~~~~~~~ + +<h2>An unexpected error has occurred</h2> +<p> + Please report this error to your system administrator + or appropriate technical support personnel. + Thank you for your cooperation. +</p> +<hr/> +<h3>Error Message</h3> +<s:actionerror/> +<p> + <s:property value="%{exception.message}"/> +</p> +<hr/> +<h3>Technical Details</h3> +<p> + <s:property value="%{exceptionStack}"/> +</p> + +~~~~~~~ + +#####Exception in constructors##### + +Global exception mappings are designed to be used with exceptions thrown by action methods (like + +~~~~~~~ +execute +~~~~~~~ +)\. exceptions thrown from constructors will **not** be handled by global exception mappings\. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/exception-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/exception-interceptor.md b/source/core-developers/exception-interceptor.md new file mode 100644 index 0000000..b29d72f --- /dev/null +++ b/source/core-developers/exception-interceptor.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: Exception Interceptor +--- + +#Exception Interceptor + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor} +~~~~~~~ + +#####Extending the Interceptor##### + + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor} +~~~~~~~ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/execute-and-wait-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/execute-and-wait-interceptor.md b/source/core-developers/execute-and-wait-interceptor.md new file mode 100644 index 0000000..ae73bd9 --- /dev/null +++ b/source/core-developers/execute-and-wait-interceptor.md @@ -0,0 +1,36 @@ +--- +layout: core-developers +title: Execute and Wait Interceptor +--- + +# Execute and Wait Interceptor + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=org.apache.struts2.interceptor.ExecuteAndWaitInterceptor} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=org.apache.struts2.interceptor.ExecuteAndWaitInterceptor} +~~~~~~~ + +#####Extending the Interceptor##### + + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=org.apache.struts2.interceptor.ExecuteAndWaitInterceptor} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.ExecuteAndWaitInterceptor} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/expression-validator-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/expression-validator-annotation.md b/source/core-developers/expression-validator-annotation.md new file mode 100644 index 0000000..93896fa --- /dev/null +++ b/source/core-developers/expression-validator-annotation.md @@ -0,0 +1,34 @@ +--- +layout: core-developers +title: ExpressionValidator Annotation +--- + +# ExpressionValidator Annotation + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.ExpressionValidator} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.ExpressionValidator} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.ExpressionValidator} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.validator.annotations.ExpressionValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/expression-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/expression-validator.md b/source/core-developers/expression-validator.md new file mode 100644 index 0000000..bc2c803 --- /dev/null +++ b/source/core-developers/expression-validator.md @@ -0,0 +1,30 @@ +--- +layout: core-developers +title: expression validator +--- + +# expression validator + +####Description#### + + + +~~~~~~~ +{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ExpressionValidator} +~~~~~~~ + +####Parameters#### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ExpressionValidator} +~~~~~~~ + +####Examples#### + + + +~~~~~~~ +{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ExpressionValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/field-expression-validator-annotation.md ---------------------------------------------------------------------- diff --git a/source/core-developers/field-expression-validator-annotation.md b/source/core-developers/field-expression-validator-annotation.md new file mode 100644 index 0000000..eede6ea --- /dev/null +++ b/source/core-developers/field-expression-validator-annotation.md @@ -0,0 +1,35 @@ +--- +layout: core-developers +title: FieldExpressionValidator Annotation +--- + +# FieldExpressionValidator Annotation + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator} +~~~~~~~ + +#####Usage##### + + + +~~~~~~~ +{snippet:id=usage|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator} +~~~~~~~ + +#####Examples##### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=java|url=com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/fieldexpression-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/fieldexpression-validator.md b/source/core-developers/fieldexpression-validator.md new file mode 100644 index 0000000..ebe1a7c --- /dev/null +++ b/source/core-developers/fieldexpression-validator.md @@ -0,0 +1,30 @@ +--- +layout: core-developers +title: fieldexpression validator +--- + +# fieldexpression validator + +####Description#### + + + +~~~~~~~ +{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.FieldExpressionValidator} +~~~~~~~ + +####Parameters#### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.FieldExpressionValidator} +~~~~~~~ + +####Examples#### + + + +~~~~~~~ +{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.FieldExpressionValidator} +~~~~~~~ http://git-wip-us.apache.org/repos/asf/struts-site/blob/f903a0f7/source/core-developers/file-upload-interceptor.md ---------------------------------------------------------------------- diff --git a/source/core-developers/file-upload-interceptor.md b/source/core-developers/file-upload-interceptor.md new file mode 100644 index 0000000..ef6ccba --- /dev/null +++ b/source/core-developers/file-upload-interceptor.md @@ -0,0 +1,83 @@ +--- +layout: core-developers +title: File Upload Interceptor +--- + +# File Upload Interceptor + + + See [this page](file-upload.html) for more examples and advanced configuration + +| + + + +~~~~~~~ +{snippet:id=description|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor} +~~~~~~~ + +#####Parameters##### + + + +~~~~~~~ +{snippet:id=parameters|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor} +~~~~~~~ + +#####Extending the Interceptor##### + + + +~~~~~~~ +{snippet:id=extending|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor} +~~~~~~~ + +#####Examples##### + +**Example action mapping:** + + +~~~~~~~ +{snippet:id=example-configuration|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor} +~~~~~~~ + +Notice the interceptor configuration in the preceding example\. + +**Example JSP form tags:** + + +~~~~~~~ +{snippet:id=example-form|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor} +~~~~~~~ + + +~~~~~~~ +{snippet:id=multipart-note|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor} +~~~~~~~ + +**Example Action class:** + + +~~~~~~~ +{snippet:id=example-action|lang=java|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor} +~~~~~~~ + +**Setting parameters example:** + + +~~~~~~~ + +<interceptor-ref name="fileUpload"> + <param name="allowedTypes"> + image/png,image/gif,image/jpeg + </param> +</interceptor-ref> + +~~~~~~~ + +This part is optional and would be done in place of the + +~~~~~~~ +<interceptor-ref name="fileUpload"/> +~~~~~~~ + line in the action mapping example above\.
