public class LoadAction extends EditLoadAction<LoadForm> {
private static Logger log = Logger.getLogger(LoadAction.class);
@Override
public EditPanel createPanel(ActionMessages errors, LoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
PersonVO person = (PersonVO)attributes.get("person");
EditPanel panel = new EditPanel(Right.CRM_PERSONS_WRITE, person);
boolean contactSelectable = true;
boolean deletable = true;
if(person.getId() == null) {
panel.setTitle(MessageUtil.message(request, "module.crm.person.headLine.create"));
contactSelectable = false;
} else {
String name = new String(person.getFirstName()+" "+person.getLastName());
if(person.getTitle() != null)
name = person.getTitle()+" "+name;
if(person.getNameAffix() != null)
name = name+" "+person.getNameAffix();
panel.setTitle(MessageUtil.message(request, "module.crm.person.headLine.edit", name));
panel.setAttribute(DeleteAction.TEXT_TITLE, MessageUtil.message(request, "module.crm.person.delete.headLine", person.getLastName(), person.getFirstName()));
panel.setAttribute(DeleteAction.TEXT_QUESTION, MessageUtil.message(request, "module.crm.person.delete.question", person.getLastName(), person.getFirstName()));
}
if(person.getPersonContacts().size() > 0 || person.getJobs().size() > 0)
deletable = false;
panel.addAction(Action.Type.DELETE, "/crm/person/delete", deletable);
panel.addAction(Action.Type.SAVE, "/crm/person/save");
if(SystemConfiguration.getInstance().getBooleanValue(SystemConfiguration.Key.SHOW_OVERVIEW)) {
panel.addPage("OVERVIEW", "/crm/person/pageOverview", "module.generic.panel.tab.overview");
}
panel.addPage("STANDARD", "/crm/person/pageStandard", "module.crm.person.pageStandard");
panel.addPage("ADDRESS", "/crm/person/pageAddress", "module.crm.person.pageAddress");
panel.addPage("CONTACT", "/crm/person/pageContact", "module.crm.person.pageContact", contactSelectable, true);
panel.addPage("JOBS", "/crm/person/pageJob", "module.generic.panel.tab.crm.jobs", contactSelectable, true);
panel.addPage("SYSTEM", "/crm/person/pageSystem", "module.generic.panel.tab.system");
if(person.getId() == null) {
panel.activatePage(panel.findPage("STANDARD"));
}
return panel;
}