im very new to JSF and JAVA too, but im working on a University project and i'm having some problems that can't solve:
basically im trying to show a button if a person is not inscribed to a course that said "inscribir" with an action to inscribe it and the oposite if is inscribed.
to check if is inscribe im trying to use materiaController.cursaMateria(materia.id)
passin the id of materia (materia is course) for check if the logued user is inscribed to that course.
Here is my code:
<h:dataTable value="#{materiaController.getAll()}" var="materia">
<h:column>
<f:facet name="header">id</f:facet>
#{materia.id}
</h:column>
<h:column>
<f:facet name="header">Nombre</f:facet>
#{materia.nombre}
</h:column>
<h:column>
<f:facet name="header">Estado</f:facet>
#{materia.estado.descripcion}
</h:column>
<c:choose>
<c:when test="#{materiaController.cursaMateria(materia.id) == false}">
<h:column>
<h:form>
<h:commandButton value="Inscribir" action="#{materiaController.inscribirMateria(materia.id)}"/>
</h:form>
</h:column>
</c:when>
<c:otherwise>
<h:column>
<h:form>
<h:commandButton value="Desinscribir" action="#{materiaController.desinscribirMateria(materia.id)}"/>
</h:form>
</h:column>
</c:otherwise>
</c:choose>
</h:dataTable>
the problem is that the method "cursaMateria" is always getting the parameter as null. btw the first colum (id) is printed with the corresponding id.
I try other ways too, but is always the same, cant send the parameter:
<c:if test="#{materiaController.cursaMateria(materia.id)}">
<h:form>
<h:commandButton value="Inscribir" action="#{materiaController.inscribirMateria(materia.id)}"/>
</h:form>
</c:if>
<c:if test="#{!materiaController.cursaMateria(materia.id)}">
<h:form>
<h:commandButton value="Desinscribir" action="#{materiaController.desinscribirMateria(materia.id)}"/>
</h:form>
</c:if>
and this way:
<h:panelGroup rendered="#{materiaController.cursaMateria(materiaId) == true}">
<h:column>
<h:form>
<h:commandButton value="Inscribir" action="#{materiaController.inscribirMateria(materiaId)}"/>
</h:form>
</h:column>
</h:panelGroup>
<h:panelGroup rendered="#{materiaController.cursaMateria(materiaId) == false}">
<h:column>
<h:form>
<h:commandButton value="Desinscribir" action="#{materiaController.desinscribirMateria(materiaId)}"/>
</h:form>
</h:column>
</h:panelGroup>
and this:
<h:column>
<h:form>
<h:commandButton value="Inscribir" action="#{materiaController.inscribirMateria(materia.id)}" rendered="#{materiaController.cursaMateria(materia.id)}" />
<h:commandButton value="Desinscribir" action="#{materiaController.desinscribirMateria(materia.id)}" rendered="#{!materiaController.cursaMateria(materia.id)}"/>
</h:form>
</h:column>
can anybody help me on this?
thank's in advance.