0

I have the following classes

public class Address {
  private String unit;
  private String street;
  ... getter and setters go here....
}

public class Person {
   private String name;
   private Address address;
   public Person(){
      address = new Address();
   }
   ... getter and setters go here...
 }

public class Employee extends Person {
    ... 
}

For example I can access the unit filed of address class using the following code

 <s:form method="POST" action="updateEmployee">
    <s:textfield name ="unit" label="Unit" value="%{employee.address.unit}" />
    <s:textfield name ="name" label="Name" value="%{employee.name}" />
 </s:form>

but when I submit the form it sends all the fields except the fields of address class. It shows the unit is null.

 @Action
 public class myaction implements ModelDriven {

 Employee emp = new Employee();

 public String updateEmployee(){
    System.out.println("Unit is" + employee.getAddress().getUnit();
    System.out.println("Unit is" + employee.getName();
    return "SUCCESS";
 }

 public Employee getEmployee() {
    return employee;
}

public void setEmployee(Employee employee) {
    this.employee = employee;
}

@Override
public Object getModel() {
    return employee;
}
Daniel Morgan
  • 782
  • 5
  • 15
  • 43

1 Answers1

1

Try

<s:textfield name ="employee.address.unit" label="Unit" value="%{employee.address.unit}" />
<s:textfield name ="employee.name" label="Name" value="%{employee.name}" />
user497087
  • 1,561
  • 3
  • 24
  • 41