1 Reply Latest reply on Apr 16, 2009 7:16 PM by Arbi Sookazian

    Factory method is not firing

    Arbi Sookazian Master

      Seam 2.0.2-FP


           private List<Object[]> populateParametersList = new ArrayList<Object[]>();

           public void populateParameters(){...}


      <a4j:form id="editParamFormTest">     
                     <rich:dataTable value="#{populateParametersList}" var="param">               
                                    <f:facet name="header"><h:outputText value="row count"/></f:facet>     
                                    <h:outputText value="#{populateParametersList.getRowCount()}"/>
                                    <f:facet name="header"><h:outputText value="Hierarchy"/></f:facet>     
                                    <h:outputText value="#{param[0].caption}"/>
                                    <f:facet name="header"><h:outputText value="Hierarchy"/></f:facet>     
                                    <h:inputText value="#{param[1].paramValue}"/>
                                    <f:facet name="header"><h:outputText value="Hierarchy"/></f:facet>     
                                    <h:outputText value="#{param[0].dataType}"/>

      Also been trouble-shooting this scenario where the dataTable is populated by data from a non-trivial ListDataModel (the createQuery() is based on more than one entity class, so I have to deal with Object[]).

      I have got this working for a similar situation in another Seam project but that one did not use @Factory.  The funny thing is the @Factory was working for a while this morning so not sure what triggered this.

      The problem is the populateParameters() is not executing when the JSF is rendered.  The only logical reason this could happen is if the instance variable for the List is not null.  But the SFSB is conversation-scoped so when I launch a new tab in IE to test, this concern should be irrelevant (i.e. new conversation per tab/window).

      Here is the entire backing bean method of concern:

           public void populateParameters(){
                populateParametersList = entityManager.createQuery("select lpm, lvp "+
                                                                                 " from ListValue lv, ListValueParam lvp, ListParamMetaData lpm "+
                                                                                 " where lv.listValueId = lvp.listValue.listValueId "+
                                                                                 " and lv.list.listId = lpm.list.listId "+
                                                                                 " and lpm.paramName = lvp.paramName "+
                                                                                 " and lvp.listValue.listValueId = 4 "+
                                                                                 " and lv.list.listId = 2")
                if (populateParametersList != null && populateParametersList.size() > 0) {
                     Object[] objArray1 = (Object[])populateParametersList.get(0);
                     Object[] objArray2 = (Object[])populateParametersList.get(1);
                     ListParamMetaData lpm1 = (ListParamMetaData)objArray1[0];
                     ListValueParam lvp1 = (ListValueParam)objArray1[1];
                     log.info("lpm1.caption = "+lpm1.getCaption());
                     log.info("lvp1.paramValue = "+lvp1.getParamValue());
                     log.info("lpm1.dataType = "+lpm1.getDataType());
                     ListParamMetaData lpm2 = (ListParamMetaData)objArray2[0];
                     ListValueParam lvp2 = (ListValueParam)objArray2[1];
                     log.info("lpm2.caption = "+lpm2.getCaption());
                     log.info("lvp2.paramValue = "+lvp2.getParamValue());
                     log.info("lpm2.dataType = "+lpm2.getDataType());
                log.info("populateParametersList.size() = "+populateParametersList.size());

      Before when the method was being called, the data was not rendering in the JSF/dataTable (but I guess that's another problem).