Help calendar richfaces

2 respostas
fabioebner

Pessoal estou com o seguinte problema utilizando o calendar do richfaces:

15/01/2008 10:32:41 com.sun.faces.lifecycle.RenderResponsePhase execute INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed. sourceId=j_id_jsp_1623102717_1:j_id_jsp_1623102717_6[severity=(ERROR 2), summary=(javax.faces.el.PropertyNotFoundException: javax.el.PropertyNotFoundException: Property 'dataAnseio' not writable on type java.lang.String), detail=(javax.faces.el.PropertyNotFoundException: javax.el.PropertyNotFoundException: Property 'dataAnseio' not writable on type java.lang.String)]
o meu jsp esta assim:
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view>
<html>
    <head>
        <title>Untitled Document</title>
        <style type="text/css">
            <!--
            body {
                margin-left: 0px;
                margin-top: 0px;
                margin-right: 0px;
                margin-bottom: 0px;
            }
            -->
        </style>
        <link href="../css/folha.css" rel="stylesheet" type="text/css" />
</head>
    
    <body>
        <h:form>
        <table width="780" align="center" cellpadding="0" cellspacing="0" border="0">
            <tr>
                <th width="170" rowspan="2" valign="top" scope="col"><img src="../imagens/topo_logo.jpg" width="170" height="190" /></th>
                <th width="610" height="57" colspan="2" valign="top" background="../imagens/topo.jpg" scope="col"><table width="100%" height="55" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <th height="19" scope="col">&nbsp;</th>
                            <th scope="col">&nbsp;</th>
                            <th scope="col">&nbsp;</th>
                        </tr>
                        <tr>
                            <th colspan="3" scope="row">&nbsp;</th>
                        </tr>
                    </table>
                </th>
            </tr>
            <tr>
                <td colspan="2" valign="top">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="fonte">
                        <tr>
                            <td colspan="2" class="fonte"><strong>Cadastro de Anseios da Popula&ccedil;&atilde;o a</strong></td>
                        </tr>
                        <tr>
                            <td colspan="2">&nbsp;</td>
                        </tr>
                        
                        <tr>
                          <td height="25">Pessoa:</td>
                          <td><h:selectOneMenu id="selectPessoa"
                                                         value="#{anseio.codigoPessoa}">
                                            <f:selectItems
                                                value="#{montaCombo.pessoa}" />
                                        </h:selectOneMenu></td>
                        </tr>
                        <tr>
                          <td width="25%" height="25">Descri&ccedil;&atilde;o:</td>
                          <td width="75%"><h:inputText value="#{anseio.descricaoAnseio}" id="descricao" styleClass="borda_cinza" /></td>
                        </tr>
                        <tr>
                            <td height="25">Data:</td>
                          <td>
                              <a4j:outputPanel id="calendario" layout="block">
                                  <rich:calendar value="#{anseio.dataAnseio}"
                                  popup="true"
                                  datePattern="dd/MM/yyyy" 
                                  showApplyButton="false"/>
                              </a4j:outputPanel>
                        </td>
                      </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td><h:commandButton value="Cadastrar" action="#{anseio.inserir}"/> </td>
                        </tr>
                    </table>
              </td>
            </tr>
        </table> 
        </h:form>
    </body>
</html>
</f:view>
e o meu bean esta assim:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.dnasolution.bean;

import br.com.dnasolution.db.Conexao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.GregorianCalendar;

/**
 *
 * @author Fabio Ebner
 */
public class AnseioBean {

    private int codigoPessoa = 0;
    private String descricaoAnseio = null;
    private GregorianCalendar  dataAnseio = null;
    static final String SUCESSO_INSERIR = "success";
    static final String FALHA_INSERIR = "failure";
    static String retorno = null;
    Connection con = null;
    PreparedStatement pStm = null;

    /** Creates a new instance of AnseioBean */
    public AnseioBean() {
        dataAnseio = new GregorianCalendar();
    }

    public String inserir() {
        try {
            con = Conexao.getInstancia().conectarDb();
            pStm = con.prepareStatement("INSERT INTO tb_anseio (cd_pessoa,ds_anseio) VALUES (?,?)");
            pStm.setInt(1,codigoPessoa);
            pStm.setString(2,descricaoAnseio);
            System.out.println(pStm.toString());
    //        pStm.setDate(3,dataAnseio);
            
            pStm.execute();
            retorno = SUCESSO_INSERIR;
            con.commit();
            con.close();
            pStm.close();
        } catch (Exception e) {
            retorno = FALHA_INSERIR;
        }
        return retorno;
    }

    public int getCodigoPessoa() {
        return codigoPessoa;
    }

    public void setCodigoPessoa(int codigoPessoa) {
        this.codigoPessoa = codigoPessoa;
    }

    public String getDescricaoAnseio() {
        return descricaoAnseio;
    }

    public void setDescricaoAnseio(String descricaoAnseio) {
        this.descricaoAnseio = descricaoAnseio;
    }

    public void setDataAnseio(GregorianCalendar dataAnseio) {
        this.dataAnseio = dataAnseio;
    }

 public String getDataAnseio(){   
        return dataAnseio.get(GregorianCalendar.DATE)+"/"+(dataAnseio.get(GregorianCalendar.MONTH)+1)+"/"+dataAnseio.get(GregorianCalendar.YEAR);   
    }   


    


}

qual o tipo q o calendar me retorna?? obrigado

2 Respostas

P

o calendar retorno o tipo Date

att

mfcn2000

fabioebner,

vc não precisa alterar o tipo do atributo do seu managed bean para Date e perder as facilidades que o Calendar proporciona, vc só precisa mudar o value do rich:calendar para #{anseio.dataAnseio.time}.

Espero que resolva.

Abraço.

Criado 15 de janeiro de 2008
Ultima resposta 24 de out. de 2008
Respostas 2
Participantes 3