我试图在页面中创建一个命令按钮,但没有得到动作方法的响应。
PS:PrimeFaces中的新功能
package br.com.copagaz.inova.mobile.web.mb.frota;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
@SessionScoped
@ManagedBean(name = "CadFrota", eager = false)
public class CadFrota implements Serializable {
private static final long serialVersionUID = -5734393292489385792L;
public void teste(ActionEvent actionEvent){
System.out.println("teste: " + actionEvent.toString());
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="/pages/templates/master.xhtml">
<ui:define name="divMain">
<h:form id="frotaForm">
<p:growl showDetail="false" life="3000" />
<p:panel id="toggleable1" header="Frota" toggleable="false" closable="false" widgetVar="frotaPanel"
style="margin-bottom:20px">
<p:panelGrid style="width:90%">
<p:row>
<p:column>
<p:outputLabel>Filial:</p:outputLabel>
</p:column>
<p:column>
<p:inputText id="i10" value="" />
</p:column>
<p:column>
<p:outputLabel>Veículo:</p:outputLabel>
</p:column>
<p:column>
<p:inputText id="i11" value="" />
</p:column>
<p:column>
<p:outputLabel>Placa:</p:outputLabel>
</p:column>
<p:column colspan="3">
<p:inputText id="i12" value="" />
</p:column>
<p:column>
<p:outputLabel>Senha:</p:outputLabel>
</p:column>
<p:column colspan="3">
<p:inputText id="i121" value="" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel>Segmento:</p:outputLabel>
</p:column>
<p:column>
<p:selectOneMenu id="console" value="XXXXX" style="width:125px">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="AAA" itemValue="AAA" />
<f:selectItem itemLabel="BBB" itemValue="BBB" />
<f:selectItem itemLabel="CCC" itemValue="CCC" />
</p:selectOneMenu>
</p:column>
<p:column >
<h:panelGrid columns="2">
<h:outputText value="Massico: " />
<p:selectBooleanCheckbox value="" />
</h:panelGrid>
</p:column>
<p:column >
<h:panelGrid columns="2">
<h:outputText value="Ativo: " />
<p:selectBooleanCheckbox value="" />
</h:panelGrid>
</p:column>
<p:column colspan="2">
</p:column>
</p:row>
</p:panelGrid>
</p:panel>
<p:separator style="width:90%;height:5px;border: none;" />
<p:panelGrid columns="2" styleClass="panelgridCmdBtn">
<p:commandButton id="gravaFrota" value="Gravar" action="#{CadFrota.teste}" icon="ui-icon-bullet"/>
<p:commandButton id="gravarCheckFilial" value="Gravar Check Filial" actionListener="#{Viagem.gravarCheckFilial}" ajax="false" style="margin-left:1px" />
<p:commandButton value="Voltar" immediate="true" style="margin-left:3px" />
</p:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
错误堆叠:
引起:javax.el.PropertyNotWritableException:/pages/controle/cadastro_frota.xhtml @ 25,42 value =&#34;&#34;:设置操作的非法语法
引起:javax.el.PropertyNotWritableException:集合操作的非法语法
答案 0 :(得分:1)
inputText
中的值不应为空
<p:inputText id="i10" value="" />
相反,您必须与托管bean中的属性相关,例如:
<p:inputText id="i10" value="#{cadFrota.attribute}" />
注意强>
您必须在ManagedBean中创建属性。