1
Get a page that gets a stop.
<f:metadata>
<f:viewParam name="id" value="#{MyBean.MyObject.id}" />
<f:event type="preRenderView" listener="#{MyBean.exibir}" />
</f:metadata>
<c:set var="myobject" value="#{MyBean.MyObject.id}" scope="session"/>
<h:form id="tabelaLancamentoid">
<p:dataTable id="dataid" var="data" value="#{MyBean.All}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
paginator="true" rows="10" style="margin-bottom:20px">
<p:column headerText="Nome">
<h:outputText value="#{data.nome} " />
</p:column>
</p:dataTable>
</h:form>
Mybean
@Inject
FansubberDao dao;
private MyObjetc myObject = new MyObjetc();
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
public void exibir(){
if(myObject.getId()!=null)
myObject = dao.getMyObjetc(myObject.getId());
}
public List<MyObjetc> getAll(){
Integer id = (Integer)session.getAttribute("myobject");
return dao.getAll(id);
}
Page normally displays and mounts the table every time you change the ID parameter. EX: if the table takes 50 record and starts browsing the pages, simply add all.
I solved part of the problem by asking. c:if in c:set, paging works normally, problem and that now if I exchange the id parameter that arrives in the page for another, it gets the old list.
<c:if test="#{sessionScope.myobject == null}">
<c:set var="myobject" value="#{MyBean.MyObject.id}" scope="session"/>
</c:if>
I’m looking for a solution to this problem.
If you take c:if the paging does not work correctly, however every time you change the ID the new table comes. If you put c:if the paging works, but the table does not change.
I’d have to remove the myobject variable from the session or null it, I don’t know how. I tried to work with Viewscope but the paging does not work properly. I would like a solution that solves both problems at the same time.