• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to populate image through HtmlGraficImage object in the backing bean?

 
prasad kakani
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I would like to populate the datatable , 4 column vlues. one column has image file. onclick of the image , i need to invoke some backing bean which poulates the table. while populating i need to set an image to datatable in the second column. how this can be done.? can you please help me out
?
Thanks
Prasad
 
Louis Bros
Ranch Hand
Posts: 54
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm not sure what you mean by "populate image through HtmlGraficImage". From what it seems like you're describing, PrimeFaces' 'FileUpload' might work for you.
 
Pondurai Singh
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer this coding koders.com/java/fid9B9AFD404F84FAC896DDA0D666A5DBB050E9724D.aspx. In this code binding method witch constructs an UIComponent Tree for JSF page and also Used for dynamic dataTable facility. That will helps you.
 
prasad kakani
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for your reply ..

@Louis,
what i meant is , i need to set an image to HtmlGraphicGmage instance. like the way we set input txt value to in bcaking bean,

//Datatable
populatedatatable(){
HtmlDataTable dataTable = new HtmlDataTable();
dataTable.setBorder(1);
dataTable.setValueExpression("value",createValueExpression("#{populateBean.dataList}", List.class));
dataTable.setVar("dataItem");
// Create <h:column> for 'ID' column.
HtmlColumn idColumn = new HtmlColumn();
dataTable.getChildren().add(idColumn);

// Create header <f:facet name="header"> of 'ID' column.
HtmlOutputText idHeader = new HtmlOutputText();
idHeader.setValue("ID");
// add header to column
idColumn.setHeader(idHeader);
// Create <hutputText value="#{dataItem.id}"> for the body of 'ID' column.
HtmlOutputText idOutput = new HtmlOutputText();
idOutput.setValueExpression("value", createValueExpression("#{dataItem.id}", String.class));
//add output text to column.
idColumn.getChildren().add(idOutput);
}

private ValueExpression createValueExpression(String valueExpression, Class<?> valueType) {
FacesContext facesContext = FacesContext.getCurrentInstance();
return facesContext.getApplication().getExpressionFactory().createValueExpression(
facesContext.getELContext(), valueExpression, valueType);
}
 
prasad kakani
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the answer..

This is the way we can set an image to htmlgraficimage instance.

HtmlGraphicImage graphicimage = new HtmlGraphicImage();
graphicimage.setUrl("./images/minusfinal.jpg");
graphicimage.setValueExpression("value", createValueExpression(graphicimage.getUrl(), String.class));
nameColumn.getChildren().add(graphicimage);
 
Tim Holloway
Saloon Keeper
Posts: 18300
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I'm reading this correctly, you're attempting to use arcane JSF code to dynamically create a JSF component tree modification to display an image using an output text tag.

I doubt you need all this JSF-specific code. Most of us can get by with straight View Definition Language XML using an image tag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic