簡體   English   中英

JSF Primefaces命令按鈕

[英]JSF Primefaces commandButton

我正在嘗試在頁面中創建命令按鈕,但是動作方法沒有響應。

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 =“”:集合操作的語法不正確
原因:javax.el.PropertyNotWritableException:集合操作的語法非法

inputText的值不能為空

<p:inputText id="i10" value="" />

相反,您必須與托管Bean中的屬性相關,例如:

<p:inputText id="i10" value="#{cadFrota.attribute}" />

注意

您必須在ManagedBean中創建屬性。


看一下關於inputText的 Primeface展示案例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM