Forums Register Login

How to optimize code using JSF

+Pie Number of slices to send: Send
I am creating an application using Hibernate and JSF, but at certain times to write data to some tables, I need to pull information stored in other tables

this is the ManagedBeans that I use to pull data from a particular table in my database



but where the line has the following code



I use a fixed class, someone would have an idea how I could pass it dynamically, I ask this because otherwise I'll have to create a ManagedBean for each class that I need to list the database

sorry for the bad english...
i´am brazilian
+Pie Number of slices to send: Send
You can inject the name of the class as a JSF ManagedProperty. However, note that this requires multiple instances of the seuManagedBean. That's not that bad, however, since it's not a very big bean.

You should not use a lower-case letter as the initial letter of the class name, however. That violates Java's coding standards and may even cause the ManagedBean mechanism to fail. A proper name would be something like: "SeuManagedBean", which the JSF bean instantiator would then catalog under the name "seuManagedBean".

However, if you take my original advice, which requires multiple instances, you'll need to configure this bean in faces-config.xml, since you'll need each instance to be cataloged under a unique bean name, and the annotation processor cannot handle that, not can it handle the multiple values for the injected ManagedProperty.
+Pie Number of slices to send: Send
Ok, you are right, I will follow the java coding standards, i will rename the "seuManagedBean" to "SeuManagedBean", but I don't know how implement faces-config.xml, how i can implement that?

Another thing, take a look in code below: it's the same logic as the "SeuManagedBean":



I use the same logic as the "SeuManagedBean", but they call two methods


and each of them call a diferent criteria



This way, everytime i need to populate a selectonemenu, the code will call all methods(each accesses the database to retrieve the records), my application may become slow?

I understand your idea about the config in faces-config.xml, but i don't know how to implement.

Could you help?

This in my xhtml file that i use with ListaEstado

Have you no shame? Have you no decency? Have you no tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1930 times.
Similar Threads
loading xml file problem in jboss developer studio managed bean
Bean value not maintained in RequestScoped
@ViewScoped not working
How to use inner join with hql query
JSF Mental Block
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:25:53.