2
I have a page with some iteration loops inside my page JSF
and then I’d like to know how I do to after each loop clear that attribute from the page.
To be clear, I know that when rendering a page sometimes a method is called a few times, so one creates a lista
for example and fills it if it is empty.
public List<Long> buscarLojas() {
if (NullUtil.isNull(this.idsLoja)) {
this.idsLoja = new ArrayList<Long>(this.getPojo().getRelatorioExtratoLojista().keySet());
}
return idsLoja;
}
In the above code is done, but I would like to know if it has how to clear after loop execution ui:repeat
Follow my page code, this omitted most columns.
<ui:param name="lojas" value="#{bean.buscarLojas()}"/>
<ui:repeat var="loja" value="#{lojas}">
<ui:param name="filiais" value="#{bean.buscarFilial(loja)}" />
<ui:repeat var="filial" value="#{filiais}">
<ui:param name="atendentes" value="#{bean.buscarAtendente(loja, filial)}" />
<ui:repeat var="atendente" value="#{atendentes}">
<ui:param name="propostasStatus" value="#{bean.buscarPropostaStatus(loja, filial, atendente)}" />
<ui:repeat var="propostaStatus" value="#{propostasStatus}">
<ui:param name="objetos" value="#{bean.buscarObjeto(loja, filial, atendente, propostaStatus)}" />
<p:panelGrid
id="panelGridRelatorioExtratoLojista"
styleClass="panelGridCenter gridNoBackground"
style="width: 100%; white-space:nowrap;">
<f:facet name="header">
<p:row>
<p:column styleClass="columnLeft" colspan="12">
<p:outputLabel value="#{bean.criarTituloTabela(objetos[0][4], objetos[0][5], objetos[0][6], objetos[0][3])}"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel value="Classificação"/>
</p:column>
</p:row>
</f:facet>
<ui:repeat var="objeto" value="#{objetos}">
<p:row>
<p:column>
<p:outputLabel value="#{objeto[7]}"/>
</p:column>
</ui:repeat>
</p:panelGrid>
<br/>
</ui:repeat>
</ui:repeat>
</ui:repeat>
</ui:repeat>
The structure that houses the data is this:
private Map<Long, Map<Long, Map<Long, Map<Integer, List<Object>>>>> map;
Hi Macario, could you clarify what you mean by clean? It seems that you are building a list of Ids on top of the keys of a map. Would you like to clear the map?
– Anthony Accioly
@Anthonyaccioly I updated the code, as I said in the text, a lot of the times I will be accessing the methods on the page. And I would like every call of the methods on the page, to move to a list, as soon as I finish the loop on that list, to clear the list to get the new content, that has more to do with the performance on the page rendering issue
JSF
.– Macario1983
Hello Macario, from what I understand you want to wear one
map.clear()
After you built the list, would that solve the problem? Off the main subject, but couldn’t its four nested map structure be replaced by something more object-oriented? In Java it’s always strange to see something like this.– Anthony Accioly
Face you got it wrong, it would be the following, imagine the following situation, you have a component that loads a list from the database data. Now imagine that when rendering this component, this method will be called for example 2 or 3 times, so it will be called 3 times in the bank, so I use the list not to overload, understood?
– Macario1983
On the subject of object orientation, is that the object in question has these attributes but the way this table is built made me create this structure.
– Macario1983
Opa Macario. I think what is making your question get confused is the design. It seems that your code is reversing the MVC, the view smart is calling various methods nested in the bean to build the data, now you want the view also notify the bean after the last
<ui:repeat
to clear the listidLojas
. That’s it?– Anthony Accioly
Let’s go continue this discussion in chat.
– Macario1983
@Anthonyaccioly see the chat please
– Macario1983