Java Reference
In-Depth Information
Action Bean
Contact someContact;
Request
(1)
someContact=5
(7)
setSomeContact(contact)
Stripersist
@Entity
public class Contact {
@Id
ID idProperty;
(2)
find @Id
TypeConverter<Entity>
}
(3)
convert("5")
(4)
return id
(5)
call
(6)
return contact
TypeConverter<ID>
EntityManager.find(Contact.class, id)
Figure 12.3: The Stripersist entity type converter
7. Finally, Stripersist's type converter returns the Contact object,
which is set on the someContact property of the action bean.
All this work that Stripersist does means we can use entity classes
directly. For example, remember how the contact form allowed the user
to update an existing contact. We needed a hidden field in the form
to identify the contact; now, we don't need to manually write a type
converter or a formatter to support that. We can just use a Contact
property on the action bean directly in the <s:hidden> tag:
Download email_23/web/WEB-INF/jsp/contact_form.jsp
<div><s:hidden name="contact"/></div>
This produces a parameter with the value of the @Id property of the
Contact object that is being updated. When the user submits the form,
that value will be converted to a Contact object. VoilĂ ! You can now use
ID parameters for all entities: User , Folder , Message , and so on.
 
 
 
Search WWH ::




Custom Search