Reputation: 1631
I have a form submited with ajax which normally must execute the removeArticle function. The problem is when I'm clicking the button, the function is never called and a beautiful error message is returned (displayed with alert) telling me : "serverError: class javax.ejb.NoSuchEJBException CORBA OBJECT_NOT_EXIST 9998 Maybe; nested exception is: org.omg.CORBA.OBJECT_NOT_EXIST: vmcid: 0x2000 minor code: 1806 completed: Maybe". I'm using in another part a similar (almost) form for adding a cocktail. When I place my removeArticle calling into this other form it's executed ...
My code is the following :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="template/common/commonLayout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:component="http://java.sun.com/jsf/composite/component"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core">
<ui:define name="title">Panier</ui:define>
<ui:define name="content">
<c:if test="#{dataManagedBean.cartLength > 0}">
<div id="cart-component">
<h2>Panier</h2>
<div class="well well-small">
<ul class="thumbnails">
<ui:repeat value = "#{dataManagedBean.cartContent}" var = "item" varStatus="status">
<h:form id="cocktail-panier">
<div class="media">
<div class="pull-left media-object span2">
<div class="text-center">
<img src="resources/img/#{item.photoURIName}.#{item.photoURIExt}"
alt="Photo du cocktail #{item.name}"/>
</div>
</div>
<div class="media-body">
<h3 class="media-heading">
#{item.name}
</h3>
<div class="well well-small">
<ul class="thumbnails">
<ui:repeat value="#{dataManagedBean.getCocktailBeverages(dataManagedBean.getCocktailFull(item))}" var="bev" varStatus="status1">
<component:ShowBeverageComponent item="#{bev}"/>
</ui:repeat>
<div class = "span2 right">Quantité : #{dataManagedBean.getQuantityForCocktailInCart(item)}</div><br />
<div class = "span2 right">Prix unitaire : #{item.price} €</div><br />
<div class = "span2 right">Prix total : #{item.price * dataManagedBean.getQuantityForCocktailInCart(item)} €</div>
</ul>
<h:commandButton
title=""
value="Supprimer les articles "
type="button"
actionListener="#{dataManagedBean.removeArticle(item)}">
<f:ajax execute="@form" render="@all" />
</h:commandButton>
<h:inputText id="qty" maxlength="3" value="#{dataManagedBean.qty}" styleClass="input-mini" />
</div>
</div>
</div>
</h:form>
</ui:repeat>
</ul>
</div>
</div>
</c:if>
<li class="thumbnail">
<div class="totalPanier">
<div class="total-cart"> Total: #{dataManagedBean.getCartPrice()}€</div>
<h:button class="totalPanier-button"
image="#{resource['img:btn_valider.png']}"
alt="valider" outcome="Form.xhtml" rendered="#{dataManagedBean.cartLength > 0}">
</h:button>
<div class="clear"></div>
</div>
</li>
</ui:define>
</ui:composition>`
Upvotes: 0
Views: 162
Reputation: 1631
The problem was the nested ui:repeat ! I replaced my 2 ui:repeat by 2 c:forEach and everything is working fine !
Upvotes: 0
Reputation: 2476
HTML Elements IDs shouldn't have "-" like in your: <h:form id="cocktail-panier">
AND <div id="cart-component">
, this causes Problems in js. replace all these ids with underscore cart_component, or use Java Style like cartComponent
use commandButton like this:
<h:commandButton
title=""
value="Supprimer les articles "
type="button">
<f:ajax execute="@form" render="@all" listener="#{dataManagedBean.removeArticle(item)}"/>
</h:commandButton>
Ajax-Listener method like:
public final void removeArticle(final YourItemClass item){
you use jstl components. JSTL will run on build time, and if your Bean is requestScoped, then the render / action of commandbutton will not fire.
change your bean (if not) to ViewScope or SessionScope, and use rendered instead of <c:if...
somthing like:
replace this <c:if test="#{dataManagedBean.cartLength > 0}">
width this:
<h:panelGroup display="block" rendered="#{dataManagedBean.cartLength > 0}">
.....
ADDITIONALY: you use templates. your template should somthing like this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:head>
<meta charset="UTF-8" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="stylesheet.css"/>
<title>${pageTitle}</title>
In your XHTML Page where you use this template, you don't need to declare XML or HTML docType, and use your template directly:
<ui:composition template="template/common/commonLayout.xhtml"
....
Use <h:head>
in your template instead of the <head>
, else JSF will not include the jsf.js in the document
Upvotes: 1