Seasar DI Container with AOP

S2Struts Outline

S2Struts facilitates the interaction of S2 and Struts. The Action class is used strictly as a controller, keeping its role to call service classes registered within it. This keeps the distinction between the presentation and service layers clear. AOP can be also be applied to Action.

Setup

S2Struts require JDK1.4 or higher, as with S2. Confirmation of operation is handled by Eclipse 3.1.

Import the entire s2struts directory contained in the S2StrutsVx.x.x.zip as a Java project in Eclipse. When Eclipse prompts to overwrite .classpath, select 'all' and 'yes' to do so. This will create the development environment expected in this document.

Check that Tomcat and Tomcat Plugin are installed, as the included samples depend on these files being installed.

Please download and extract the sample files from S2StrutsExampleVx.x.x.zip. We will create a Java project in Eclipse named s2struts-example. Make sure to create a Java project, not a Tomcat project. Import the entire s2struts-example directory. When Eclipse prompts to overwrite .classpath, select 'all' and 'yes' to do so. Right click the s2struts-example project and set the property to tomcat. Confirm the project to be a tomcat project, and set the application URI to be /s2struts-example. Once this is complete, point a browser to http://localhost:8080/s2struts-example/ to see a sample using s2Struts. To see the Employee Management sample, run runHsqldb.bat in the WEB-INF/bin directory to initialize HSQLDB.

S2StrutsBlankVx.x.x.zip contains all files required to use S2Struts in addition to files that are useful in web application development such as Mayaa and S2Dao. When using these files as a prototype for web application development, reference the following list and delete the unused files.

Files required to use S2Struts
WEB-INF/
        struts-config.xml             
        tiles-defs.xml                
        validation.xml                
        validator-rules.xml           
        web.xml                       

WEB-INF/lib
        javassist-3.0.jar                 
        commons-logging-1.0.4.jar           
        log4j-1.2.8.jar               
        ognl-2.6.5.jar                
        aopalliance-1.0.jar               
        s2-framework-2.x.x.jar        
        
        commons-beanutils-1.7.0.jar         
        commons-digester-1.6.jar          
        commons-fileupload-1.0.jar        
        commons-validator-1.0.4.jar         
        oro-2.0.8.jar               
        struts-1.2.8.jar                    
        
        s2-struts-x.x.x.jar           

WEB-INF/src
        log4j.properties              
        application.properties        
        app.dicon                     
        s2struts.dicon                


Files added to use the expanded S2 functionality
WEB-INF/lib
        jta.jar                       
        junit-3.8.1.jar               
        poi-2.5-final-20040804.jar    
        s2-extension-2.x.x.jar

WEB-INF/src
        j2ee.dicon                    
        aop.dicon                     


Files added to enable Mayaa. Delete if not used.
WEB-INF/lib
        jaxen-1.1-beta-8.jar          
        nekohtml-0.9.5.jar            
        rhino-1.6r2.jar               
        xercesImpl-2.7.1.jar          
        xml-apis-1.3.jar              
        mayaa-x.x.x.jar                


Files added to enable S2Dao. Delete if not used.
WEB-INF/lib
        s2-dao-x.x.x.jar              

WEB-INF/src
        dao.dicon                     


Files added to enable HSQLDB. Delete if not used.
WEB-INF/lib
        hsqldb.jar                    

In order to use Tiger annotation, copy the file

  • lib/s2-struts-tiger-x.x.x.jar

from the s2struts-tiger directory extracted from S2StrutsTigerVx.x.x.zip into WEB-INF/lib and include it in CLASSPATH.

In order to use backport175 annotation, copy the files

  • lib/s2-struts-backport175-x.x.x.jar
  • lib/backport175-1.0.jar

from the s2struts-backport175 directory extracted from S2StrutsBackport175Vx.x.x.zip into WEB-INF/lib and include it in CLASSPATH.

Quickstart

Let's give this a try.

Check that Tomcat and Tomcat Plugin are installed, as Quickstart depends on these files.

We will use S2StrutsBlankVx.x.x.zip as a starting point to using S2Struts. Import the entire s2struts-blank directory contained in S2StrutsBlankVx.x.x.zip as a Java project in Eclipse. When Eclipse prompts to overwrite .classpath, select 'all' and 'yes' to do so. Right click the s2struts-blank project and set the property to tomcat. This completes our preparation.

First, we will construct a demo screen from HTML. Create greetingInput.html and greeting.html directly in s2struts-blank.

greetingInput.html

This is a page to select a period of time.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j">
  <title>Greeting Demo</title>
</head>
<body>
  <form method="GET" action="greeting.html">
    <table>
      <tr>
        <th>time</th>
        <td>
          <select name="time">
            <option value="" selected>Please select</option>
            <option value="a.m.">a.m.</option>
            <option value="p.m.">p.m.</option>
          </select>
        </td>
      </tr>
    </table>
    <input type="submit" value="greeting">
  </form>
</body>
</html>

greeting.html

This page will display a greeting for each period of time.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j">
  <title>Greeting Demo</title>
</head>
<body>
  <table>
    <tr>
      <th>time</th>
      <td>a.m.</td>
    </tr>
    <tr>
      <th>greeting</th>
      <td>Good morning</td>
    </tr>
  </table>
  <a href="greetingInput.html">back</a>
</body>
</html>

Point a browser to greetingInput.html to see a rough copy of the application we will be creating.

Are we starting to get an idea of what we will be creating?

From here, we will actually make this a working project. The steps in the workflow will look like this:

  • Create an interface.
  • Implement the interface, and then create the components.
  • Connect components.

We will be creating Action using POJO, and Mayaa to view. When using POJO as Action, we will need to divide the interface and implementation in S2Struts. Refer to "Using POJO as Action" for additional details.

We will create the GreetingInputInitAction, GreetingAction, and GreetingService interface first. We will also create GreetingDto to be ActionForm(DTO) as an interface to the screen.

GreetingDto

We will use the DTO of POJO as an ActionForm. We will give it items passed from the screen.

package examples.dto;

public class GreetingDto {
    private String time = "";

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }
}

GreetingInputInitAction

This is the Action interface to provide information needed to display greetingInput.html.

package examples.action;

public interface GreetingInputInitAction {
    String initialize();
}

GreetingAction

This is the Action interface that will handle the greeting process.

package examples.action;

public interface GreetingAction {
    String SUCCESS = "success";
    
    String goGreeting();
}

GreetingService

This interface will provide services that do not depend on a presentation layer framework, such as Struts.

package examples.service;

import java.util.List;
import examples.dto.GreetingDto;

public interface GreetingService {
    List getTimeList();

    String getGreeting(GreetingDto dto);
}

We have created the set of interfaces. Next, we will implement the interfaces and create components.

GreetingInputInitActionImpl

setGreetingService is a setter method to injection GreetingService. setTimeList is a getter method to pass data to the screen.

package examples.action.impl;

import java.util.List;
import examples.action.GreetingInputInitAction;
import examples.service.GreetingService;

public class GreetingInputInitActionImpl implements GreetingInputInitAction {
    private GreetingService service;
    private List timeList;

    public String initialize() {
        timeList = service.getTimeList();
        return null;
    }
    
    public void setGreetingService(GreetingService service) {
        this.service = service;
    }

    public List getTimeList() {
        return timeList;
    }
}

GreetingActionImpl

setGreetingService is a setter method to injection GreetingService. setGreetingDto is a setter method to receive ActionForm from the screen. getGreetingDto is a getter method to pass ActionForm to the screen. getGreeting is a getter method to pass data to the screen.

package examples.action.impl;

import examples.action.GreetingAction;
import examples.dto.GreetingDto;
import examples.service.GreetingService;

public class GreetingActionImpl implements GreetingAction {
    private GreetingService service;
    private GreetingDto greetingDto;
    private String greeting;

    public String goGreeting() {
        greeting = service.getGreeting(greetingDto);
        return SUCCESS;
    }

    public void setGreetingService(GreetingService service) {
        this.service = service;
    }

    public GreetingDto getGreetingDto() {
        return greetingDto;
    }

    public void setGreetingDto(GreetingDto greetingDto) {
        this.greetingDto = greetingDto;
    }

    public String getGreeting() {
        return greeting;
    }
}

GreetingServiceImpl

package examples.service.impl;

import java.util.ArrayList;
import java.util.List;
import examples.dto.GreetingDto;
import examples.service.GreetingService;

public class GreetingServiceImpl implements GreetingService {
    private static final String AM = "a.m.";
    private static final String PM = "p.m.";

    public List getTimeList() {
        List result = new ArrayList();
        result.add(AM);
        result.add(PM);
        return result;
    }

    public String getGreeting(GreetingDto dto) {
        if (AM.equals(dto.getTime())) {
            return "Good morning";
        }
        if (PM.equals(dto.getTime())) {
            return "Good evening";
        }
        return "";
    }
}

This completes the implementation and creation of components. Next we will link these components.

greeting.dicon

We will create greeting.dicon directly in examples/dicon to link Action and Service together.

<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
  "http://www.seasar.org/dtd/components21.dtd">
<components>
  <include path="aop.dicon"/>

  <component name="actionInterceptorChain"
      class="org.seasar.framework.aop.interceptors.InterceptorChain">
    <initMethod name="add"><arg>aop.traceInterceptor</arg></initMethod>
  </component>

  <component
    class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister">
    <property name="autoNaming">
      <component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
    </property>
    <initMethod name="addClassPattern">
      <arg>"examples.service.impl"</arg>
      <arg>".*ServiceImpl"</arg>
    </initMethod>
  </component>
  
  <component
    class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister">
    <property name="instanceDef">
      @org.seasar.framework.container.deployer.InstanceDefFactory@REQUEST
    </property>
    <property name="autoNaming">
      <component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
    </property>
    <initMethod name="addClassPattern">
      <arg>"examples.action.impl"</arg>
      <arg>".*ActionImpl"</arg>
    </initMethod>
  </component>
  <component class="org.seasar.framework.container.autoregister.AspectAutoRegister">
    <property name="interceptor">actionInterceptorChain</property>
    <initMethod name="addClassPattern">
      <arg>"examples.action.impl"</arg>
      <arg>".*ActionImpl"</arg>
    </initMethod>
  </component>

</components>

Add include to app.dicon in order to read-in greeting.dicon.

<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
  "http://www.seasar.org/dtd/components21.dtd">
<components>
  <include path="s2struts.dicon"/>
  <include path="examples/dicon/greeting.dicon"/>
</components>

Editing greeting.dicon is not required to add new Actions. This is due to the component auto-registration functionality provided by S2.

We will edit greetingInput.html and greeting.html to link the screen to Action and ActionForm. We will then create a corresponding maya file. Please refer to "JavaServer Templates 'Mayaa'" for additional details.

greetingInput.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j">
  <title>Greeting Demo</title>
</head>
<body>
<div id="appBody">
  <form method="GET" action="greeting.html" id="appForm">
    <table>
      <tr>
        <th>time</th>
        <td>
          <select name="time" id="time">
            <option value="" selected>Please select</option>
            <option value="a.m.">a.m.</option>
            <option value="p.m.">p.m.</option>
          </select>
        </td>
      </tr>
    </table>
    <input type="submit" value="greeting" id="goGreeting">
  </form>
</div>
</body>
</html>

greetingInput.mayaa

We will call GreetingInputInitAction#initialize() using the init tag provided by S2Struts. We obtain timeList by running initialize(). timeList is required to display the screen.

<?xml version="1.0" encoding="UTF-8"?>
<m:mayaa xmlns:m="http://mayaa.seasar.org"
        xmlns:html="http://struts.apache.org/tags-html"
        xmlns:bean="http://struts.apache.org/tags-bean"
        xmlns:s2struts="http://www.seasar.org/tags-s2struts"
        m:noCache="true">

    <m:with id="appBody" replace="false">
        <s2struts:init action="#{greetingInputInitAction.initialize}"/>
        <m:doBody />
    </m:with>

    <html:form m:id="appForm" action="/greeting" method="POST" />
    <html:select m:id="time" property="time">
        <html:option value="">Please select</html:option>
        <html:options name="timeList" />
    </html:select>
    <html:submit m:id="goGreeting" >greeting</html:submit>

</m:mayaa>

greeting.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j">
  <title>Greeting Demo</title>
</head>
<body>
<div id="appBody">
  <table>
    <tr>
      <th>time</th>
      <td><span id="time">a.m.</span></td>
    </tr>
    <tr>
      <th>greeting</th>
      <td><span id="greeting">Good morning</span></td>
    </tr>
  </table>
  <a href="greetingInput.html" id="goBack">back</a>
</div>
</body>
</html>

greeting.mayaa

<?xml version="1.0" encoding="UTF-8"?>
<m:mayaa xmlns:m="http://mayaa.seasar.org"
        xmlns:html="http://struts.apache.org/tags-html"
        xmlns:bean="http://struts.apache.org/tags-bean"
        xmlns:s2struts="http://www.seasar.org/tags-s2struts"
        m:noCache="true">

    <m:ignore id="appBody" />

    <bean:write m:id="time" name="greetingDto" property="time" />
    <bean:write m:id="greeting" name="greeting" />
    <html:link m:id="goBack" page="/greetingInput.html">back</html:link>

</m:mayaa>

This concludes our work.

Restart Tomcat, and point a browser to http://localhost:8080/s2struts-blank/greetingInput.html to confirm proper operation.

It will be working without editing struts-config.xml, as S2struts is following rules and generating struts-config information. Creating GreetingDto and GreetingAction is equivalent to the below struts-config entries.

...
<form-beans>
    ...
    <form-bean
        name="greetingDto"
        type="examples.dto.GreetingDto" />
    ...
</form-beans>
...
<action-mappings>
    ...
    <action
        path="/greeting"
        type="examples.action.GreetingAction"
        name="greetingDto"
        scope="request"
        validate="true">
        <forward name="success" path="/greeting.html" />
    </action>
    ...
</action-mappings>
...

Additional configuration was obviated by the adherence to common convention, but there are cases where this is not possible. In these cases, a direct configuration can be done through annotations. Refer to "Unconfigured S2Struts" for additional details on rules and annotations.

How was the world of S2Struts? Don't POJO Actions look like they can be easily tested? The fear of a uncontrollably expanding struts-config.xml is solved. Refer to the following references if you want to learn more about S2Struts.

S2Struts Reference

Basic Usage

First, we must register S2ContainerServlet with web.xml in order to initialize S2Container. Also, configure S2ContainerFilter and S2StrutsFilter as shown below.

Next, register org.seasar.struts.servlet.S2ActionServlet to replace org.apache.struts.action.ActionServlet. Alternately, register org.seasar.struts.servlet.S2RedeployableActionServlet to replace org.apache.struts.actions.RedeployableActionServlet.

web.xml

<web-app>
  <display-name>Struts Application</display-name>

  <filter>
    <filter-name>s2filter</filter-name>
    <filter-class>
      org.seasar.framework.container.filter.S2ContainerFilter
    </filter-class>
  </filter>

  <filter>
    <filter-name>s2strutsfilter</filter-name>
    <filter-class>org.seasar.struts.filter.S2StrutsFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>s2filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>s2strutsfilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <servlet>
    <servlet-name>s2container</servlet-name>
    <servlet-class>
      org.seasar.framework.container.servlet.S2ContainerServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.seasar.struts.servlet.S2ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>s2container</servlet-name>
    <url-pattern>/s2container</url-pattern>
  </servlet-mapping>

  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

  <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

</web-app>

We must register a RequestProcessor for S2 in struts-config.xml to link S2 and Struts. We have S2RequestProcessor and S2TilesRequestProcessor prepared for us. These each correspond to RequestProcessor and TilesRequestProcessor.

struts-config.xml

<struts-config>
  ...
  <controller processorClass="org.seasar.struts.processor.S2RequestProcessor"/>
  ...
</struts-config>

We must register the Action class we wish to link in component definitions. We can define Action classes individually, but this forces changes in the component definitions file for every additional Action class. We recommend the use of Component Auto-registration to avoid this issue.

Multiply.dicon

<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
  "http://www.seasar.org/dtd/components21.dtd">
<components>
  <component name="traceInterceptor"
      class="org.seasar.framework.aop.interceptors.TraceInterceptor"/>

  <component
      class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister">
    <property name="autoNaming">
      <component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
    </property>
    <initMethod name="addClassPattern">
      <arg>"org.seasar.struts.examples.multiply"</arg>
      <arg>".*ServiceImpl"</arg>
    </initMethod>
  </component>
  
  <component
      class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister">
    <property name="instanceDef">
      @org.seasar.framework.container.deployer.InstanceDefFactory@REQUEST
    </property>
    <property name="autoNaming">
      <component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
    </property>
    <initMethod name="addClassPattern">
      <arg>"org.seasar.struts.examples.multiply"</arg>
      <arg>".*Action"</arg>
    </initMethod>
  </component>
  <component class="org.seasar.framework.container.autoregister.AspectAutoRegister">
    <property name="interceptor">traceInterceptor</property>
    <initMethod name="addClassPattern">
      <arg>"org.seasar.struts.examples.multiply"</arg>
      <arg>".*Action"</arg>
    </initMethod>
  </component>
</components>

This component definition file must be registered with the application's overall definition file, app.dicon.

app.dicon

<components>
  ...
  <include path="org/seasar/struts/examples/dicon/Multiply.dicon"/>
  ...
</components>

All action classes generated by RequestProcessor will link with S2.

Setter Injection will be automatically applied if the setter method for an interface is defined. In addition, constructor injection can be automatically applied if a constructor is defined with only interfaces as arguments.

We will define a constructor or Setter method in the Action Class to receive a service component. You may notice the clean code as execute() method delegates processing out to services.

MultiplyAction

package org.seasar.struts.examples.multiply;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.seasar.struts.examples.form.CalculationForm;

public class MultiplyAction extends Action {

    private MultiplyService multiplyService_;

    public MultiplyAction(MultiplyService multiplyService) {
        multiplyService_ = multiplyService;
    }

    public ActionForward execute(
            ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) {

        CalculationForm calForm = (CalculationForm) form;
        int result = multiplyService_.multiply(calForm.getArg1(), calForm.getArg2());
        calForm.setResult(result);
        return (mapping.findForward("success"));
    }
}

Using Action as POJO

We can use POJO that does not inherit org.apache.struts.action.Action as an Action.

Create the interface and implementation class, then define the class in the component definition file. The forward name should be returned by the method as a string. Finally, set the type attribute of the action tag in struts-config.

EchoAction

public interface EchoAction {
	String echo();
}

EchoActionImpl

public class EchoActionImpl implements EchoAction {
    private StringForm strForm;
    
    public EchoActionImpl() {
    }

    public String echo() {
        strForm.setResult(strForm.getInput());
        
        return FowardNameConstants.SUCCESS;
    }

    public StringForm getStrForm() {
        return strForm;
    }
    public void setStrForm(StringForm strForm) {
        this.strForm = strForm;
    }
}

In the case that there is a setter method in the POJO action class, HttpServletRequest or HttpSession values will automatically be bound.
The order of precedence will be
(1)HttpServletRequest#gerParameter(property name)
(2)HttpServletRequest#getAttribute(property name)
(3)HttpSession#getAttribute(property name)

A parameter may contain square brackets '[ ]'. In the case of such a parameter like foo[0]=fooVal0, foo[1]=fooVal1 being passed, the setter method with an int as the first argument and a value as a second argument will be targeted for automatic binding, as shown below.

setFoo(int index, Object value);

In case of a getter method, HttpServletRequest or Httpsession will be automatically bound to a value.
(1) HttpservletRequest#setAttribute(property name, Property value) will be run by default.
(2) Enter

public final static String PropertyName_EXPORT = org.seasar.struts.Constants.SESSION;
in the action class using constant value annotation to use Httpsession#setAttribute(property name, property value).

Entry by annotation is also possible. To do this, enter annotations for each getter method as shown below.

@ExportToSession()
public String getFoo() {
    return foo;
}
Backport175 annotation can also be used, as shown below.
/**
 * @org.seasar.struts.annotation.backport175.ExportToSession()
 */
public String getFoo() {
    return foo;
}

Echo.dicon

<components>
	<component class="org.seasar.struts.examples.echo.EchoActionImpl" instance="request"/>
</components>

struts-config.xml

<struts-config>
  ...
  <action-mappings>
    ...
    <action
      path="/echo"
      type="org.seasar.struts.examples.echo.EchoAction"
      name="strForm"
      scope="request"
      validate="false"
      input="/pages/echoInput.jsp">
      <forward name="success" path="/pages/strResult.jsp" />
    </action>
    ...
  <action-mappings>
  ...
</struts-config>

By registering S2ContainerFilter in web.xml, the property of the implementation class is automatically bound to Action and Request or Session. The instance property of the component definition file determines if it binds to Request or Session. The scope property defined in struts-config.xml determines the binding of ActionForm.

In case there are multiple interface methods, use the same practice as when using org.apache.actions.DispatchAction. Add the parameter attribute to the action tag in struts-config.xml, and select a method for the JSP submit button using the two name and value attributes.

ChangeCaseAction

public interface ChangeCaseAction {
    String toLowerCase();

    String toUpperCase();
}

struts-config.xml

<struts-config>
  ...
  <action-mappings>
    ...
    <action
      path="/changeCase"
      type="org.seasar.struts.examples.changecase.ChangeCaseAction"
      name="strForm"
      scope="request"
      validate="true"
      parameter="command"
      input="/pages/changeCaseInput.jsp">
      <forward name="success" path="/pages/strResult.jsp" />
    </action>
    ...
  <action-mappings>
  ...
</struts-config>

changeCaseInput.jsp

...
<html:submit property="command"><bean:message key="toLowerCase"/></html:submit>
<p>
<html:submit property="command"><bean:message key="toUpperCase"/></html:submit>
...

When converted into HTML, it will look like the following.

<input type="submit" name="command" value="toLowerCase">
<p>
<input type="submit" name="command" value="toUpperCase">

Using the ProxyAction class

The ProxyAction class can be used to call an action entered in the component definition file to delegate the process. This removes the need to synchronize struts-config.xml and the component definition file with identical class names. Instead, action class path names in struts-config must have a corresponding name attribute of component defined in the component definition file. Refer to "Path attribute and Action class mapping" for additional details.

ProxyAction class can interact with S2 without registering a RequestProcessor for S2 in struts-config. All other Action classes must have a RequestProcessor for S2 registered in struts-config.xml. This indicates select Action classes as being valid for linking to S2.

struts-config.xml

<struts-config>
  ...
  <action-mappings>
    ...
    <action
      path="/subtract"
      type="org.seasar.struts.action.ProxyAction"
      name="calcForm"
      scope="request"
      validate="false"
      input="/pages/subtractInput.jsp">
      <forward name="success" path="/pages/result.jsp" />
    </action>
    ...
  <action-mappings>
  ...
</struts-config>

Subtract.dicon

<components>
  <component name="/subtract" class="org.seasar.struts.examples.SubtractAction"/>
  <component class="org.seasar.struts.examples.SubtractServiceImpl"/>
</components>

Selecting an Action class without a type attribute under action in struts-config

An Action class may be called without a type attribute entry in a manner identical to the use of the ProxyAction class. This is done by defining an action class path name in struts-config to a corresponding name attribute of component defined in the component definition file. There may not be type, forward, or include attributes when using this method. This removes the need to synchronize class names between struts-config and the component definition file.

struts-config.xml

<struts-config>
  ...
  <action-mappings>
    ...
    <action
      path="/divide"
      name="calcForm"
      scope="request"
      validate="false"
      input="/pages/divideInput.jsp">
      <forward name="success" path="/pages/result.jsp" />
    </action>
    ...
  <action-mappings>
  ...
</struts-config>

Divide.dicon

<components>
  <component name="/divide" class="org.seasar.struts.examples.DivideAction"/>
  <component class="org.seasar.struts.examples.DivideServiceImpl"/>
</components>

path attribute and Action class mapping

Details on the use of the path attribute and action class mapping as used in "Using the ProxyAction class" and "Selecting an Action class without a type attribute under action in struts-config" will be discussed.

We assume there exists the web.xml, struts-config and component definition files as follows.

web.xml

<web-app>
  ...
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>config/foo</param-name>
      <param-value>/WEB-INF/struts-config-foo.xml</param-value>
    </init-param>
    ...
  </servlet>
  ...
</web-app>

struts-config.xml

<struts-config>
  ...
  <action-mappings>
    ...
    <action path="/bar"
      ...
    </action>
    ...
  <action-mappings>
  ...
</struts-config>

struts-config-foo.xml

<struts-config>
  ...
  <action-mappings>
    ...
    <action path="/baz"
      ...
    </action>
    ...
  <action-mappings>
  ...
</struts-config>

component definition file

<components>
  <component name="/bar" class="BarAction"/>
  <component name="/foo/baz" class="BazAction"/>
</components>

If it is a default module, or a module that operates with struts-config.xml, mapping is facilitated by the path attribute of the action tag within struts-config.xml in addition to the name attribute of the component tag in the component definition file. This follows the (2) sub module pattern.

There are two mapping methods for sub modules. In this case, modules that operate with struts-config-foo.xml.

    (1)module(prefix)name (/foo) +path attribute (/baz) = name attribute (/foo/baz)
    (2)path attribute (/baz) =name attribute (/baz)
the priority given to acquiring the component is in the order of (1) then (2). If a component with the name /foo/baz in not found, it will acquire the component named /baz.

The default mapping method shown above can be changed by registering a class implementing org.seasar.struts.ComponentNameCreator from app.dicon.

Hints for usage

Advantage/Disadvantage comparison.


Advantage Disadvantage
POJO Action(recommended) Improved testability
Easy switch between mock Action classes
Easy transition to S2JSF
Files with interface definitions may increase. However, the Seasar foundation believes an explicit interface when being accessed externally is better for maintainability.
Multiply example Can utilize the existing action-mapping of Action and struts-config without editing.
-

Subtract(ProxyAction) example No need to synchronize Action class name between struts-config and component definition file, as components are searched for using ActionMapping information. Default search is by path name. Component name and ActionMapping Information must be synchronized.
Divide example Same as above. Amount of data entry is reduced by not needing to enter the type attribute (Action class name) in struts-config. Same as above. However, it is not a standard of Struts. There is a possibility of interoperability errors with tools that use struts-config.

We recommend the use of POJOAction if there is no strong reason to use the other methods.

Acquiring RequestProcessor from a component

Acquiring RequestProcessor from a component yields the same results as applying a common aspect to the Action class. This also allows for identical treatment to other components in addition to applying an aspect.

First, S2ActionServlet must be registered with web.xml. The org.seasar.struts.S2ActionServlet or org.seasar.struts.S2RedeployableActionServlet should be entered into web.xml instead of org.apache.struts.action.ActionServlet. (S2ActionServlet inherits ActionServlet and S2RedeployableActionServlet inherits RedeployableActionServlet.)

web.xml

<web-app>
  ...
  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.seasar.struts.action.S2ActionServlet</servlet-class>
    ...
  </servlet>
  ...
</web-app>

In this example, the MeasureTimeInterceptor aspect is applied to S2RequestProcessor to measure the processing time of each request and output to stdout.

RequestProcessor.dicon

<components>
  <include path="s2struts.dicon"/>
  <component class="org.seasar.struts.S2RequestProcessor">
    <aspect pointcut="process">
      <component class="org.seasar.struts.examples.MeasureTimeInterceptor">
    </aspect>
  </component>
</components>

Manage error message display from the selected component

Error message display can be controlled from a selected component by using the org.seasar.struts.action.MessageManager class.

MessageActionImpl.java

public class MessageActionImpl implements MessageAction {

    public String execute() {
        MessageManager.addGlobalError("examplemessage");
        MessageManager.addGlobalError("examplemessage", "foo");
        MessageManager.addGlobalError("examplemessage", "bar", "baz", "qux");
        MessageManager.addError("property", "examplemessage");
        MessageManager.addError("property", "examplemessage", "foo");
        MessageManager.addError("property", "examplemessage", "bar", "baz", "qux");
        MessageManager.saveErrors();

        return FowardNameConstants.SUCCESS;
    }

}

This is nearly identical in function to the below code implemented in the Struts Action class.

  ActionMessages errors = new ActionMessages();
  errors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("examplemessage"));
  errors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("examplemessage", "foo"));
  errors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("examplemessage", "bar", "baz", "qux"));
  errors.add("property",new ActionMessage("examplemessage"));
  errors.add("property",new ActionMessage("examplemessage", "foo"));
  errors.add("property",new ActionMessage("examplemessage", "bar", "baz", "qux"));
  if(!errors.isEmpty()) {
      saveErrors(request,errors);
  }

It is "nearly" identical, as MessageManager has functionality to delete entries such as {4} within the example message in the Resource key used above.

MessageManager also has addGlobalMessage(), addMessage() and saveMessage() methods to manage messages. These methods will use the same arguments as error message handling.

Unconfigured S2Struts Reference

struts-config is automatically completed when S2Struts is used. (Unconfigured S2Struts). struts-config can be completed using content selected using annotation. This can be used to abbreviate the configuration using struts-config.

Unconfigured S2Struts

AutoStrutsConfigRegisterPlugIn must be registered with struts-config to use Unconfigured S2Struts functionality. PlugInには読み込み順があるのでValidatorPlugInより後に登録してください。

struts-config.xml

<struts-config>
  ...
  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    ...
  </plug-in>
    
  <plug-in className="org.seasar.struts.plugin.AutoStrutsConfigRegisterPlugIn">
    <set-property property="enableJar" value="false"/>
    <set-property property="jarFilePattern" value="^My.*\.jar$"/>
    <set-property property="actionClassPattern" value="foo.bar.action.*Action"/>
    <set-property property="formClassPattern" value="foo.bar.form.*Form"/>
    <set-property property="docRoot" value="/WEB-INF/jsp"/>
    <set-property property="viewExtension" value="jsp,html,view"/>
  </plug-in>
  ...
</struts-config>

A value can be set for plug in properties. Each property is described below. If the property value is not specified, the indicated default value will be used.

Property Description Default Value
enableJar Determines if jar files located in classpath will be searched for classes to be included in Unconfigured S2Struts. false
jarFilePattern enableJarをtrueとしたときに検索するjarファイルのファイル名パターンを指定します。 なし
(どのjarファイルも検索対象になりません)
referenceClass 指定されたクラスが存在するディレクトリまたはjarファイルを基点として自動登録するクラスを検索します。 なし
actionClassPattern Selects a class name pattern to determine the value of the action tag in Unconfigured S2Struts. .*Action$
formClassPattern Selects a class name pattern to determine the value of the form-bean tag in Unconfigured S2Struts. (.*Form$)|(.*Dto$)
docRoot Selects the top directory of the View template file. none
viewExtension Selects the file extension of the View template file. jsp,html

Values abbreviated in Unconfigured S2Struts will become one of the following attributes. form-bean, action tag, or the forward tag within the action tag. The attributes returned if default conventions are followed are listed below.

Attribute values of form-bean tag

Configuration is completed based on those classes with a class name of "Form" or "Dto".

Attribute Value defined in default conventions
type class name
name Uses the component name found by searching components registered in S2 using the class name.
restricted false

Attribute values of action tag

Configuration is completed based on the class with a classname ending with "Action".

Attribute Value defined in default conventions
type class name
path Searches components registered in S2 using the class name.
Uses the component if the component name starts with "/".
Prefixes "/", then if the name ends with "ActionImpl", "Impl", or "Action" deletes the term.
If a component name is not found, the class name's first letter is made lower case, and the above configuration is applied.
name Uses the path attribute after deleting the leading "/"
scope request
validate true
input not configured (null)
parameter not configured (null)
attribute not configured (null)
forward not configured (null)
include not configured (null)
prefix not configured (null)
suffix not configured (null)
unknown not configured (null)
roles not configured (null)
cancellable false

Attribute values of forward tag located within action tag

Configuration is completed based on the class with a classname ending with "Action".
Attribute Value defined in default conventions
name success (cannot be altered)
path configures path as described below.
1. changes the "." in the package name to a "/" and link that value to the class name.
2. If the name ends with "ActionImpl", "Impl", or "Action", deletes this term. Changes the first letter of the class name to lower case when linked.
3. Prefixes the selected value in docRoot contained in AutoStrutsConfigRegisterPlugIn.
4. Searches for files with the extension ".html" and ".jsp", configuring those files found in path.
5. If file is not found, step 4 is repeated after deleting the string to the second "/" referring to the package.
6. If all steps fail, no configuration will be made. A log will be output.

例えば、
クラス:aaa.bbb.ccc.HogeAction
AutoStrutsConfigRegisterPlugInのdocRoot:/jsp
の場合、pathに設定するファイルの検索順は
1)/jsp/aaa/bbb/ccc/hoge.jsp
2)/jsp/bbb/ccc/hoge.jsp
3)/jsp/ccc/hoge.jsp
4)/jsp/hoge.jsp
となります。
redirect not configured (false)

Configuration of struts-config using annotation

It is possible to use Tiger or backport175 annotations, but not simultaneously. The jar files listed below are required to enable each.

AnnotationRequired jar file (x.x.x will denote version)
Tigers2-struts-tiger-x.x.x.jar
backport175s2-struts-backport175-x.x.x.jar

struts-config can be configured using annotation in action as shown below.

package org.seasar.struts.examples.employee.action;

import org.seasar.struts.annotation.tiger.StrutsAction;
import org.seasar.struts.annotation.tiger.StrutsActionForward;

@StrutsAction(name="employeeForm", validate=false)
public interface EmployeeEditAction {

	@StrutsActionForward(path="/pages/employee/employeeEdit.jsp")
	public String SUCCESS = "success";

	public String execute();

}
backport175 annotation will look like the following.
package org.seasar.struts.examples.employee.action;

/**
 * @org.seasar.struts.annotation.backport175.StrutsAction(
 *   name="employeeForm", validate=false)
 */
public interface EmployeeEditAction {

	/**
	 * @org.seasar.struts.annotation.backport175.StrutsActionForward(
	 *         path="/pages/employee/employeeEdit.jsp")
	 */
	public String SUCCESS = "success";

	public String execute();

}
定数アノテーションの記述では以下のようになります。
package org.seasar.struts.examples.employee.action;

public interface EmployeeEditAction {

	public static final String ACTION = "name=employeeForm, validate=false";

	public static final String SUCCESS_FORWARD = "path=/pages/employee/employeeEdit.jsp";

	public String SUCCESS = "success";

	public String execute();

}
These are functionally identical to the following.
...
<action-mappings>
    ...
    <action
        path="/employeeEdit"
        type="org.seasar.struts.examples.employee.action.EmployeeEditAction"
        name="employeeForm"
        scope="request"
        validate="true">
        <forward name="success" path="/pages/employee/employeeEdit.jsp" />
    </action>
    ...

Attributes selectable in StrutsAction

AttributeRequired
path
X
name
X
scope
X
validate
X
input
X
parameter
X
attribute
X
forward
X
include
X
prefix
X
suffix
X
unknown
X
roles
X
cancellable
X
These form a pair with the attribute of the action tag in struts-config. The default value of these attributes will be defined by Unconfigured S2Struts.

Attributes selectable by StrutsActionForward

AttributeRequiredDefault Value
path
O
-
redirect
X
false
This forms a pair with the action tag of struts-config. Selects a name attribute using a constant value.

struts-config can be configured using annotation in the Form(DTO) as shown below.

package org.seasar.struts.examples.employee.dto;

import org.seasar.struts.annotation.tiger.StrutsActionForm;

@StrutsActionForm(name="employeeForm")
public class EmployeeDto extends Employee {
	...
}
Annotation using backport175 is shown below.
package org.seasar.struts.examples.employee.dto;

/**
 * @org.seasar.struts.annotation.backport175.StrutsActionForm(name="employeeForm")
 */
public class EmployeeDto extends Employee {
	...
}
定数アノテーションの記述では以下のようになります。
package org.seasar.struts.examples.employee.dto;

public class EmployeeDto extends Employee {

	public static final String FORM = "name=employeeForm";
	...
}
This is equivalent to what is shown below.
...
<form-beans>
    ...
    <form-bean
        name="employeeForm"
        type="org.seasar.struts.examples.employee.dto.EmployeeDto" />
    ...

Attributes selectable by StrutsActionForm

AttributeRequired
name
X
restricted
X
These form a pair with the attribute of the form-bean tag. The default value of these attributes will be defined by Unconfigured S2Struts.

Configuring validation using annotation

We can use annotations in the ActionForm setter method to configure validation as shown below.

public class ValidateDto implements Serializable {

    private String value;

    @ValidateOrder(1)
    @Required
    @Minlength(10)
    @Maxlength(15)
    @Mask(pattern="com$",messageKey="mustendcom")
    @EmailType
    @Args(keys="mixValue",resource=false)
    public void setvalue(String value) {
        this.value = value;
    }
backport175 annotation use looks like the following.
public class ValidateDto implements Serializable {

    private String value;

    /**
     * @org.seasar.struts.validator.annotation.backport175.ValidateOrder(1)
     * @org.seasar.struts.validator.annotation.backport175.Required
     * @org.seasar.struts.validator.annotation.backport175.Minlength(value=10)
     * @org.seasar.struts.validator.annotation.backport175.Maxlength(value=15)
     * @org.seasar.struts.validator.annotation.backport175.Mask(
     *    pattern="com$",messageKey="mustendcom")
     * @org.seasar.struts.validator.annotation.backport175.Email
     * @org.seasar.struts.validator.annotation.backport175.Args(
     *    keys="mixValue",resource=false)
     */
    public void setvalue(String value) {
        this.value = value;
    }
}
定数アノテーションの記述では以下のようになります。
public class ValidateDto implements Serializable {

    private String value;

    public static final int value_VALIDATOR_ORDER = 1;
    public static final String value_VALIDATOR = "required";
    public static final String value_VALIDATOR_0 = "minlength, value=10";
    public static final String value_VALIDATOR_1 = "maxlength, value=15";
    public static final String value_VALIDATOR_2 = "mask, pattern=com$, messageKey=mustendcom";
    public static final String value_VALIDATOR_3 = "email";
    public static final String value_VALIDATOR_ARGS = "keys=mixValue, resource=false";

    public void setValue(String value) {
        this.value = value;
    }
}

S2Struts has annotations prepared for validation configuration. All annotation besides ValidateOrder, Args, Message is used in basic validation.

ValidateOrder

検証する順番を制御します。指定した順番でエラーメッセージを表示します。

AttributeRequiredDefault valueDescription
value
X
999
検証する順番を指定します。

Args

The substitute data used in the message is selected.

AttributeRequiredDefault valueDescription
keys
X
-
This selects a substitute value used in a message.
Multiple values may be delimited by commas ",".
定数アノテーションで","で区切る方法については「定数アノテーションの補足」を参照してください。
bundle
×
-
デフォルト以外のメッセージリソースを使用する場合、 使用するメッセージリソースのキーを指定します。
resource
X
true
Selects if the value defined in keys will be used as a resource key.
When true, it will use this as a resource key and corresponding values as a substitute parameter.
When false, it will simply use the value defined in keys as a substitute parameter.
value
×
-
Argアノテーションで個別に置換パラメータを指定する場合に使用します。
個別に置換パラメータを指定する場合は、keys、bundle、resourceを指定しないで下さい。

Arg

メッセージで使用される置換パラメータを個別に指定します。

属性必須デフォルト値説明
key
-
メッセージで使用される置換パラメータを指定します。
name
×
-
置換パラメータを使用するバリデータの名前を指定します。
bundle
×
-
デフォルト以外のメッセージリソースを使用する場合、 使用するメッセージリソースのキーを指定します。
resource
×
true
keyで指定した値をリソースキーとして利用するかを指定します。
trueの場合はリソースキーとして利用し該当する値をメッセージとします。
falseの場合はkeyで指定した値をそのままメッセージとします。
position
×
-
置換パラメータの位置を指定します。

定数アノテーションでは、以下のように プロパティー名_VALIDATOR_ARG で指定します。 複数指定する場合は、定数名の最後にゼロからのINDEXをつけます。

    public static final String value_VALIDATOR_0 = "required";
    public static final String value_VALIDATOR_1 = "integer";
    public static final String value_VALIDATOR_ARG_0 = "form.value";
    public static final String value_VALIDATOR_ARG_1 = "form.value.def";
    public static final String value_VALIDATOR_ARG_2 = "form.value.req, name = required, position = 1";

    public void setValue(String value) {
        this.value = value;
    }

Messages

複数のMessageアノテーションを指定したい場合に使用します。

属性必須デフォルト値説明
value
-
複数のMessageアノテーションを指定します。

Message

デフォルトメッセージの代わりに個別のメッセージを表示したい場合に指定します。

属性必須デフォルト値説明
key
-
メッセージのキー又はメッセージを指定します。
name
-
メッセージを指定するバリデータの名前を指定します。
bundle
×
-
デフォルト以外のメッセージリソースを使用する場合、 使用するメッセージリソースのキーを指定します。
resource
×
true
keyで指定した値をリソースキーとして利用するかを指定します。
trueの場合はリソースキーとして利用し該当する値をメッセージとします。
falseの場合はkeyで指定した値をそのままメッセージとします。

Required

Checks if there are non-white space characters in the value. No arguments.

Mask

Checks if the value corresponds to the regular expression defined in pattern.

AttributeRequiredDefault valueDescription
pattern
O
-
Selects a regular expression
messageKey
X
-
Selects a key to acquire messages
resource
X
true
Selects if value defined in keys will be used as resource key or not.
When true, it will use this as a resource key and corresponding values as a substitute parameter.
When false, it will simply use the value defined in keys as a substitute parameter.

IntRange, LongRange, FloatRange, DoubleRange

Checks if the value is within min and max.

AttributeRequiredDefault valueDescription
min
O
-
Defines minimum value
max
O
-
Defines maximum value

Maxlength

Checks if the value is shorter than value characters long.

AttributeRequiredDefault valueDescription
value
O
-
Defines minimum length of the value

Minlength

Checks if the value is longer than value characters long.

AttributeRequiredDefault valueDescription
value
O
-
Defines minimum length of the value

Maxbytelength

Checks if the byte count of the value is less than value bytes.

AttributeRequiredDefault valueDescription
value
O
-
Defines maximum size of the value
charset
X
-
Selects a character set when verifying by byte count.
If not selected, the default character set of the platform will be used.

Minbytelength

Checks if the byte count of the value is larger than value bytes.

AttributeRequiredDefault valueDescription
value
O
-
Defines minimum size of the value
charset
X
-
Selects a character set when verifying by byte count.
If not selected, the default character set of the platform will be used.

ByteType, ShortType, IntegerType, LongType, FloatType, DoubleType

Checks if the value can be converted to a corresponding type. There are no associated attributes.

DateType

Checks if value represents a valid date.

AttributeRequiredDefault valueDescription
pattern
X
Pattern selected when defining the dateConfigRegister component of s2struts.dicon
Defines a date pattern

CreditCardType

Checks if the value is a valid credit card number. There are no associated attributes.

EmailType

Checks if the value is a valid E-mail address. There are no associated attributes.

UrlType

Checks if the value is a valid URL.

AttributeRequiredDefault valueDescription
allowallschemes
X
false
Selects if scheme is allowed or not.
If true, all types of scheme will be allowed.
allow2slashes
X
false
Selects if double slashes (//) will be allowed.
If true, // will be valid.
nofragments
X
false
Selects if URL fragmentation is allowed.
If false, fragmentation will be valid.
schemes
X
http,https,ftp
Separate allowed schemes by commas.

NoValidate

Turns off automatic validation. There are no associated attributes.

定数アノテーションの補足

定数アノテーションでは、属性の区切り文字として「,」(カンマ)を利用しています。 値に「,」を指定する場合は以下のように値を「'」(シングルコーテーション)または「"」(ダブルコーテーション)で囲んでください。

 public static final String value_VALIDATOR = "mask, pattern='(^[0-9]{1,2}$)', messageKey=comma";

 public static final String value_VALIDATOR = "mask, pattern=\"(^[0-9]{1,2}$)\", messageKey=comma";

S2Struts tag library reference

S2Struts has both ButtonTag and SubmitTag prepared. Both are expanded struts tags.

button tag

org.seasar.struts.taglib.html.ButtonTag(tagname : button)

http://struts.apache.org//struts-doc-1.2.8/userGuide/struts-html.html#button
Additional attributes are shown below to supplement the above information.

AttributeRequiredrtexprvalueDescription
type
X
false
The attribute will change the button type
"button" : normal button
"submit" : submit button
"reset" : reset button
submit is the standard value in HTML4.01, but is button in IE6.0 or Netscape.
indexId
X
false
Selects the variable name defined in the id attribute of the logic:iterate tag.
The value attribute of button is set to this variable.
(If the variable is an Integer of 32, the converted HTML will look like <button ... value="32" ...>)

submit tag

org.seasar.struts.taglib.html.SubmitTag(tagname : submit)

http://struts.apache.org//struts-doc-1.2.8/userGuide/struts-html.html#submit
Additional attributes are shown below to supplement the above information.

AttributeRequiredrtexprvalueDescription
action
X
-
The component and method run from submit can be selected using action="#{component.method}".
the component must be registered in S2Container with the name selected in this attribute.
indexId
X
false
Selects the variable name defined in the id attribute of the logic:iterate tag.
This will be converted in the form of propertyName[variable].
(If the variable is an Integer of 32, the converted HTML will look like <... foo[32]="bar"...>)
cancel
×
false
trueを指定した場合、フォームに関連付けされたActionFormのvalidateを無視し、 アクションを呼び出します。

cancelタグ

org.seasar.struts.taglib.html.CancelTag(タグ名:cancel)

http://struts.apache.org//struts-doc-1.2.8/userGuide/struts-html.html#cancel
を拡張し、Requestパラメーターを利用しないでCancel機能を実現したタグです。 追加した属性はありません。

image tag

org.seasar.struts.taglib.html.ImageTag(tagname : image)

http://struts.apache.org//struts-doc-1.2.8/userGuide/struts-html.html#image
Additional attributes are shown below to supplement the above information.

AttributeRequiredrtexprvalueDescription
action
X
-
The component and method run from submit can be selected using action="#{component.method}".
the component must be registered in S2Container with the name selected in this attribute.
cancel
X
false
trueを指定した場合、フォームに関連付けされたActionFormのvalidateを無視し、 アクションを呼び出します。

checkboxタグ

org.seasar.struts.taglib.html.CheckboxTag(タグ名:checkbox)

http://struts.apache.org//struts-doc-1.2.8/userGuide/struts-html.html#checkbox
を拡張し、チェックがない場合でもフォームに関連付けされたActionFormのプロパティにfalseを設定します。 追加した属性はありません。

page tag

org.seasar.struts.taglib.html.PageTag(tagname : page)

Inserting this tag in JSP enables the input attribute of struts-config to be Unconfigured and display a white screen at an error. This must be placed within the form tag. If there are multiple forms, each needs its own entry. There are no associated attributes.

init tag

org.seasar.struts.taglib.InitializeTag(tagname : init)

This tag enables the initialization of a screen. The process runs when MethodBinding noted in the action attribute or JSP is displayed.

AttributeRequiredrtexprvalueDescription
action
X
-
The component and method run when JSP is displayed can be selected using action="#{component.method}".
the component must be registered in S2Container with the name selected in this attribute.