Eu estou usando o repeat do richfaces: http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=repeat&skin=blueSky
nele eu tenho um panelGrid com outputpanel.. e uma lista de lookbooks... cada lookBook tem uma midia que tem um arquivo (que é um array de byte)
1- abaixo eu tenho uma lista de lojaLookBooks... ele está trazendo a lista normalmente (exceto pela imagem ^^)<h:panelGrid columns="1">
<a4j:outputPanel id="panel" layout="block" >
<a4j:repeat value="#{lojaVirtualLookBookFacesBean.lojaLookBooks}" var="look" rows="20" id="repeat">
<rich:panel style="float:left; width:220px;">
<f:facet name="header">
<h:panelGroup>
<center><h:outputText value="#{look.nome}" style="font-weight:bold" /></center>
</h:panelGroup>
</f:facet>
<center>
<a4j:mediaOutput createContent="#{lojaVirtualLookBookFacesBean.printarImg}"
mimeType="image/jpg" element="img" cacheable="false" session="true"
standby="Carregando gráfico..." value="#{look.midia.arquivo}" />
</center>
<br></br>
<h:panelGrid columns="2">
<h:outputText value="Código" style="font-weight:bold" />
<h:outputText value="#{look.codigo}" />
<h:outputText value="Coleção" style="font-weight:bold" />
<h:outputText value="#{look.colecao}" />
</h:panelGrid>
</rich:panel>
</a4j:repeat>
</a4j:outputPanel>
<a4j:outputPanel layout="block" >
<rich:datascroller for="repeat" rendered="panel"/>
</a4j:outputPanel>
</h:panelGrid>
lojaLookBooks = Ejbs.getLojaLookBook().listarLookBooks();
for(LojaLookBook i : lojaLookBooks){
System.out.println("saida: " + i.getMidia().getArquivo().length);
}
a saida foi o seguinte:
11:39:09,816 INFO [STDOUT] saida: 57244
11:39:09,816 INFO [STDOUT] saida: 10996
11:39:09,816 INFO [STDOUT] saida: 10996
11:39:09,816 INFO [STDOUT] saida: 10996
11:39:09,816 INFO [STDOUT] saida: 57244
Bom, até ai ta beleza... eu sei que cada lojaLookBook tem uma midia, e essa midia tem um arquivo populado...
obs.: o tamanho igual dos arquivos não é coincidencia.... são 2 imagens diferentes, e eu conferi e realmente tem os tamanhos informados!
<a4j:mediaOutput createContent="#{lojaVirtualLookBookFacesBean.printarImg}"
mimeType="image/jpg" element="img" cacheable="false" session="true"
standby="Carregando gráfico..." value="#{look.midia.arquivo}" />
public void printarImg(OutputStream out, Object data) throws IOException{
byte[] b = (byte[]) data;
System.out.println("b" + b);
}
CASO eu retire o value="#{look.midia.arquivo}" ai ele passa pelo printarImg escrevendo: bnull
não entendo... quando eu passo o arquivo(imagem) ele não passa pelo método... e quando eu não passo o arquivo ele passa pelo método e obviamente me fala que está nulo
tópicos que me ajudaram em partes:
http://www.guj.com.br/java/129899-a4jmediaoutput---como-eu-uso-ele-para-exibir-uma-imagem-do-discobd
http://stackoverflow.com/questions/7677207/how-to-use-a4jmediaoutput-correctly-for-displaying-images
http://javafree.uol.com.br/topic-880844-Erro-usando-<a4j-mediaOutput-com-imagem-de-tamanho-grande.html
http://www.guj.com.br/java/133633-problemas-com-a4jmediaoutput-jsf