Save with bad ingkey, print page fixes
This commit is contained in:
parent
bc368f084c
commit
af7c49713a
|
@ -5,9 +5,6 @@ import com.mousetech.gourmetj.persistence.model.IngredientIF;
|
||||||
import com.mousetech.gourmetj.persistence.model.Recipe;
|
import com.mousetech.gourmetj.persistence.model.Recipe;
|
||||||
import com.mousetech.gourmetj.persistence.model.Shopcat;
|
import com.mousetech.gourmetj.persistence.model.Shopcat;
|
||||||
|
|
||||||
import net.bytebuddy.asm.Advice.This;
|
|
||||||
|
|
||||||
import com.mousetech.gourmetj.IngredientDigester;
|
|
||||||
import com.mousetech.gourmetj.IngredientDigester.IngredientAmountFormat;
|
import com.mousetech.gourmetj.IngredientDigester.IngredientAmountFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,9 +23,13 @@ public class IngredientUI implements IngredientIF {
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param ingredient
|
* @param ingredient Ingredient that we facade. If null,
|
||||||
|
* constructs a dummy Ingredient (example, for group item).
|
||||||
*/
|
*/
|
||||||
public IngredientUI(Ingredient ingredient) {
|
public IngredientUI(Ingredient ingredient) {
|
||||||
|
if ( ingredient == null ) {
|
||||||
|
ingredient = new Ingredient();
|
||||||
|
}
|
||||||
this.ingredient = ingredient;
|
this.ingredient = ingredient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,17 @@ public class JSFUtils {
|
||||||
.getExternalContext().getFlash());
|
.getExternalContext().getFlash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look in Flash scope for item.
|
||||||
|
*
|
||||||
|
* @param key Item to retrieve
|
||||||
|
* @return Item, or null if not in Flash OR Flash not active
|
||||||
|
*/
|
||||||
public static Object getFlash(String key) {
|
public static Object getFlash(String key) {
|
||||||
|
Flash flash = flashScope();
|
||||||
|
if ( flash == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return flashScope().get(key);
|
return flashScope().get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ public class RecipeDetailBean implements Serializable {
|
||||||
*/
|
*/
|
||||||
if (this.recipe == null) {
|
if (this.recipe == null) {
|
||||||
Long rid =
|
Long rid =
|
||||||
(Long) JSFUtils.flashScope().get("recipeID");
|
(Long) JSFUtils.getFlash("recipeID");
|
||||||
if (rid != null) {
|
if (rid != null) {
|
||||||
this.recipe = loadRecipe(rid);
|
this.recipe = loadRecipe(rid);
|
||||||
} else {
|
} else {
|
||||||
|
@ -704,7 +704,7 @@ public class RecipeDetailBean implements Serializable {
|
||||||
JSFUtils.addErrorMessage(
|
JSFUtils.addErrorMessage(
|
||||||
"No Shopping Category is defined for Ingredient Key "
|
"No Shopping Category is defined for Ingredient Key "
|
||||||
+ ingKey);
|
+ ingKey);
|
||||||
return false;
|
//return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
ing.setShopCat(scat);
|
ing.setShopCat(scat);
|
||||||
|
@ -1008,4 +1008,35 @@ public class RecipeDetailBean implements Serializable {
|
||||||
long now = new java.util.Date().getTime();
|
long now = new java.util.Date().getTime();
|
||||||
return String.valueOf(now);
|
return String.valueOf(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//*** Add Group
|
||||||
|
|
||||||
|
private String newGroupName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the newGroupName
|
||||||
|
*/
|
||||||
|
public String getNewGroupName() {
|
||||||
|
return newGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param newGroupName the newGroupName to set
|
||||||
|
*/
|
||||||
|
public void setNewGroupName(String newGroupName) {
|
||||||
|
this.newGroupName = newGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new group to bottom of model as AJAX operation.
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public String doAddGroup() {
|
||||||
|
IngredientUI iui = new IngredientUI(null);
|
||||||
|
iui.setIngGroup(true);
|
||||||
|
iui.setItem(this.getNewGroupName());
|
||||||
|
List<IngredientUI> ingUIList = this.getWrappedIngredients();
|
||||||
|
ingUIList.add(iui);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,8 +165,9 @@
|
||||||
render="ingredientTable"
|
render="ingredientTable"
|
||||||
/>
|
/>
|
||||||
</p:commandButton>
|
</p:commandButton>
|
||||||
<p:button value="Add Group"
|
<p:commandButton
|
||||||
disabled="true"
|
value="Add Group"
|
||||||
|
onclick="PF('addGroupDlg').show()"
|
||||||
/>
|
/>
|
||||||
<p:button
|
<p:button
|
||||||
value="Add Recipe As Ingredient"
|
value="Add Recipe As Ingredient"
|
||||||
|
@ -255,6 +256,7 @@
|
||||||
id="ingOpt"
|
id="ingOpt"
|
||||||
value="#{item.optionalCB}"
|
value="#{item.optionalCB}"
|
||||||
rendered="#{not item.ingGroup}"
|
rendered="#{not item.ingGroup}"
|
||||||
|
title="Optional item"
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column style="width: 13em">
|
<p:column style="width: 13em">
|
||||||
|
@ -274,9 +276,7 @@
|
||||||
/>
|
/>
|
||||||
</p:inputText>
|
</p:inputText>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column
|
<p:column style="width: 2em">
|
||||||
style="width: 2em"
|
|
||||||
>
|
|
||||||
<f:facet name="header">
|
<f:facet name="header">
|
||||||
E
|
E
|
||||||
</f:facet>
|
</f:facet>
|
||||||
|
@ -287,6 +287,7 @@
|
||||||
update="editShopcatDlg"
|
update="editShopcatDlg"
|
||||||
oncomplete="PF('editShopcatDlg').show()"
|
oncomplete="PF('editShopcatDlg').show()"
|
||||||
title="Edit the shopping category for ing. key"
|
title="Edit the shopping category for ing. key"
|
||||||
|
rendered="#{not item.ingGroup}"
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column>
|
<p:column>
|
||||||
|
@ -351,6 +352,7 @@
|
||||||
</p:tab>
|
</p:tab>
|
||||||
</p:tabView>
|
</p:tabView>
|
||||||
<p:commandButton id="doSave" value="Save"
|
<p:commandButton id="doSave" value="Save"
|
||||||
|
icon="pi pi-check"
|
||||||
disabled="{not recipeDetailBean.dirty}"
|
disabled="{not recipeDetailBean.dirty}"
|
||||||
action="#{recipeDetailBean.doSave}"
|
action="#{recipeDetailBean.doSave}"
|
||||||
/>
|
/>
|
||||||
|
@ -359,6 +361,32 @@
|
||||||
/>
|
/>
|
||||||
</h:form>
|
</h:form>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
|
<p:dialog id="addGroupDlg" widgetVar="addGroupDlg">
|
||||||
|
<h:form id="frmAddGroup">
|
||||||
|
<p:panelGrid columns="1">
|
||||||
|
<p:outputLabel for="@next"
|
||||||
|
value="Group Name"
|
||||||
|
/>
|
||||||
|
<p:inputText id="ctlNewGroupName"
|
||||||
|
value="#{recipeDetailBean.newGroupName}"
|
||||||
|
/>
|
||||||
|
<p:panelGrid columns="2"
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<p:commandButton id="agDlgOK"
|
||||||
|
value="OK" style="width: 6em"
|
||||||
|
action="#{recipeDetailBean.doAddGroup}"
|
||||||
|
update="form1:tabGroupClient:ingredientTable"
|
||||||
|
oncomplete="PF('addGroupDlg').hide()"
|
||||||
|
/>
|
||||||
|
<p:commandButton id="agDlgCan"
|
||||||
|
value="Cancel" style="width: 6em"
|
||||||
|
onclick="PF('addGroupDlg').hide()"
|
||||||
|
/>
|
||||||
|
</p:panelGrid>
|
||||||
|
</p:panelGrid>
|
||||||
|
</h:form>
|
||||||
|
</p:dialog>
|
||||||
<p:dialog id="editShopcatDlg"
|
<p:dialog id="editShopcatDlg"
|
||||||
widgetVar="editShopcatDlg"
|
widgetVar="editShopcatDlg"
|
||||||
>
|
>
|
||||||
|
|
|
@ -9,80 +9,118 @@
|
||||||
<!-- Print Recipe -->
|
<!-- Print Recipe -->
|
||||||
<ui:define name="title">Gourmet Recipe Manager</ui:define>
|
<ui:define name="title">Gourmet Recipe Manager</ui:define>
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:messages />
|
<h:form id="printForm">
|
||||||
<img id="bigpix"
|
<h:messages />
|
||||||
SRC="/img/picture/#{recipeDetailBean.recipe.id}"
|
<p:panelGrid
|
||||||
/>
|
style="margin-bottom: 5px; border-style: none"
|
||||||
<p:commandButton value="<- Back" action="main.jsf" />
|
|
||||||
<p:panelGrid columns="2">
|
|
||||||
<h:outputLabel for="@next" value="Category: " />
|
|
||||||
<h:outputText
|
|
||||||
value="#{adminMainBean.formatCategories(recipeDetailBean.recipe)}"
|
|
||||||
/>
|
|
||||||
<h:outputLabel for="@next" value="Cuisine: " />
|
|
||||||
<h:outputText
|
|
||||||
value="#{recipeDetailBean.recipe.cuisine}"
|
|
||||||
/>
|
|
||||||
<h:outputLabel for="@next" value="Prep Time: " />
|
|
||||||
<h:outputText
|
|
||||||
value="#{userSession.formatTime(recipeDetailBean.recipe.preptime)}"
|
|
||||||
/>
|
|
||||||
<h:outputLabel for="@next" value="Cook Time: " />
|
|
||||||
<h:outputText label="Cook Time: "
|
|
||||||
value="#{userSession.formatTime(recipeDetailBean.recipe.cooktime)}"
|
|
||||||
/>
|
|
||||||
</p:panelGrid>
|
|
||||||
<!-- -->
|
|
||||||
<p:panelGrid columns="1" id="ingredientsc">
|
|
||||||
<f:facet name="header">
|
|
||||||
<h:outputText styleClass="subtitle"
|
|
||||||
value="Ingredients"
|
|
||||||
/>
|
|
||||||
</f:facet>
|
|
||||||
<p:dataTable id="ingredients"
|
|
||||||
showDirectLinksArrows="true"
|
|
||||||
value="#{recipeDetailBean.ingredients}"
|
|
||||||
var="ingredient"
|
|
||||||
>
|
>
|
||||||
<p:column label="Amt" style="text-align: right">
|
<p:column>
|
||||||
<h:outputText
|
<img id="bigpix"
|
||||||
value="#{ingredient.displayAmount}"
|
SRC="/img/picture/#{recipeDetailBean.recipe.id}"
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column label="Units">
|
<p:column
|
||||||
<h:outputText value="#{ingredient.unit}" />
|
style="vertical-align: middle; text-align: left; border: none"
|
||||||
</p:column>
|
>
|
||||||
<p:column label="Item">
|
<p:commandButton value="<- Back"
|
||||||
<h:outputText value="#{ingredient.item}" />
|
style="margin-left: 2em" immediate="true"
|
||||||
</p:column>
|
action="/main.jsf"
|
||||||
<p:column label="Optional" align="center">
|
|
||||||
<p:selectBooleanCheckbox readonly="true"
|
|
||||||
value="#{ingredient.optionalCB}"
|
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
</p:dataTable>
|
</p:panelGrid>
|
||||||
</p:panelGrid>
|
<p:panelGrid columns="2">
|
||||||
<h:outputText
|
<h:outputLabel for="@next" value="Category: " />
|
||||||
value="Recipe ID: #{recipeDetailBean.recipe.id}"
|
<h:outputText
|
||||||
/>
|
value="#{userSession.formatCategories(recipeDetailBean.recipe)}"
|
||||||
<p:panelGrid columns="1">
|
|
||||||
<f:facet name="header">
|
|
||||||
<h:outputText styleClass="subtitle"
|
|
||||||
value="Instructions"
|
|
||||||
/>
|
/>
|
||||||
</f:facet>
|
<h:outputLabel for="@next" value="Cuisine: " />
|
||||||
|
<h:outputText
|
||||||
|
value="#{recipeDetailBean.recipe.cuisine}"
|
||||||
|
/>
|
||||||
|
<h:outputLabel for="@next" value="Prep Time: " />
|
||||||
|
<h:outputText
|
||||||
|
value="#{userSession.formatTime(recipeDetailBean.recipe.preptime)}"
|
||||||
|
/>
|
||||||
|
<h:outputLabel for="@next" value="Cook Time: " />
|
||||||
|
<h:outputText label="Cook Time: "
|
||||||
|
value="#{userSession.formatTime(recipeDetailBean.recipe.cooktime)}"
|
||||||
|
/>
|
||||||
|
</p:panelGrid>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<h:outputText id="instructions" escape="false"
|
<p:panelGrid id="ingredientsc">
|
||||||
value="#{recipeDetailBean.instructions}"
|
<f:facet name="header">
|
||||||
|
<h:outputText styleClass="subtitle"
|
||||||
|
value="Ingredients"
|
||||||
|
/>
|
||||||
|
</f:facet>
|
||||||
|
<p:column style="padding: 0px 4px">
|
||||||
|
<p:dataTable id="ingredients"
|
||||||
|
showDirectLinksArrows="true"
|
||||||
|
value="#{recipeDetailBean.ingredients}"
|
||||||
|
var="ingredient"
|
||||||
|
>
|
||||||
|
<p:column
|
||||||
|
style="text-align: right; width: 2em"
|
||||||
|
>
|
||||||
|
<f:facet name="header">
|
||||||
|
Amt.
|
||||||
|
</f:facet>
|
||||||
|
<h:outputText
|
||||||
|
value="#{ingredient.displayAmount}"
|
||||||
|
/>
|
||||||
|
</p:column>
|
||||||
|
<p:column style="width: 6em">
|
||||||
|
<f:facet name="header">Units</f:facet>
|
||||||
|
<h:outputText
|
||||||
|
value="#{ingredient.unit}"
|
||||||
|
/>
|
||||||
|
</p:column>
|
||||||
|
<p:column>
|
||||||
|
<f:facet name="header">
|
||||||
|
Item
|
||||||
|
</f:facet>
|
||||||
|
<h:outputText
|
||||||
|
value="#{ingredient.item}"
|
||||||
|
/>
|
||||||
|
</p:column>
|
||||||
|
<p:column align="center"
|
||||||
|
style="width: 2em"
|
||||||
|
>
|
||||||
|
<f:facet name="header">
|
||||||
|
Opt.
|
||||||
|
</f:facet>
|
||||||
|
<p:selectBooleanCheckbox
|
||||||
|
readonly="true"
|
||||||
|
value="#{ingredient.optionalCB}"
|
||||||
|
/>
|
||||||
|
</p:column>
|
||||||
|
</p:dataTable>
|
||||||
|
</p:column>
|
||||||
|
</p:panelGrid>
|
||||||
|
<h:outputText
|
||||||
|
value="Recipe ID: #{recipeDetailBean.recipe.id}"
|
||||||
/>
|
/>
|
||||||
</p:panelGrid>
|
<p:panelGrid columns="1">
|
||||||
<p:panelGrid columns="1">
|
<f:facet name="header">
|
||||||
<f:facet name="header">
|
<h:outputText styleClass="subtitle"
|
||||||
<h:outputText styleClass="subtitle" value="Notes" />
|
value="Instructions"
|
||||||
</f:facet>
|
/>
|
||||||
<h:outputText escape="false"
|
</f:facet>
|
||||||
value="#{recipeDetailBean.modifications}"
|
<!-- -->
|
||||||
/>
|
<h:outputText id="instructions" escape="false"
|
||||||
</p:panelGrid>
|
value="#{recipeDetailBean.instructions}"
|
||||||
|
/>
|
||||||
|
</p:panelGrid>
|
||||||
|
<p:panelGrid columns="1">
|
||||||
|
<f:facet name="header">
|
||||||
|
<h:outputText styleClass="subtitle"
|
||||||
|
value="Notes"
|
||||||
|
/>
|
||||||
|
</f:facet>
|
||||||
|
<h:outputText escape="false"
|
||||||
|
value="#{recipeDetailBean.modifications}"
|
||||||
|
/>
|
||||||
|
</p:panelGrid>
|
||||||
|
</h:form>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
</ui:composition>
|
</ui:composition>
|
Loading…
Reference in New Issue
Block a user