permaculture playing cards
The moose likes Struts and the fly likes Values persisting in browser after save Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Values persisting in browser after save" Watch "Values persisting in browser after save" New topic

Values persisting in browser after save

Narsimha Reddy

Joined: Jan 08, 2008
Posts: 6
I am using struts2,spring and hibernate in our application.
Basic flow:Action calls dao, dao uses hibernate.saveOrUpdate method to save the data.

Here my problem is, after saving the object to db, value remains persistatnt.I have done all clean up operations at hiberante level.
It is always displaying in the browser.

Then i came to know problem with struts, my action class implements ModelDriven And Preparable interfaces.

I am new to these technologies.

Could you some one help me out in resolving this issue

Narsimha Reddy
David Newton

Joined: Sep 29, 2008
Posts: 12617

Could you provide a little more information? What exactly is the problem?

Narsimha Reddy

Joined: Jan 08, 2008
Posts: 6
I will give provied some piece of code
in jsp:<s:textfield label="Name" name="name" />
Hibernate POJO:
public abstract class implements Serializable{
@Column(name = "Name", nullable = false)
private String name = null;
// setters and getters go here
Action: implements ModelDriven<T>, Preparable
//contains getModel and prepare method.
// used some java generics
private T dataElement;
private List<T> dataElements;
public String saveElement(){
dataElements = configDAO.findAll();
return "Elements";
DAO methods:
public void makePersistent(T element) {
public List<T> findAll() {
DetachedCriteria detachedCrit = DetachedCriteria
List<T> elements = getHibernateTemplate().findByCriteria(detachedCrit);
return elements;

makePersistant method save the entiy and findAll method retrieves the list of records.After saving element findAll method will be called.
Everything working properly but aftetr saving, jsp text box name not clearing.

My only problem here is, i need to clear the text field after saving the record.
wood burning stoves
subject: Values persisting in browser after save
It's not a secret anymore!