package com.mousetech.gourmetj; import java.io.Serializable; import java.util.List; import javax.annotation.PostConstruct; import javax.faces.event.AjaxBehaviorEvent; import javax.faces.event.ValueChangeEvent; import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; import com.mousetech.gourmetj.persistence.dao.ShopcatRepository; @Named @ViewScoped public class EditShopcatBean implements Serializable { /** * */ private static final long serialVersionUID = 1L; private String ingkey; private String shopcatName; private String shopcatSuggestion; private List shopcatSuggestionList; @Inject ShopcatRepository shopcatRepository; /* * Indicate if the shopcatname has been changed. */ private boolean changed = false; /** * @return the changed */ public boolean isChanged() { return changed; } /** * Default Constructor. */ public EditShopcatBean() { } @PostConstruct public void init() { this.shopcatSuggestionList = this.shopcatRepository .findDistinctCategoryNative(); } /** * Prepare for edit before the dialog is displayed. * * @param ingkey Ingredient key * @param shopCat Previous shopping category for ingKey */ public void beginEdit(String ingkey, String shopCat) { this.setIngkey(ingkey); this.setShopcatName(shopCat); this.changed = false; } /** * @return the shopcatName */ public String getShopcatName() { return shopcatName; } /** * @param shopcatName the shopcatName to set */ public void setShopcatName(String shopcatName) { this.shopcatName = shopcatName; } /** * @return the shopcatSuggestion */ public String getShopcatSuggestion() { return shopcatSuggestion; } /** * @param shopcatSuggestion the shopcatSuggestion to set */ public void setShopcatSuggestion(String shopcatSuggestion) { this.shopcatSuggestion = shopcatSuggestion; } /** * @return the ingkey */ public String getIngkey() { return ingkey; } /** * Set the ingredient key. * * @param ingkey */ public void setIngkey(String ingkey) { this.ingkey = ingkey; } /** * @return the shopcatSuggestionList */ public List getShopcatSuggestionList() { return shopcatSuggestionList; } public void ajaxShopcatSuggest(AjaxBehaviorEvent event) { this.shopcatName = this.shopcatSuggestion; } /** * ValueChangeListener for shopcat editor. * * @param e Event, with new name in it. */ public void shopcatNameChanged(ValueChangeEvent e) { this.changed = true; } }