aspose file tools*
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Values persisting in browser after save" Watch "Values persisting in browser after save" New topic
Author

Values persisting in browser after save

Narsimha Reddy
Greenhorn

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

Thanks,
Narsimha Reddy
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Dave
Narsimha Reddy
Greenhorn

Joined: Jan 08, 2008
Posts: 6
I will give provied some piece of code
in jsp:<s:textfield label="Name" name="name" />
Hibernate POJO:
@MappedSuperclass
@Validation
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(){
configDAO.saveElement(dataElement);
dataElements = configDAO.findAll();
return "Elements";
}
DAO methods:
@Override
public void makePersistent(T element) {
getHibernateTemplate().saveOrUpdate(element);
getHibernateTemplate().clear();
element.setId(null);
}
@Override
@SuppressWarnings("unchecked")
public List<T> findAll() {
DetachedCriteria detachedCrit = DetachedCriteria
.forClass(dataElementClass);
List<T> elements = getHibernateTemplate().findByCriteria(detachedCrit);
getHibernateTemplate().clear();
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Values persisting in browser after save