gourmetj-springboot/src/main/java/com/mousetech/gourmetj/EditShopcatBean.java

136 lines
2.5 KiB
Java
Raw Normal View History

2022-01-05 16:02:42 +00:00
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;
2022-01-05 16:02:42 +00:00
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<String> shopcatSuggestionList;
@Inject
ShopcatRepository shopcatRepository;
/*
* Indicate if the shopcatname has been changed.
*/
private boolean changed = false;
/**
* @return the changed
*/
public boolean isChanged() {
return changed;
}
2022-01-05 16:02:42 +00:00
/**
* 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;
}
2022-01-05 16:02:42 +00:00
/**
* @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
*/
2022-01-05 16:02:42 +00:00
public void setIngkey(String ingkey) {
this.ingkey = ingkey;
}
/**
* @return the shopcatSuggestionList
*/
public List<String> getShopcatSuggestionList() {
return shopcatSuggestionList;
}
2022-01-05 16:02:42 +00:00
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;
}
2022-01-05 16:02:42 +00:00
}