I dont't get your point. In which part do you recover the values sent by the user to the server? I think the best way to do that would be to use the Struts' infrastructure to load the fields in a temporary object, and then recover the object from the DB and alter the fields you want on that object. You would need to implement Preparable to create the object before the parameters are loaded.Suppousing you use the same action to see and save the object Person, the action would be as follow:
package test; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.Preparable; public class PersonAction extends ActionSupport implements Preparable{ private Person person = null; public Person getPerson() { return person; } public void setPerson(Person person) { this.person = person; } public void prepare() throws Exception { } public void prepareSave() throws Exception { //This is so Struts can do a getPerson().setXXXXXXX(); person = new Person(); } public String save(){ Person person2 = em.find(1, Person.class);; person2.setName(person.getName()); //Copy other fields depending on the user's profile //Save person2 } public String see(){ //read Person 1 from DB person = em.find(1, Person.class); return SUCCESS; } } 2011/11/14 Marco Schwarz <marco.schw...@cioppino.net> > I remember I'm new with Struts2 ;-) > > Why do I use Struts2/Tiles/openJPA? > > openJPA: to work with database entities > tiles: to work with layouts > struts2: the action concept and the posibility to make mapping between > html and the object in my action. > > example: > > model: > class Person() { > private int id; > private String name; > public String getName() { return name; } > public int getId() { return id; } > public void setName(String name) { this.name = name; } > publci void setId(int id) { this.id = id; } > } > > action: > PersonAction extends { > > private Person person; > > @override > public String execute throws Execption { > > //read Person 1 from DB > person = em.find(1, Person.class); > > return SUCCESS; > > } > > } > > html: > <s:textfield name="person.id" label="id" /> > <s:textfield name="person.name" label="name" /> > > When I must read the request, why do I use Struts2... Servlet do the same. > > Thanks > Marco > > > > > On Mon, Nov 14, 2011 at 3:58 PM, Edward W. Rouse <ero...@comsquared.com> > wrote: > > You could always store it in the session and read it from there. > > > >> -----Original Message----- > >> From: Marco Schwarz [mailto:marco.schw...@cioppino.net] > >> Sent: Saturday, November 12, 2011 1:57 PM > >> To: Struts Users Mailing List; jlm...@gmail.com > >> Subject: Re: <s:textfield /> Beginner question > >> > >> You are right, but the user must see the fields and I need the object > >> with all properties for call (JPA) persist method. what's the best > >> practice for this use case > >> > >> I have one object and many roles .... any role can change a different > >> field ... Do I create a class for any roles? > >> > >> Idea? > >> > >> Thanks > >> Marco > >> > >> > >> On Sat, Nov 12, 2011 at 7:31 PM, <jlm...@gmail.com> wrote: > >> > The use of hidden fields to avoid the user changing those fields is a > >> security risk. You are still getting all the fields from the client's > >> side, so the user or somebody else (through a man-in-the-middle > >> atytack) are still able to change the value of those fields. > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >> For additional commands, e-mail: user-h...@struts.apache.org > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >