Sebastien Dionne
Sebastien Dionne

Reputation: 776

Struts2 CRUD, how to update the model : ModelDriven. It's always blank in the JSP

I'm not able to retreive my Model in my JSP to update the object.

public class ViewDashboardAction extends ActionSupport implements ModelDriven {
private Clinique clinique = null;

@Override
    public Clinique getModel() {
        return clinique;
    }

    public String execute() throws Exception {

        clinique = service.read(1);

        // at this point my object is populated

        return SUCCESS;
    }

in my JSP I want to have something that simple

<s:textfield name="nom" key="clinique.nom" value="nom"></s:textfield>

but my textfield is always blank.

What I'm missing ?

Upvotes: 1

Views: 1268

Answers (1)

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

try this

private Clinique clinique = new Clinique();

@Override
    public Object getModel() {
        return clinique;
    }


public void setClinique(Clinique clinique ){
   this.clinique =clinique ;
}

public Clinique getClinique(){
   return clinique ;
}

Upvotes: 1

Related Questions