Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

Struts CRUD

jd1000

2008-10-10


Author LoginPost Reply

I cannot work the CRUD right.

I have a UserAction with action methods ( createUser, updateUser...) and a
User (id, name ...) object.
The action contains an id, a user object and a List<User> object, implements
Preparable and ModelDriven<User>

Listing all users works ONLY when i put my users list to the stack manually:
ActionContext.getContext().put("users", users) to access it from the
view-jsp
I thought it has to be accessible from jsp when i just populate the object.

Creating works, but updating is confusing.

Creating works fine with the jsp
 <s:form action="createUserAction">
   <s:textfield label="Nickname" name="nickname" />
             ...
   <s:submit />
 </s:form>

the update DOES NOT work. I use the jsp.
 <s:form action="updateUserAction">
   <s:hidden key="id"/>
   <s:textfield label="Nickname" key="nickname" />
          ...
   <s:submit />
 </s:form>
Im trying to use the paramsprepareparams pattern. I can get the right Model
from my database by the id and put it on the stack ( in the getModel
method). but the values are not shown in the update form.
All fields are empty, when i insert new ones, the new values do overwrite my
model.

1.) Do i have to manually put my users-object on the stack ?
2.) How can i make the update form show my old values ?

Is there a working CRUD example ? ( I often stumble upon hints and snippets,
never an example what really works)
--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.