@DataModelSelection always empty
luanfg Oct 11, 2012 10:30 AMHello,
I'm having some troubles trying to fill a @DataModelSelection.
My @DataModel works, the h:dataTable iterates fine, but when I choose a row it just reloads the page, but my selection continues empty.
I'll post my code above, please, any help will be very welcome.
Bean:
@Name("collaboration") public class CollaborationHome { @In EntityManager entityManager; @Out(required = false, value="ontologies") List<Ontology> oL; @Factory("ontologies") public void getOntologies() { oL = (List<Ontology>) entityManager.createQuery("from Ontology").getResultList(); } private Ontology ontology; public Ontology getOntology() { return ontology; } public void setOntology(Ontology ontology) { this.ontology = ontology; } @DataModel private List<Universal> universals; @DataModelSelection("universals") @Out(required=false) private Universal selectedUniversal; public void getSelectedUniversal(Universal selectedUniversal) { this.selectedUniversal = selectedUniversal; } public Universal getSelectedUniversal() { return selectedUniversal; } @Factory("universals") public void selectUniversals() { { universals = (List<Universal>)entityManager.createQuery("from Universal where unty_id=1 and onto_id = :ontoid"). setParameter("ontoid", ontology.getOntoId()). getResultList(); } } }
View:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml"> <ui:define name="body"> <div> <h:form> <rich:panel style="float:left; width:20%"> <f:facet name="header">Arvore de Conceitos:</f:facet> <h:outputLabel value="Ontologia:" ></h:outputLabel> <h:selectOneMenu id="cbOntology" value="#{collaboration.ontology}"> <s:selectItems value="#{ontologies}" var="onto" label="#{onto.ontoName}" noSelectionLabel="Selecione uma ontologia"/> <s:convertEntity /> </h:selectOneMenu> <h:commandButton id="btnLoadOntology" value="Carregar" action="submit()" /> <rich:panel rendered="#{not empty collaboration.ontology}" > <h:dataTable value="#{universals}" var="univ"> <h:column> <h:commandLink value="#{univ.univLabelpt}" /> </h:column> </h:dataTable> </rich:panel> </rich:panel> <rich:panel rendered="#{not empty selectedUniversal}"> <h:outputLabel value="a a #{selectedUniversal}" /> </rich:panel> </h:form> </div> </ui:define> </ui:composition>
As I said, the drop down menu is populated, the load button works fine, then the universal query work aswell, but when I select a universal using the commandLink nothing happens, the page reloads but selectedUniversal still empty.
I've tried the s:link also, but when the page reloads ontologies becomes null and then I get an error.
I have no idea what to do, followed every step of the book but still doesn't work =\