I create a persisstance object, called LogInformation, I want the createBy and lastUpdateBy value is from session that I create using JSP. I use WebWork to do a save action. This is my code. I got dispose error when try to execute it.
If I remove the line of setCreateBy and setLastUpdateBy, the save execution to database is run well. but the value is null.
anyone can help?
/*
* Created on Dec 25, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.blueoxygen.cimande.role.actions;
import java.util.Calendar;
import org.blueoxygen.util.StringUtils;
import com.opensymphony.webwork.ServletActionContext;
import org.blueoxygen.cimande.LogInformation;
import org.blueoxygen.cimande.role.Role;
import org.blueoxygen.cimande.security.SessionCredentials;
import org.blueoxygen.cimande.security.SessionCredentialsAware;
import org.blueoxygen.cimande.security.User;
/**
* @author frans
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class AddRole extends RoleForm implements SessionCredentialsAware {
private SessionCredentials sessionCredentials;
public String execute() {
Role role = new Role();
if (getName().equalsIgnoreCase(""))
addActionError("Name can't be empty.");
if (getDescription().equalsIgnoreCase(""))
addActionError("Description can't be empty.");
if (hasErrors()) {
return INPUT;
} else {
role.setName(getName());
role.setDescription(getDescription());
// logging information
LogInformation log = new LogInformation();
log.setCreateDate(Calendar.getInstance());
log.setLastUpdateDate(Calendar.getInstance());
String activeUserId;
StringUtils stringUtils = new StringUtils();
activeUserId = ""+stringUtils.decodeBase64(""+ServletActionContext.getRequest().getSession().getAttribute("GA_USER"));
//sessionCredentials.getCurrentUser().setUsername();
log.setCreateBy(activeUserId);
log.setLastUpdateBy(activeUserId);
if (getActiveFlag() == -1) {
log.setActiveFlag(LogInformation.INACTIVE);
} else {
log.setActiveFlag(getActiveFlag());
}
role.setLogInformation(log);
getPersistenceManager().save(role);
return SUCCESS;
}
}
public void setSessionCredentials(SessionCredentials sessionCredentials) {
this.sessionCredentials = sessionCredentials;
}
}
|