webtier@glassfish.java.net

(JSF) Setting converter property in the backing PageBean:

From: <webtier_at_javadesktop.org>
Date: Tue, 06 Jan 2009 15:57:33 PST

Okay,

I am trying to create a JSF table dynamically into a JSF page, everything goes all right except for the fact that converters only de the getAsObject() but not the the getAsString

If I create the InputFields on the JSF xml page, and I set the converter attribute everything seems to go fine. But If I create the InputField in the init() or preprocessMethod of the backing PageBean the JSF Engine doesn´t call the Converters getAsString Method. Actually, It only calls the getAsString some times.

This is the Java code of the backing page Bean

        EntityMetaData emd = Introspector.getEntityMetaData(clazz);

        tableRowGroup1.getChildren().clear();
        
        int idx = 0;
        for (String s : emd.columnNames) {

            idx++;

            TableColumn tc = new TableColumn();
            tc.setId("tableColumn" + idx);
            tableRowGroup1.getChildren().add(tc);
            tc.setHeaderText(emd.columnDisplayNames.get(s));

            InputField input = new TextField();

            if (emd.types.get(s).equals(Date.class) {
                           DateTimeConverter c = new DateTimeConverter();
                           c.setPattern("dd/MM/YYYY");
                           input.setConverter(c) ;
            }

If I was to do the similar in the JSF xml Page it would work (something like this)

<webuijsf:tableColumn headerText="col1" id="tableColumn1" width="200">

                                        <webuijsf:textField converter="#{EntityEditor.dateTimeConverter2}" text="#{currentRow.value['fecha']}" id="textField3"/>
                                    </webuijsf:tableColumn>


Anybody got a clue?
[Message sent by forum member 'pablopina' (pablopina)]

http://forums.java.net/jive/thread.jspa?messageID=324407