• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Values persisting in browser after save

 
Narsimha Reddy
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you provide a little more information? What exactly is the problem?

Dave
 
Narsimha Reddy
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic