add htm tag in java code

Hello,

I'm a newbie in jsf and since a long time, I try to create dynamic tables but I never reach to do all what I want.

Recently, I build a panelGrid in my java code because the number of columns is dynamic. And In this panelgrid, I have several components like outputtext, selectonemenu... and I want to add some html tags between these components. For exemple, I want to surround several components by a div section, or I want to had a line delimiter (hr) but I don't know how to do this in the java code. I tried to do this with the htmlib library (enable here, jsftutorials.net/htmLib/) but there is no documentation and I didn't reach to had attribute to the tags (like styleClass attribute).

Here is an extract of my code, to help you anderstand what I want to do :

privatevoid initTableRubriques(){

//purge du panel

panelGridRubriques.getChildren().clear();

//r閏up閞ation du nombre de colonnes du tableau

int nbColonnes = controle.getNbColonnes();

panelGridRubriques.setColumns(nbColonnes);

for(int i = 0; i < nbColonnes; i++){

List<Rubrique> rubByCol = controle.getRubriquesByColonne(i+1);

//panelgroup regroupant tous les composents de la colonne

HtmlPanelGroup groupe =new HtmlPanelGroup();

for(int j = 0; j < rubByCol.size(); j++){

FacesContext contexte = FacesContext.getCurrentInstance();

Rubrique r = rubByCol.get(j);

//le div bloc

UIDiv divBloc =new UIDiv();

try{

divBloc.setStringAttribute(contexte,"styleClass","bloc");

}catch (IOException e){

e.printStackTrace();

}

//l'image de d閜liage de la rubrique (petit moins)

HtmlGraphicImage imageMoins =new HtmlGraphicImage();

imageMoins.setUrl("img/menu_moins.png");

imageMoins.setStyleClass("titre_noir_2 pointeur");

//l'espace entre l'image et la rubrique

HtmlOutputText espace =new HtmlOutputText();

espace.setValue(" ");

//le titre de la rubrique

HtmlOutputText titreRub =new HtmlOutputText();

titreRub.setValue(r.getNom());

titreRub.setStyleClass("titre_noir_2");

titreRub.setStyle("width:164px");

//la ligne de s閜aration entre la rubrique et la sous rubrique

UIHr ligneSepRubSousRub =new UIHr();

try{

ligneSepRubSousRub.setStringAttribute(contexte,"styleClass","diviseur_niveau_1");

}catch (IOException e){

e.printStackTrace();

}

divBloc.getChildren().add(imageMoins);

divBloc.getChildren().add(espace);

divBloc.getChildren().add(titreRub);

divBloc.getChildren().add(ligneSepRubSousRub);

groupe.getChildren().add(divBloc);

//s'il y a des rubriques ?la suite, on ajoute une ligne de s閜aration

if(j != rubByCol.size()-1){

//la ligne de s閜aration entre les rubriques

UIHr ligneSepRubs =new UIHr();

try{

ligneSepRubs.setStringAttribute(contexte,"styleClass","diviseur_niveau_2b");

}catch (IOException e){

e.printStackTrace();

}

groupe.getChildren().add(ligneSepRubs);

}

}

panelGridRubriques.getChildren().add(groupe);

}

}

I thougt that the setStringAttribute method will set the attribute named as the first parameter with the value of the secon parameter but it doesn't.

If someone have an idea it will really help me, because each time I try to create a dynamic datatable or panelgrid I'm blocked because of that. And as all the pages I have to do contain dynamic tables, I don't progress at all in my work... so please help me

[5431 byte] By [stephbibiea] at [2007-10-2 20:32:56]
# 1
Add a f:verbatim tag instead. Inside this tag add normal html tags like you want.
pringia at 2007-7-13 23:16:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Ok, but how I add a f:verbatim in java code (not in jsp file)? I found the method createVerbatimComponent() in UIComponentClassicTagBase class but I didn't find how to get an UIComponentClassicTagBase instance.

So finaly, I create an HtmlOutPutText with escape property to false and value equals to the html code I want and add it to the rest of the components tree.

But, I am under the impression that it is not the better way to do such a thing. It seems to be not practical and not "pretty" code. If someone has another solution I am fascinating.

stephbibiea at 2007-7-13 23:16:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...