* Shop bean
*/
@Inject
- private ShopWebController controller;
+ private ShopWebController shopController;
/////////////////////// Properties /////////////////////
/**
category.setCategoryTitle(this.getCategoryTitle());
// Deligate to remote bean
- this.categoryBean.doAdminAddCategory(category);
+ Category updatedCategory = this.categoryBean.doAdminAddCategory(category);
// Also send it to the controller bean
- this.controller.addCategory(category);
+ this.shopController.addCategory(updatedCategory);
} catch (final CategoryTitleAlreadyUsedException | CannotAddCategoryException ex) {
// Continue to throw
throw new FaceletException(ex);
/**
* House number
*/
- private Long houseNumber;
+ private Short houseNumber;
/**
* Phone number
}
@Override
- public Long getHouseNumber () {
+ public Short getHouseNumber () {
return this.houseNumber;
}
@Override
- public void setHouseNumber (final Long houseNumber) {
+ public void setHouseNumber (final Short houseNumber) {
this.houseNumber = houseNumber;
}
*
* @return the houseNumber
*/
- public Long getHouseNumber ();
+ public Short getHouseNumber ();
/**
* House number
*
* @param houseNumber the houseNumber to set
*/
- public void setHouseNumber (final Long houseNumber);
+ public void setHouseNumber (final Short houseNumber);
/**
* Phone number
/**
* Remote bean for products
*/
- private final AdminProductSessionBeanRemote productBean;
+ private final AdminProductSessionBeanRemote productRemoteBean;
////////////////////// Bean injections ///////////////////////
/**
* Shop bean
*/
@Inject
- private ShopWebController controller;
+ private ShopWebController shopController;
/////////////////////// Properties /////////////////////
/**
Context context = new InitialContext();
// Try to lookup the bean
- this.productBean = (AdminProductSessionBeanRemote) context.lookup("ejb/stateless-admin-product"); //NOI18N
+ this.productRemoteBean = (AdminProductSessionBeanRemote) context.lookup("ejb/stateless-admin-product"); //NOI18N
} catch (final NamingException e) {
// Throw it again
throw new FaceletException(e);
product.setProductTitle(this.getProductTitle());
// Call bean
- this.productBean.doAdminAddProduct(product);
+ Product updatedProduct = this.productRemoteBean.doAdminAddProduct(product);
// Add to shop controller
- this.controller.addProduct(product);
+ this.shopController.addProduct(updatedProduct);
// Set all to null
this.setProductAvailability(Boolean.FALSE);
@Override
public List<Product> getAllProducts () throws FaceletException {
// Call bean
- return this.productBean.getAllProducts();
+ return this.productRemoteBean.getAllProducts();
}
@Override
import javax.naming.NamingException;
import org.mxchange.jshopcore.model.category.Category;
import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote;
-import org.mxchange.jshopcore.model.category.ProductCategory;
import org.mxchange.jshopcore.model.product.Product;
import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
import org.mxchange.pizzaapplication.beans.AbstractWebBean;
@Override
public List<Category> getAllCategoriesParent () throws FaceletException {
// Get regular list
- List<Category> list = new LinkedList<>();
-
- // Create null category
- Category nullCategory = new ProductCategory();
- nullCategory.setCategoryTitle(this.getMessageStringFromKey("ADMIN_CATEGORY_HAS_NO_PARENT")); //NOI18N
-
- // Add it
- list.add(nullCategory);
-
- // Add all
- list.addAll(this.getAllCategories());
+ List<Category> list = new LinkedList<>(this.getAllCategories());
// Return it
return list;
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
- <h:selectOneMenu class="select" id="parentId" value="#{admin_product.productCategory}" required="true" requiredMessage="#{msg.ADMIN_CATEGORY_MUST_BE_SELECTED}">
- <f:selectItems value="#{controller.allCategories}" var="cat" itemValue="#{cat.categoryId}" itemLabel="#{cat.categoryTitle}" />
- <f:validateLongRange for="parentId" minimum="0" maximum="1000" />
+ <h:selectOneMenu class="select" id="productCategory" value="#{admin_product.productCategory}" required="true" requiredMessage="#{msg.ADMIN_CATEGORY_MUST_BE_SELECTED}" converter="category">
+ <f:selectItems value="#{controller.allCategories}" var="cat" itemValue="#{cat}" itemLabel="#{cat.categoryTitle}" />
+ <f:validateLongRange for="productCategory" minimum="0" maximum="1000" />
</h:selectOneMenu>
</ui:composition>
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
- <h:selectOneMenu class="select" id="parentId" value="#{admin_category.parentCategory}" required="true" requiredMessage="#{msg.ADMIN_PARENT_CATEGORY_CANNOT_BE_NULL}">
+ <h:selectOneMenu class="select" id="parentCategory" value="#{admin_category.parentCategory}">
+ <f:selectItem itemValue="" itemLabel="#{msg.ADMIN_CATEGORY_HAS_NO_PARENT}" />
<f:selectItems value="#{controller.allCategoriesParent}" var="parent_category" itemValue="#{parent_category.categoryId}" itemLabel="#{parent_category.categoryTitle}" />
</h:selectOneMenu>
</ui:composition>