Mercurial > hg > LGServer
view src/main/java/de/mpiwg/web/FileCreator.java @ 2:1f56cf4f80d4
Fix of bug in the creation of a new file.
author | "jurzua <jurzua@mpiwg-berlin.mpg.de>" |
---|---|
date | Wed, 11 Mar 2015 16:00:42 +0100 |
parents | 7682c04c63a8 |
children |
line wrap: on
line source
package de.mpiwg.web; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import javax.faces.event.ActionEvent; import javax.faces.event.ValueChangeEvent; import javax.faces.model.SelectItem; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.icefaces.ace.event.TextChangeEvent; import de.mpiwg.gazetteer.db.DBSection; import de.mpiwg.gazetteer.utils.DBService; import de.mpiwg.gazetteer.utils.DataProvider; public class FileCreator extends AbstractBean{ private static Logger logger = Logger.getLogger(FileCreator.class); private DBSection section; private Long sectionId; private List<SelectItem> sectionSuggestion; public FileCreator(){ } public void reset(){ this.section = null; this.sectionId = null; this.sectionSuggestion = null; } public void listenerLoadSection(ActionEvent event){ if(sectionId != null & sectionId > 0){ try { this.section = DBService.getSectionWithContent(sectionId); } catch (SQLException e) { internalError(e); } }else{ this.reset(); } } public void listenerReset(ActionEvent event){ this.reset(); } public void changeSectionInput(TextChangeEvent event){ String input = event.getNewValue().toString(); this.sectionSuggestion = new ArrayList<SelectItem>(); try { List<String> list = DBService.suggestSectionId(input); System.out.println(list.size()); for(String s : list){ this.sectionSuggestion.add(new SelectItem(s)); } } catch (SQLException e) { internalError(e); } } /* public void listenerSaveNewFile(ActionEvent event){ if( section != null && StringUtils.isNotEmpty(section.getText()) && StringUtils.isNotEmpty(label)){ try { Long branchId = DataProvider.getInstance().saveNewFile( section.getText(), label, section.getId(), getSessionBean().getUser().getId()); addMsg("New branch created [id=" + branchId +"]"); } catch (Exception e) { internalError(e); } } } */ public DBSection getSection() { return section; } public void setSection(DBSection section) { this.section = section; } public Long getSectionId() { return sectionId; } public void setSectionId(Long sectionId) { this.sectionId = sectionId; } public List<SelectItem> getSectionSuggestion() { return sectionSuggestion; } public void setSectionSuggestion(List<SelectItem> sectionSuggestion) { this.sectionSuggestion = sectionSuggestion; } }