0
votes

I'm trying to create a command button in a page but getting no response from the action method.

PS: new in 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>

Error stack:

Caused by: javax.el.PropertyNotWritableException: /pages/controle/cadastro_frota.xhtml @25,42 value="": Illegal Syntax for Set Operation
Caused by: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation

1

1 Answers

1
votes

The value in inputText should not be empty

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

Instead you have to related to a property in your managed bean for example:

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

Note

You have to create your attribute in your ManagedBean.


Take a look in Primeface show cases, about inputText