1
<p:dataList value="#{simuladoBean.questoes}" var="q" type="unordered"
rowIndexVar="qi" itemType="none" paginator="true" rows="1"
styleClass="paginated">
<h:panelGrid columns="2" style="color:#000;"
rendered="#{q.tipo == simuladoBean.certoErrado}">
<p:outputLabel for="resposta" value="Resposta: " />
<p:selectOneRadio id="resposta" value="#{simuladoBean.resposta}"
style="color:black;width:auto;">
<p:ajax listener="#{simuladoBean.processaResposta}" />
<f:selectItem itemLabel="Certo" itemValue="Certo | #{q.id}" />
<f:selectItem itemLabel="Errado" itemValue="Errado | #{q.id}" />
</p:selectOneRadio>
</h:panelGrid>
</p:dataList>
My Managedbean is like @Named
and @ViewScoped
.
import javax.inject.Named;
import javax.faces.view.ViewScoped;
The code works normally though, when moving from one page to another (Pagination), when I return to the previous page the radiobutton
is cleared, the ViewScoped
just doesn’t work for the SelectOneRadio
.
How do I keep the Selectoneradio
as viewScoped
, so that if you mark for example right on the first page when passing to the second and returning to the first the 'right' is still marked?
you need to leave Viewscoped even? Maybe Sessionscoped will solve your problem.
– Phelipe Galiotti
Even with the Sessionscoped it doesn’t work. All Managedbean attributes are staying in the view scope, just this <f:selectoneRadio that is not.
– Maroni
Maroni tempted me to a detail, did you see the import? in my classes I usually import the "import javax.faces.bean.Viewscoped;" tries to change the import, leaving Viewscoped even and tell me if it worked. Hugs
– Phelipe Galiotti
Yes, the Imports are correct, I left them there on the question. import javax.inject.Named; import javax.faces.view.Viewscoped;
– Maroni
Exactly, in my last comment I gave the idea to change the import that is "javax.faces.VIEW.Viewscoped" to "javax.faces.BEAN.Viewscoped"
– Phelipe Galiotti