Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamically generate Panel grid elements

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !!!
 
Ranch Hand
Posts: 90
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27933
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic