java - Radio button selection with primefaces -
this question has answer here:
i have following radio button-selectable datatable:
<h:form> <p:datatable value="#{gerardocumentobacking.reclamantes}" selection="#{gerardocumentobacking.reclamante}" var="re" rowkey="#{re.id}"> <p:column headertext="id"> <h:outputtext value="#{re.id}"/> </p:column> <p:column headertext="relamantes"> <h:outputtext value="#{re.nome}"/> </p:column> <p:column selectionmode="single"/> </p:datatable> <p:commandbutton value="gerar" action="#{gerardocumentobacking.gerar}"/> </h:form>
it displays rows , radio button expected. however, it's not setting reclamante
variable, specified in selection=
attribute.
the setreclamante
method available , public:
@named @viewscoped public class gerardocumentobacking implements serializable { private static final long serialversionuid = 1l; private list<reclamante> reclamantes; private reclamante reclamante; @ejb private reclamanteservice reclamanteservice; @postconstruct public void init() { reclamantes = reclamanteservice.listar(); } public string gerar() { system.out.println(reclamante.getnome()); return null; } public reclamante getreclamante() { return reclamante; } public void setreclamante(reclamante reclamante) { this.reclamante = reclamante; } ...
using ide debugging, see setreclamante
method being called null value, gerar
method throwing nullpointerexception @ line system.out.println(reclamante.getnome());
. datatable has rowkey attribute , know it's valid because it's being displayed in datatable.
i need command button outside datatable because intend use other datatables inside h:form
.
found problem. page had <head>
tag instead of <h:head>
.
Comments
Post a Comment