当我在CommandButton中单击时不会转到另一个页面

时间:2016-05-29 00:17:01

标签: java jsf commandbutton

我试图转到另一个JSF页面并将对象添加到ArrayList,使用下面的按钮,托管bean的范围在Session中,但是当我单击按钮时不会转到另一页面。

我编辑了整个代码以仅显示重要部分,因此Button位于Form中,并且托管bean的@ManagedBean和@SessionScoped anotations已到位。

XHTML

<p:commandButton value="Ingresar" action="#{cliente.formularioGo()}"/>

Ciente JSF Managed Beans

public String formularioGo() {

    entidades.Cliente cliente = new entidades.Cliente(celular, nombre, direccion);       

    listaCliente.add(cliente);//here I store objects in an ArrayList

    return "fomularioVenta";// This should take me to other JSF page called "formularioVenta"
}

1 个答案:

答案 0 :(得分:0)

首先,你的按钮应该是一种形式;

<p:form>
    <p:commandButton value="Ingresar" action="#{cliente.formularioGo()}"/>
</p:form>

你的班级应该注明;

@ManagedBean(name="cliente")
@SessionScoped
相关问题