我提出了以下问题。完成后单击对话框中的按钮(弹出),actionListener 属性不起作用,即不调用 Backingbean。
奇怪的是,在 PrimeFaces 展示的版本中,此代码完美运行,只有移动设备失败。另一个好奇是javascript函数按钮是成功的,是什么让我觉得是手机版ajax的问题这里是代码
<pm:content>
<h:form id="productForm">
<p:dataList value="#{productoMB.productList}" var="pro"
paginator="true" id="productDL">
<f:facet name="header">Menu de comidas</f:facet>
<p:panel header="#{pro.name}" style="text-align:center">
<h:panelGrid columns="1" style="width:100%">
<p:commandLink update=":homeFirst:productForm:productDetail"
oncomplete="PF('productDialog').show()" title="Ver Detalles">
<h:graphicImage library="images" name="#{pro.path}" width="320px"
height="120px" />
<f:setPropertyActionListener value="#{pro}"
target="#{productoMB.productSelect}" />
</p:commandLink>
</h:panelGrid>
</p:panel>
</p:dataList>
<p:dialog header="Detalle Plato" widgetVar="productDialog"
modal="true" showEffect="fade" hideEffect="fade" resizable="false">
<p:outputPanel style="text-align:center;">
<p:panelGrid id="productDetail" columns="2"
rendered="#{not empty productoMB.productSelect}"
columnClasses="label,value">
<f:facet name="header">
<p:graphicImage library="images"
name="#{productoMB.productSelect.path}.jpg" width="100px"
height="100px" />
</f:facet>
<h:outputText value="Nombre:" />
<h:outputText value="#{productMB.productSelect.name}" />
<h:outputText value="Precio" />
<h:outputText value="#{productoMB.productSelect.price}" />
<h:outputText value="Detalles:" />
<h:outputText value="#{productoMB.productSelect.description}" />
<h:outputText value="Cantidad:" />
<h:inputText value="#{productoMB.quantity}" required="true">
<!-- <p:ajax update="costo" listener="#{empMB.calcularPrecioTotal}" /> -->
<!-- <f:validateDoubleRange minimum="0" maximum="200" /> -->
</h:inputText>
<h:outputText value="Total a Pagar:" />
<!-- <h:outputText id="costo" value="#{empMB.precioTotal}" /> -->
<p:commandButton value="Volver"
onclick="PF('productDialog').hide()"></p:commandButton>
<h:form>
<p:commandButton value="Agregar al carrito"
onclick="PF('carDialog').hide()" icon="ui-icon-cart" actionListener="#{productoMB.addCart}">
</p:commandButton>
</h:form>
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</pm:content>
这是一个backingbean
package ar.com.as.presentation.mb;
import java.util.ArrayList;
import java.util.List;
import ar.com.as.business.bo.interfaces.GenericBO;
import ar.com.as.business.bo.patterns.FactoryFacade;
import ar.com.as.model.Cart;
import ar.com.as.model.Product;
public class ProductMB {
private List<Product> productList;
private Product productSelect;
private int quantity;
private List<Cart> cartList;
public ProductMB() {
productList = new ArrayList<Product>();
cartList = new ArrayList<Cart>();
findAllProduct();
}
public void findAllProduct() {
GenericBO<Product> productBO = FactoryFacade.createFacade("facade")
.getInstance().create("product");
productList = productBO.findAll();
}
public void addCart() {
System.out.println("se agrego al carrito");
}
// Getters+setters.
}
任何想法 Como esta 问题已解决。或者如何在没有 ajax 的情况下运行方法 addcart 。从已经非常感谢你了。问候,圣地亚哥