Pessoal,
Tenho uma lista em uma página JSF 2 + RichFaces 4 com itens que devem ser movidos para o topo da lista, uma posição acima, uma abaixo, última posição ou removidos da lista. A idéia é que ao clicar na imagem que representa a ação, deve ser passado para o bean uma referência da posição do item na lista.
A tabela está definida como:
<rich:panel id="batchPanel">
<table border="1" class="dr-table rich-table" width="100%">
<a4j:repeat value="#{assemblyMB.batchLDM}" var="batch" rowKeyVar="row">
<tr>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>
<a4j:commandLink action="#{assemblyMB.moveBatchToTop[row]}" render="batchPanel">
<h:graphicImage value="/images/icons/arrow_top.png" />
</a4j:commandLink>
<a4j:commandLink action="#{assemblyMB.moveBatchUpOnePosition[row]}" render="batchPanel">
<h:graphicImage value="/images/icons/arrow_up.png" />
</a4j:commandLink>
<a4j:commandLink action="#{assemblyMB.moveBatchDownOnePosition[row]}" render="batchPanel">
<h:graphicImage value="/images/icons/arrow_down.png" />
</a4j:commandLink>
<a4j:commandLink action="#{assemblyMB.moveBatchToBottom[row]}" render="batchPanel">
<h:graphicImage value="/images/icons/arrow_bottom.png" />
</a4j:commandLink>
<a4j:commandLink action="#{assemblyMB.deleteBatch[row]}">
<h:graphicImage value="/images/icons/delete.png" />
</a4j:commandLink>
</td>
</tr>
</table>
</rich:panel>
public void moveBatchToTop(int batchPos) {
System.out.println("moveBatchToTop: " + batchPos);
bservice.reorderBatchList(batchList.get(batchPos);
}
public void moveBatchUpOnePosition(int batchPos) {
System.out.println("moveBatchUpOnePosition: " + batchPos);
bservice.reorderBatchList(batchList.get(batchPos), (batchPos - 1));
}
public void moveBatchDownOnePosition(int batchPos) {
System.out.println("moveBatchDownOnePosition: " + batchPos);
bservice.reorderBatchList(batchList.get(batchPos), (batchPos + 1));
}
public void moveBatchToBottom(int batchPos) {
System.out.println("moveBatchToBottom: " + batchPos);
bservice.reorderBatchList(batchList.get(batchPos), batchList.size() + 1);
}
public void deleteBatch(int batchPos) {
batchList.remove(batchPos);
}
Como eu posso resolver isso?
Obrigado desde já,
Gustavo