Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0335b31b
authored
Oct 26, 2012
by
Riku Silvola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit templates in beans
1 parent
9c27721e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
159 additions
and
18 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/FoodWaveBean.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/FoodWaveBeanLocal.java
code/LanBortalWeb/WebContent/foodadmin/editTemplate.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/FoodWaveBean.java
View file @
0335b31
package
fi
.
insomnia
.
bortal
.
beans
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.annotation.security.DeclareRoles
;
...
...
@@ -11,8 +12,11 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
import
fi.insomnia.bortal.facade.FoodWaveFacade
;
import
fi.insomnia.bortal.facade.FoodWaveTemplateFacade
;
import
fi.insomnia.bortal.facade.GenericFacade
;
import
fi.insomnia.bortal.facade.ProductFacade
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
import
fi.insomnia.bortal.model.Product
;
/**
* Session Bean implementation class FoodWaveBean
...
...
@@ -26,6 +30,8 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
@EJB
private
FoodWaveFacade
foodWaveFacade
;
@EJB
private
ProductFacade
productfacade
;
@Override
@RolesAllowed
(
ShopPermission
.
S_MANAGE_PRODUCTS
)
...
...
@@ -87,4 +93,28 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
return
foodWaveFacade
.
getEventFoodWaves
();
}
@Override
public
FoodWaveTemplate
addProductToTemplate
(
FoodWaveTemplate
template
,
Product
product
)
{
template
=
fwtFacade
.
reload
(
template
);
if
(
product
.
getId
()
==
null
)
{
productfacade
.
create
(
product
);
}
else
{
product
=
productfacade
.
reload
(
product
);
}
if
(
product
.
getFoodWaveTemplates
()
==
null
)
{
product
.
setFoodWaveTemplates
(
new
ArrayList
<
FoodWaveTemplate
>());
}
if
(
template
.
getProducts
()
==
null
)
{
template
.
setProducts
(
new
ArrayList
<
Product
>());
}
template
.
getProducts
().
add
(
product
);
product
.
getFoodWaveTemplates
().
add
(
template
);
return
template
;
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/FoodWaveBeanLocal.java
View file @
0335b31
...
...
@@ -6,6 +6,7 @@ import javax.ejb.Local;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
import
fi.insomnia.bortal.model.Product
;
@Local
public
interface
FoodWaveBeanLocal
{
...
...
@@ -29,4 +30,6 @@ public interface FoodWaveBeanLocal {
public
List
<
FoodWave
>
getEventFoodWaves
();
public
void
createFoodWave
(
FoodWave
fw
);
FoodWaveTemplate
addProductToTemplate
(
FoodWaveTemplate
template
,
Product
currentProduct
);
}
code/LanBortalWeb/WebContent/foodadmin/editTemplate.xhtml
View file @
0335b31
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{foodWaveView.initEditTemplate()}"
/>
<f:event
type=
"preRenderView"
listener=
"#{foodWaveView.initEditTemplate()}"
/>
<f:viewParam
name=
"id"
value=
"#{foodWaveView.templateId}"
/>
</f:metadata>
...
...
@@ -18,34 +26,123 @@
<h:form>
<p:panel
header=
"#{i18n['foodwavetemplate.edit']}"
>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
for=
"name"
value=
"#{i18n['foodwavetemplate.name']}"
/>
<h:outputLabel
for=
"name"
value=
"#{i18n['foodwave.template.name']}"
/>
<h:inputText
id=
"name"
value=
"#{foodWaveView.template.name}"
/>
<h:message
for=
"name"
/>
<h:outputLabel
for=
"desc"
value=
"#{i18n['foodwavetemplate.description']}"
/>
<h:inputText
id=
"desc"
value=
"#{foodWaveView.template.description}"
/>
<h:outputLabel
for=
"desc"
value=
"#{i18n['foodwave.template.description']}"
/>
<h:inputText
id=
"desc"
value=
"#{foodWaveView.template.description}"
/>
<h:message
for=
"desc"
/>
<h:outputText
value=
" "
/>
<h:commandButton
action=
"#{foodWaveView.saveTemplate()}"
value=
"#{i18n['foodwavetemplate.save']}"
/>
<h:commandButton
action=
"#{foodWaveView.saveTemplate()}"
value=
"#{i18n['foodwavetemplate.save']}"
/>
</h:panelGrid>
<h:selectOneMenu
value=
"#{foodWaveView.currentProduct}"
converter=
"#{productConverter}"
>
<f:selectItems
value=
"#{foodWaveView.products}"
var=
"product"
itemLabel=
"#{product.name}"
></f:selectItems>
</h:selectOneMenu>
<p:commandButton
value=
"#{i18n['foodwavetemplate.addproduct']}"
actionListener=
"#{foodWaveView.addProductToTemplate}"
update=
"productTable"
/>
<!-- <h:panelGrid columns="4">
<h:outputText value="#{i18n['foodwavetemplate.productname']}" />
<h:outputText
value="#{i18n['foodwavetemplate.productdescription']}" />
<h:outputText value="#{i18n['foodwavetemplate.price']}" />
<h:outputText value=" " />
<h:inputText id="productname"
value="#{foodWaveView.currentProduct.name}" />
<h:inputText id="productdescription"
value="#{foodWaveView.currentProduct.description}" />
<h:inputText id="price"
value="#{foodWaveView.currentProduct.price}" />
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}"
actionListener="#{foodWaveView.addProductToTemplate}"
update="productTable" />
</h:panelGrid>
-->
<p:dataTable
name=
"productTable"
id=
"productTable"
value=
"#{foodWaveView.template.products}"
var=
"product"
editable=
"true"
>
<p:column
headerText=
"#{i18n['foodwavetemplate.productname']}"
>
<p:cellEditor>
<f:facet
name=
"output"
>
<h:outputText
value=
"#{product.name}"
/>
</f:facet>
<f:facet
name=
"input"
>
<p:inputText
value=
"#{product.name}"
style=
"width:100%"
required=
"true"
requiredMessage=
"Name required"
/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column
headerText=
"#{i18n['foodwavetemplate.productdescription']}"
>
<p:cellEditor>
<f:facet
name=
"output"
>
<h:outputText
value=
"#{product.description}"
/>
</f:facet>
<f:facet
name=
"input"
>
<p:inputText
value=
"#{product.description}"
style=
"width:100%"
required=
"true"
requiredMessage=
"Description required"
/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column
headerText=
"#{i18n['foodwavetemplate.price']}"
>
<p:cellEditor>
<f:facet
name=
"output"
>
<h:outputText
value=
"#{product.price}"
/>
</f:facet>
<f:facet
name=
"input"
>
<p:inputText
value=
"#{product.price}"
style=
"width:100%"
required=
"true"
requiredMessage=
"Price required"
/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column
headerText=
"#{i18n['foodwavetemplate.editRow']}"
style=
"width:20px"
>
<p:rowEditor
/>
</p:column>
<p:column
headerText=
"#{i18n['foodwavetemplate.actions']}"
style=
"width:20px;"
>
<p:commandButton
value=
"#{i18n['foodwavetemplate.removeFromList']}"
action=
"#{foodWaveView.removeProductFromList(product)}"
update=
"productTable"
/>
</p:column>
</p:dataTable>
<h:commandButton
action=
"#{foodWaveView.saveTemplate()}"
value=
"#{i18n['foodwavetemplate.savetemplate']}"
/>
<!-- -->
</p:panel>
<p:panel
header=
"#{i18n['foodwavetemplate.createwave']}"
>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
for=
"waveName"
value=
"#{i18n['foodwavetemplate.waveName']}"
/>
<h:inputText
id=
"waveName"
value=
"#{foodWaveView.selectedFoodWave.name}"
/>
<h:outputLabel
for=
"waveName"
value=
"#{i18n['foodwavetemplate.waveName']}"
/>
<h:inputText
id=
"waveName"
value=
"#{foodWaveView.selectedFoodWave.name}"
/>
<h:message
for=
"waveName"
/>
<h:outputLabel
for=
"waveMaxFoods"
value=
"#{i18n['foodwavetemplate.maxfoods']}"
/>
<h:inputText
id=
"waveMaxFoods"
value=
"#{foodWaveView.selectedFoodWave.maximumFoods}"
/>
<h:outputLabel
for=
"waveMaxFoods"
value=
"#{i18n['foodwavetemplate.maxfoods']}"
/>
<h:inputText
id=
"waveMaxFoods"
value=
"#{foodWaveView.selectedFoodWave.maximumFoods}"
/>
<h:message
for=
"waveMaxFoods"
/>
<h:outputLabel
for=
"startTime"
value=
"#{i18n['foodwavetemplate.startTime']}"
/>
<p:calendar
id=
"startTime"
value=
"#{foodWaveView.startDate}"
pattern=
"dd.MM.yyyy HH:mm"
/>
<h:outputLabel
for=
"startTime"
value=
"#{i18n['foodwavetemplate.startTime']}"
/>
<p:calendar
id=
"startTime"
value=
"#{foodWaveView.startDate}"
pattern=
"dd.MM.yyyy HH:mm"
/>
<h:message
for=
"startTime"
/>
</h:panelGrid>
<h:commandButton
action=
"#{foodWaveView.createFoodwave()}"
value=
"#{i18n['foodwavetemplate.createFoodwave']}"
/>
<h:commandButton
action=
"#{foodWaveView.createFoodwave()}"
value=
"#{i18n['foodwavetemplate.createFoodwave']}"
/>
</p:panel>
</h:form>
<ui:fragment>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
View file @
0335b31
...
...
@@ -3,6 +3,7 @@ package fi.insomnia.bortal.web.cdiview.shop;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.TreeSet
;
import
java.util.Vector
;
...
...
@@ -14,6 +15,7 @@ import javax.inject.Named;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.FoodWaveBeanLocal
;
import
fi.insomnia.bortal.beans.ProductBeanLocal
;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
...
...
@@ -37,6 +39,9 @@ public class FoodWaveView extends GenericCDIView {
private
Integer
templateId
;
@EJB
private
EventBeanLocal
eventbean
;
@EJB
private
ProductBeanLocal
productbeanlocal
;
private
ListDataModel
<
FoodWave
>
foodWaves
;
...
...
@@ -47,6 +52,10 @@ public class FoodWaveView extends GenericCDIView {
private
Product
currentProduct
;
public
List
<
Product
>
getProducts
()
{
return
productbeanlocal
.
getProducts
();
}
public
void
initTemplateList
()
{
if
(
super
.
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
))
{
...
...
@@ -63,8 +72,8 @@ public class FoodWaveView extends GenericCDIView {
foodWaveBean
.
createFoodWave
(
selectedFoodWave
);
return
"/food
admin/listTemplat
es"
;
initFoodwaveManagerList
();
return
"/food
manager/listFoodwav
es"
;
}
public
void
initEditTemplate
()
{
...
...
@@ -72,6 +81,8 @@ public class FoodWaveView extends GenericCDIView {
if
(
super
.
requirePermissions
(
ShopPermission
.
MANAGE_PRODUCTS
)
&&
template
==
null
)
{
template
=
foodWaveBean
.
findTemplate
(
templateId
);
// prepare to make new foodwaves
selectedFoodWave
=
new
FoodWave
();
selectedFoodWave
.
setTemplate
(
template
);
super
.
beginConversation
();
...
...
@@ -102,7 +113,7 @@ public class FoodWaveView extends GenericCDIView {
}
public
void
addProductToTemplate
()
{
template
.
getProducts
().
add
(
currentProduct
);
template
=
foodWaveBean
.
addProductToTemplate
(
template
,
currentProduct
);
createNewProductSkeleton
();
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment