• 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

ui:repeat wrote in a bean

 
Ranch Hand
Posts: 82
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to all.

I have a DB table and I want to create filters to apply to it with a mask.
I fill a HashMap and submit it to the JPA function....

I want to display label and inputText to fill two array (one for label, "nomi", and one for values, "valori"), but records in the maps are non static. An user must "add" a filter choosing from the available fields.
It must be done in jsf page in this way:

"nomi" and "valori" are of type List<String>... with add button i add the string "newChoise" to the list "nomi" and then I update the panel. It works.

Now, i have a panel binded to a java bean properties and inside this i want to insert the code above...how it can be done?
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For storing the label and value, you can think of Value Object. Then use an ArrayList to store table data as a collection. The value object provides extensibility so you can add new parameters in future very easily.

The following link explains how to use ui:repeat tag.
http://www.mkyong.com/jsf2/jsf-2-repeat-tag-example/

Your question is little unclear on where you are having problem. So have answered generally by looking at your code.
 
daniele licitra
Ranch Hand
Posts: 82
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply.

I'm sorry, I was not clear.

My xhtml looks like

sessioneUtente is a session bean and pannelloModuloAttivo is of type "org.primefaces. ... .Panel".
pannelloModuloAttivo is filled inside bean function.
I append to this component all the components that I want to show with pannelloModuloAttivo.getChildren().add(newComponent).

For now, I solved in that way: I have a List<Field> listaCampi and each element of list is a column of the db table.
For each element, i draw a checkbox, a label, a select and 2 input text inside a dialog:


This function return a dialog that is appended to the panel "pannelloModuloAttivo". This dialog has static field: if the entity has 10 columns, I have 10 rows in the dialog.

What i want to achieve is:
to use a List filterList that contains only query used filter;
to add a filter to filterList by ajax function;
to remove unused filter from dialog with a button;

I can do it with a lot of functions and re-drawing the dialog. If i use a ui-repeat-like system, it will be more simple,readable and maintainable.
There is a way to add by java code a ui:repeat component to the panel above?
 
Saloon Keeper
Posts: 27762
196
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
As a general rule, I discourage both the use of ui:repeat AND the creation of JSF Components in Java code. Both have their uses, but there are much cleaner ways to display and update tables of data rows from a database. Use an h:dataTable and DataModel instead.
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic