| Author |
how to populate image through HtmlGraficImage object in the backing bean?
|
prasad kakani
Ranch Hand
Joined: Jul 15, 2008
Posts: 59
|
|
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
Joined: Jun 03, 2011
Posts: 54
|
|
|
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.
|
OCA7
|
 |
Pondurai Singh
Ranch Hand
Joined: Jun 27, 2011
Posts: 32
|
|
|
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.
|
Software Developer, Oracle Java Certification Training Labs at EPractize Labs
OCPJP 7 | OCAJP 7
|
 |
prasad kakani
Ranch Hand
Joined: Jul 15, 2008
Posts: 59
|
|
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 <h utputText 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
Joined: Jul 15, 2008
Posts: 59
|
|
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
Joined: Jun 25, 2001
Posts: 14491
|
|
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.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: how to populate image through HtmlGraficImage object in the backing bean?
|
|
|