EntityHome: No transaction is in progress
asriel Oct 16, 2009 3:01 PMHi everybody,
I'm trying to make a page that allows the user to select an entity from a DataTable and to edit the entity that has been selected through a form.
For persistence I'm using the EntityHome class generated by seam-gen (the entity is Sperimentazione and the class I use for managing the persistence is SperimentazioneHome).
Here is how I do that:
- When the user selects a row on the table, the selection listener is fired and it links the selected entity to the EntityHome instance via .setInstance()
- When the user then clicks the button to make an update, the action listener is fired and it calls the EntityHome method .update()
but then the exception  javax.faces.el.EvaluationException: javax.persistence.TransactionRequiredException: no transaction is in progress  is raised.
Here is the view:
<ice:panelGroup>
        <ice:form>
                <ice:dataTable var="_sperimentazione" value="#{sperimentazioneList.dataModel}">
                        <ice:column>
                                <ice:rowSelector value="#{_sperimentazione.selected}"
                                        selectionListener="#{testTableSelection.selectionListener}"/>
                                <f:facet name="header"><ice:outputText value="id"/></f:facet>
                                <ice:outputText value="#{_sperimentazione.id}"/>
                        </ice:column>
                        <ice:column>
                                <f:facet name="header"><ice:outputText value="idAmministrativo"/></f:facet>
                                <ice:outputText value="#{_sperimentazione.idAmministrativo}"/>
                        </ice:column>
                        <ice:column>
                                <f:facet name="header"><ice:outputText value="Tipo di sperimentazione"/></f:facet>
                                <ice:outputText value="#{_sperimentazione.clsSperimentazione.tipo}"/>
                        </ice:column>
                        <ice:column>
                                <f:facet name="header"><ice:outputText value="Descrizione"/></f:facet>
                                <ice:outputText value="#{_sperimentazione.descrizione}"/>
                        </ice:column>
                </ice:dataTable>
        </ice:form>
</ice:panelGroup>
<ice:panelGroup>
        <ice:form>
                <ice:outputLabel for="sperimId" value="id:"/>
                <ice:outputLabel id="sperimId" value="#{sperimentazioneHome.instance.id}"/> 
                <h:message for="sperimId"/> <br />
                
                <ice:outputLabel for="sperimIdAmministr" value="id Amministrativo:"/>
                <ice:inputText id="sperimIdAmministr" value="#{sperimentazioneHome.instance.idAmministrativo}"/> 
                <h:message for="sperimIdAmministr"/> <br />
         
                <ice:outputLabel for="sperimTipo" value="Tipo di sperimentazione:"/>
                <ice:selectOneMenu id="sperimTipo" value="#{sperimentazioneHome.instance.clsSperimentazione}"> 
                        <s:selectItems value="#{clsSperimentazioneList.resultList}" itemValue="#{_tipoSperimentazione}"
                                var="_tipoSperimentazione" label="#{_tipoSperimentazione.tipo}"/>
                        <s:convertEntity />
                </ice:selectOneMenu> <h:message for="sperimTipo"/> <br />
                <ice:outputLabel for="sperimDescriz" value="Descrizione:"/>
                <ice:inputText id="sperimDescriz" value="#{sperimentazioneHome.instance.descrizione}"/>
                <h:message for="sperimDescriz"/> <br />
                
                <ice:commandButton value="Modifica" action="#{sperimentazioneHome.update}"/>
        </ice:form>
</ice:panelGroup>And here is the controller that hosts the listeners:
@Name("testTableSelection")
public class TestTableSelectionAct {
        
        @In(value = "sperimentazioneList")
        private SperimentazioneList sperimList;
        @In
        private SperimentazioneHome sperimentazioneHome;
        public TestTableSelectionAct() {
        }
        
        public void selectionListener(RowSelectorEvent rsevt) {
                sperimentazioneHome.setInstance(sperimList.getDataModelSelection());            
        }
        
        @TransactionAttribute
        public void updateCommandListener(ActionEvent acevt) {
                sperimentazioneHome.update();
        }
        public SperimentazioneHome getSperimHome() {
                return sperimentazioneHome;
        }
        public void setSperimHome(SperimentazioneHome sperimHome) {
                this.sperimentazioneHome = sperimHome;
        }
}
The SEAM component SperimentazioneHome has been set with a Page scope.
Do you have any idea of how to fix this?
(The @TransactionAttribute annotation is a last minute attempt to make things working, but it changed nothing) 
Thank you.
 
     
     
     
    