Tim Holloway

Saloon Keeper
+ Follow
since Jun 25, 2001
Tim likes ...
Android Eclipse IDE Tomcat Server Redhat Java Linux
Long-time moderator for the Tomcat and JavaServer Faces forums. Designer and manager for the mousetech.com enterprise server farm, which runs VMs, a private cloud and a whole raft of Docker containers.
These days, doing a lot of IoT stuff with Arduinos and Raspberry Pi's.
Jacksonville, Florida USA
Cows and Likes
Cows
Total received
158
In last 30 days
1
Total given
29
Likes
Total received
2172
Received in last 30 days
39
Total given
200
Given in last 30 days
3
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tim Holloway

Some editors have a "display blank characters" mode (like Microft Word). In that case, if you turn it on, spaces may show as dots and tabs might show as arrows.
18 hours ago
First, go back and read the "future improvements" hints that I gave you at the end of your earlier problem: webpage You need to do these things, because using crude force like you are doing now will cost much in both performance and reliability in your table display.

Next, make sure that you know the distinction between the number of rows in the View (extendedDataTable) and the Model (tmunicipios bean). The view can show the entire contents of the table DataModel or it can show a subset (fixed number of rows).  Tne clientRows attribute of the extendedDataTable indicates the number of rows to display. The number of rows in the DataModel (tmunicipios.municipio) is simply the size of the List or array that holds those rows. The AJAX properties of the  extendedDataTable tag determine whether the rows can be fetched from within the DataModel without refreshing the entire webpage [iii]versus[/i] just fetching and updating the table view within the current page (without re-drawing everything else).

If you want all of the rows in the DataModel to display without scrolling or fetching, set clientRows to 0. Otherwise, the dataTable will only display as many rows out of the DataModel as you indicate. If there are fewer rows in the DataModel than the value of clientRows, the dataTable will only display what's available and either shorten the table display or pad it with filler.
18 hours ago
JSF
That's the problem with interpreted languages like python. Bad code doesn't show up until something tries to compile it. Python's a really bad offender because if you print the code and examine it, bad use of tabs won't be detectable.

So the brute-force way to check bad indentation is to actually run the code.

If you can't do that or want something more refined, use a "lint" utility. Lint utilities, plus other useful code analysis tools for Python are listed here: https://realpython.com/python-code-quality/#linters

Some IDEs and text editors can be helpful in that they can be instructed to not use tab characters and/or to replace tabs with spaces.
22 hours ago
Note the difference:

LstCidade is set to "SELECT MunicipioFROM Tabela_Cadastro_Municipios".

Compare to:

LstEspecialidade is set to "SELECT Especialidade FROM Tabela_Especialidades_Medica".

See the difference?
1 day ago
JSF


Evaluates to:
Which is not valid SQL. That should have thrown an Exception and been reported on the server log.
1 day ago
JSF

Stephan van Hulst wrote:Because Double isn't a primitive, but an object.



Boldfaced for emphasis. A Double cannot be cast to a primitive, but the Double intValue() method can do what you want.

For that matter, you can do a Double x; int i = (int)x.doubleValue(); or even (int)x.floatValue(), but that's just making things more complicated.

Zulfi Khan wrote:
This is not a built in project. I am running Netbeans for the first time on ubuntu 18.04 so I am getting java.lang problem. Netbeans is not able to recognize the "String" class.



I don't know what the difference between a "built in" project and a non-"built in" project is supposed to be, but unless NetBeans is a lot different than I remember, every bit of user code visible to NetBeans must be in a NetBeans project.

And the project needs to have a JDK associated with it.

Normally when you install an IDE, it looks to see what JDKs and JVMs it can locate that are already in your system and will register one or more of them for use to compile and run NetBeans projects. If you installed NetBeans before installing a JVM, it may not have been able to do so, in which case I'd expect to see an error like what you are getting.

The other thing that can result in that sort of error is if you are not pointing to the root directory of the JDK/JRE that you are trying to use. DO NOT point to the "bin" directory or one of the other sub-directories of the JDK that you downloaded and unzipped. For example, if I downloaded and unzipped the Oracle JDK jdk1.8.0_66, I would unzip it (per Red Hat convention) into the /usr/java/ directory and the JDK location to plug into the IDE would be /usr/java/jdk1.8.0_66.

In the case of OpenJDK, I cannot be so definite, because although OpenJDK is now pre-installed with Fedora Linux, I do all my professional work with the downloaded Oracle products (at least up until now). However, you will probably find that the openJDK equivalent for the /usr/java directory on your machine is /usr/lib/jvm, so a generic path might be /usr/lib/jvm/java-11-openjdk. Because of the "alternatives" feature of Linux, this may lead down one or more aliases (softlinks).
2 days ago
The CLASSPATH of the shell that you launched NetBeans into is probably not used at all by NetBeans. Furthermore, unless I'm mistaken, the CLASSPATH that the JVM that runs NetBeans is probably not the CLASSPATH used by projects inside NetBeans.

This is certainly true in the case of the Eclipse IDE, and I'm pretty sure that NetBeans is designed similarly.

So to get the right CLASSPATH for running/debugging a project in NetBeans you need to look at the project properties, and if there's an independent run/debug profile being used (like in Eclipse), you will need to look there, since that's where the classpath for execution of that particular project is defined.
3 days ago
Actually, I'm pretty sure that the flush() call does send the data. But the receiving app might not know to flush its output text without that line-termination.
Both IntelliJ and NetBeans are very popular here, as is the Eclipse IDE. Eclipse may be somewhat less friendly than the first two, but it has a lot of power (and it's what I generally prefer).
3 days ago
If you can figure out what the old encoding scheme was, you should be able to dump the defective items, convert them to the proper encoding, and reload them.

A thought occurs to me - you can use an ETL utility (like Pentaho DI/Kettle) to setup this process without having to do any arduous coding (after all, that's what you want to do: ETL - Extract, Transform and (re)Load). Dump the offending items out as text files (make sure you have a multi-lingual text editor!) using different encoding schemes for the source until you get something readable, then you can create the part of the pipeline that reloads with the repaired values. Needless to say, you should backup the database first - or better yet, clone the database and do your experiments on the clone copy.
I'm not sure why you're using TomEE if you're not using EJB, If all you want is JPA, ordinary Tomcat can do that without the overhead. And remember, JPA is a subset of EJB3!

A note on your "action". That's not how JSF wants actions to work. An action method is supposed to be a method that takes no parameters and returns a String (which indicates which View to display next). For "click on link/button in dataTable, you should wrap your table's Model Data in a DataModel object, which will decorate it with some necessary infrastructure. Then, when your (proper!) action method is fired, it can easily determine which row was selected by using the DataModel's getCurrentRow() or getRowIndex() methods. The action method is supposed to be indicated by a reference (action="#{studentController.addStudent}") not a "call". Putting an explicit method call in an EL expression may cause it to be invoked at the wrong point in the JSF lifecycle.

OK, enough nitpicking. I've discovered that JPA can often demand a transaction for things that you wouldn't consider transactional (like SELECTS). I've never found out why, just take it as a given.

Since you're not using an implicit transaction management framework such as Spring Data, that means that you're going to have to wrap your database operations in explicit getTransaction/begin/commit/rollback calls.

Finally, I've seen indications that when you create a backing bean using NetBeans, the name it gives ends with "Controller". This is a lie. Backing beans are Models. Controller logic in JSF resides in the FacesServlet and in the tag library implementations. Unless you're creating a custom tag using low-level logic in JSF, you never write Controller logic in JSF. You create Models and View Templates only. I think some of the confusion may be because backing beans can contain Action Methods, but Action methods are not Controller code. Controllers move data values between Model and View. Action methods see data already updated in the Model. Action methods are more properly classified as "business logic" and are invoked after all Controllers update the bean and before Controllers post any action updates to bean properties back to the View. So a Backing Bean is an impure Model (with business logic), but never a Controller.
Many congratulations on getting things to work! It has been a struggle for you I know, and you deserve a cow for it.

I'm not sure exactly what you mean by "I have another set that work only with <h:dataTable> I can't see where are the problem to use <rich:extendedDataTable>", but if you can do what you want, that's a good start. You can learn from there.

A couple of hints for future improvements:

First, instead of SessionScoped on the backing bean, consider ViewScoped. View scope is much like Session scope, except that when you move to a different View, the ViewScoped Bean is automatically deleted. Session Scoped beans remain forever (or until the Seesion is destroyed), so this can make your app more resource-efficient.

Secondly, instead of instantiating an object to get the JDBC Connection form, you might want to provide an Application Scoped object that returns a Connection. When that object is initially instantiated, it can do a JNDI lookup to find the database Connection Pool and cache it in the Application Scope bean. Note that Application Scope is not thread-safe, so the logic for doing the JNDI should ideally be synchronized.

Also, instead of doing a SELECT every time that getEspecialidade() is invoked, keep a member property with the selected data List in your backing bean and only do the SELECT if that property is null. That will cache the data values. This is important because A), the getEspecialidade() method may get called 5 or 6 times every time the page is rendered, which is a LOT of database overhead, and B) if the items you are retrieving are likely to have had inserts, deletes or updates done by other users/threads, the same list won't get used to build the display and results may be unpredictable. If you keep a data cache like this in your bean, you'll have code that's more reliable and more efficient and if the data goes stale, just set the list reference to null to let the getEspecialidade() method know that it has to go back to the database and SELECT out a new List.
4 days ago
JSF
It's important to remember that web browsers don't receive "files", they receive data streams. The data stream's "type" should be marked via a Content-Type header.

Content-type refers to a MIME value. MIME, incidentally, stands for Multimedia Internet Mail Extensions, since it was first designed for email with non-text content, then adapted for web use.

When a web client (browser) receives a data stream, it looks up the Content-Type MIME type. There's typically a file or database somewhere it references, either client-specific or sometimes system-wide.

The MIME type lookup typically will return what filename extension(s) that type is associated with. For example, in the global MIME mapping (/etc/mime.types) file on my machine, the type application/gzip assiciates with "gz" and "gzip" file extensions.

In-browser MIME mapping may also specify the default disposition for a data stream - that is, "display in browser" or "save as file".

So the file save options dialog's selection of default file types for a given Content-Type depends on the browser and the browser's preferences possibly augmented by sysytem preferences.
I can say nothing further without actually having my sweaty hands on the project source code. Which would probably offend your employers besides being more work than I would do withut payment.

I found a Google Group that might be able to help you, though: https://groups.google.com/g/drools-setup
6 days ago