• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamically generate Panel grid elements

 
Arindam Lahiri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am very new to jsf technology. Even I have worked in core java.

Can anybody help me how to generate a panel grid dynamically.

that means a panel grid may contain some text fields, but how many of those will be and what are their names and id will come from data base.

So inside bean class I have to create the html objects.

What i have done is :

<h:panelGrid binding="#{dropdowns.searchDataList}" id="dynamicSearchtableList" />

uisng this I am binding the grid to bean class. But how to generate the tags inside the java code I have no idea. Need help !!!
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arindam

You are in the right direction, now in the event of button for example or in the place that you need (function), you build the components and add them to the panelGrid, I give you an example:


I hope this help youwith you problem.
Regards
Cesar
 
Arindam Lahiri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you very much for the help.

But in jsf what I came across is use of getters setters. In the above code we are not doing so. Is it not necessary?

I mean if I bind it with a bean function and write the code inside bean then won't it paint the fields?

Or is there any other approach. I have started to work on java since last 8 days. So I am novice to this area.

Cheers !!
Arindam
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't just generate HTML, if that's what you mean. JSF doesn't assume that the output is even going to be HTML. So internally, JSF uses a component tree, which the render-results phase feeds to a renderer. Which generally IS an HTML renderer, but it can render to some other format entirely.

So to add arbitrary components within a container component, you have to construct their JSF component object equivalents, such as HtmlOutputText for <h:outputText> elements. Then you have to add them as children to the collection member of the container component.

Setting the child element values is fairly ugly, since you're exactly reproducing what would be hand-coded in a JSF view definition file. And since the outputText element can take an EL expression for its value attribute, you have to setup an EL expression interface to be attached to the value attribute of the HtmlOutputText element.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!