File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes ui:repeat wrote in a bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "ui:repeat wrote in a bean" Watch "ui:repeat wrote in a bean" New topic
Author

ui:repeat wrote in a bean

daniele licitra
Ranch Hand

Joined: Apr 08, 2013
Posts: 43

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?


JPA 2.1.0
Glassfish 3.1->4, Wildfly, Primefaces 3.4->4
Balaji Manoharan Bm
Greenhorn

Joined: Sep 22, 2013
Posts: 13
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

Joined: Apr 08, 2013
Posts: 43

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?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ui:repeat wrote in a bean