title: How to access properties in the POJO using Struts 2 ModelDriven interface when you are using JSP?
body: <p>I have an action class that implements <code>ModelDriven</code> interface. This <code>ModelDriven</code> is a regular POJO, the problem is that one of its properties is another object.</p>
  <p>Imagine that my ModelDriven<code>is a object called</code>Person<code>and my person has an attribute called</code>Address<code>that is another object.</code>Address<code>has regular properties such as</code>String<code>, </code>Long` and etc.</p>
  <p>In the JSP when I submit the form, all the regular properties used such as <code>String</code>, <code>int</code>, <code>long</code> in <code>Person</code> are mapped correctly, but all the data that should be mapped to address are not.</p>
  <pre><code>&lt;s:textfield name=&quot;name&quot; id=&quot;name&quot; size=&quot;25&quot; maxlength=&quot;15&quot; /&gt;
  &lt;s:textfield name=&quot;address.zipcode&quot; id=&quot;zipcode&quot; size=&quot;25&quot; maxlength=&quot;15&quot; /&gt;
  </code></pre>
  <p>That's how I try mapping the properties. The name property I can get it right, but when it comes to map the properties in the person's address this approach does not work.</p>
  <p>What am I doing wrong?</p>
  <p>In time, my <code>Address</code> property is declared in <code>Person</code> instantiating the object, so it's never <code>null</code>.</p>
  <p><strong>EDIT:</strong> As requested, here the action source and the DTOs:</p>
  <p><strong>The Action:</strong></p>
  <pre><code>@Controller
  @Scope(&quot;request&quot;)
  public class AnAction extends BaseAction implements ModelDriven&lt;FakeDTO&gt; {
  
      private static final long serialVersionUID = 8238033889271514835L;
  
      @Autowired
      private FakeFacade facade;
  
      private FakeDTO fakeDTO = new FakeDTO();
  
      public String action01() {
          return Action.SUCCESS;
      }
  
      public String action02() {
          this.fakeDTO.setAnswer(this.fakeFacade.fakeFacadeMethod(this.fakeDTO.getComplexObject()));
          return Action.SUCCESS;
      }
  
      @Override
      public FakeDTO getModel() {
          return this.fakeDTO;
      }
  }
  </code></pre>
  <p><strong>The main class <code>FakeDTO</code>:</strong></p>
  <pre><code>public class FakeDTO implements BaseDTO {
  
      private static final long serialVersionUID = -2093038083351846003L;
  
      private FakeFilterDTO filter = new FakeFilterDTO();
      private String name;
  
      public FakeDTO() {
          super();
      }
  
      @Override
      public FakeFilterDTO getFilter() {
          return this.filter;
      }
  
      public void setFilter(final FakeFilterDTO filterParam) {
          this.filter = filterParam;
      }
  
      public String getName() {
          return this.name;
      }
  
      public String setName(final String nameParam) {
          this.name = nameParam;
      }
  }
  </code></pre>
  <p><strong>The  class <code>FakeFilterDTO</code>:</strong></p>
  <pre><code>public class FakeFilterDTO extends BaseFilterDTO {
  
      private static final long serialVersionUID = 4528040257605851210L;
  
      private Date aDate;
      private Long aLong;
      private Integer anInteger;
      private String aString;
  
      public Date getADate() {
          return this.aDate;
      }
  
      public void setDataInicial(final Date aDateParam) {
          this.aDate = aDateParam;
      }
  
      public Long getALong() {
          return this.aLong;
      }
  
      public void setALong(final Long aLongParam) {
          this.aLong = aLongParam;
      }
  
      public Integer getAnInteger() {
          return this.anInteger;
      }
  
      public void setAnInteger(final Integer anIntegerParam) {
          this.anInteger = anIntegerParam;
      }
  
      public String getAString() {
          return this.aString;
      }
  
      public void setAString(final String aStringParam) {
          this.aString = aStringParam;
      }
  }
  </code></pre>
  <p><strong>The <code>struts.xml</code>:</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
  &lt;!DOCTYPE struts PUBLIC
      &quot;-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN&quot;
      &quot;http://struts.apache.org/dtds/struts-2.1.7.dtd&quot;&gt;
      &lt;struts&gt;
  
      &lt;include file=&quot;META-INF/bsad/struts2/struts-config.xml&quot; /&gt;
  
      &lt;package name=&quot;reports&quot; namespace=&quot;/reports&quot; extends=&quot;project-default&quot;&gt;
          &lt;action name=&quot;anAction&quot; class=&quot;anAction&quot; method=&quot;action01&quot;&gt;
              &lt;result&gt;/WEB-INF/pages/success.jsp&lt;/result&gt;
              &lt;result name=&quot;input&quot;&gt;/WEB-INF/pages/input.jsp&lt;/result&gt;
          &lt;/action&gt;
  
      &lt;action name=&quot;generateReport&quot; class=&quot;anAction&quot; method=&quot;action02&quot;&gt;
              &lt;result&gt;/WEB-INF/pages/reportGenerated.jsp&lt;/result&gt;
          &lt;/action&gt;
      &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>
  <p>The <code>project-default</code> is placed in the include <code>struts-config.xml</code> and extends <code>struts-default</code> package that contains the <code>ModelDrivenInterceptor</code>. I can assure that because I placed a break point in this interceptor and its passing through there.</p>
  <p>The JSP that I used as an example before would become as follows:</p>
  <pre><code>&lt;s:textfield name=&quot;name&quot; id=&quot;name&quot; size=&quot;25&quot; maxlength=&quot;15&quot; /&gt;
  &lt;s:textfield name=&quot;filter.aString&quot; id=&quot;zipcode&quot; size=&quot;25&quot; maxlength=&quot;15&quot; /&gt;
  </code></pre>
  <p>For company policies I'm not allowed to copy/paste the actual <em>objects</em> and its names. But that's the idea.</p>