Blake Minghelli

Ranch Hand
+ Follow
since Sep 13, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Blake Minghelli

I am trying to define a required element of type 'decimal' that should allow up to 12 total digits and up to 2 fractional digits. It also must allow empty strings (i.e. element is present but contains no value).

Here is the xsd snippet for the element:
So, I want this to be a legal value in an instance document:
But when I validate (using Xerces), I get this error:
What do I need to do to make the element allow empty values?
I just read a JavaWorld article about EJB 3.0. The pieces of the spec regarding eliminating home interfaces, making entity beans POJOs, etc sound great, like they will really help make developing EJB apps easier.

However, I'm not sold on annotations. EJB 3.0 seems to be all about annotations. That seems like you are doing the same thing as deployment descriptors except that now you have hard-coded them into your classes. And, for entity beans, annotating the table/column names in the class files seems like it would be severly impacting portability.

The EJB 3.0 expert group consists of experts (duh), so I'm not doubting their design. I have very little EJB experience to draw on. But maybe someone can help clarify how annotations are a better way to go?

Originally posted by Balaji Loganathan:
Blake!.. Could you please post your complete schema snippet using UBB code tags?

Here is the entire schema. The content under the "CCI_Server_Interface" is what I am trying to set up to allow any content.
Any suggestions? Thanks

Originally posted by Lasse Koskela:
This should work:

That's exactly what I tried. Unfortunately XMLSpy still reports the error: "Element 'sub1' not defined in DTD/Schema"
I'm having trouble creating a schema where one element can have any content, i.e. within my xml, I have an element that can consist of any sub-elements. For example:


How can I define <sub1> in my schema to allow any sub-elements?
I tried playing with <xs:any>, but the validation fails on anything under <sub1>, complaining about 'unexpected element'.

Originally posted by Barry Andrews:
Are you absolutely sure both machines are running the same Java version? If you run java -version on the command line, you get the same?

Correct.
Even if the version was slightly different, I don't see why the cast would break. As far as I understand TableModel usage, if you don't explicitly use one (e.g. if you use the JTable(Vector, Vector) constructor), then you get a DefaultTableModel. Arghhhh
20 years ago
Well, I've had all kinds of difficulties working with JTable so far.
I am working with a very simple table. Originally, I constructed it like this:The data is not known at the time of construction which is why I was passing a null Vector for the dataRows param.
That code worked fine from my PC but the JTable constructor threw NullPointerExceptions on another PC. Both PCs were running java 1.4.2_05.

So, since one JVM seemed to not like the null dataRows, I created an empty dataRows Vector, like this:: That fixed the NPE's and both PC's seemed to be happy.

However, now I am running into another strange problem with this code:As you can see the intent is to simply remove all rows from a table. But on [B]one[B] PC, I am getting a ClassCastException in that method. On the other PC, it works fine.

Anyone experience this?
Why would table.getModel() on one PC using the same JRE return something other than DefaultTableModel???
20 years ago
I created a custom modal dialog class that will pop-up, run some Runnable task, and then go away once the task is complete. It's a very basic window containing a single JLabel that displays some informational message to the user, like "Retrieving data...". Here is the code:

To use it, I am launching a new thread, something like this:

The problem is this: The first time I launch a new ModalDialog, it looks perfect - the window appears with the appropriate message. However, in subsequent uses, the JLabel does not appear so the user just sees a blank modal window. The only difference I can see is that the first launch occurs within the constuctor of my app whereas the subsequent launches originate through the event thread (e.g. user clicked a button). However, since in both cases, I run the ModalDialog in a new thread, it doesn't seem like that should matter.

I have tried many things such as calling repaint(), validate(), launching new threads, etc, etc.
Does anyone have any suggestions?
20 years ago

Do a fireTableDataChanged on the tablemodel after adding the row

Thanks, tried that but unfortunatetly still got same exception.

I got data to display if I used the JTable(Vector rowData, Vector colNames) constructor. So I guess I'll play around with that more.

Swing is overly complicated
20 years ago
I'm not a "Swing" guy so I'm struggling with something that should be very basic and easy. I am creating a JTable using a DefaultTableModel and a DefaultTableColumnModel that I build myself (contains 14 columns). I don't feel like I should need to create a custom TableModel implementation - I just want a very basic table that will store results from a db query.

The code snippets are this:

Right after I do the addRow() (which works) and it attempts to repaint the table, i get this exception:

I'm sure this is something stupid and basic but I can't figure it out. The API seems confusing because there seems to be a dozen ways of configuring the table's columns.

Any help is appreciated. Thanks
20 years ago
Well, you could get more precise by calculating the max row size and then multiplying that by the estimated number of rows.
For example, just to make things easy, let's say you have one table with 3 columns:
1. Integer (4-bytes)
2. varchar(6) (6-bytes)
3. varchar(10) (10-bytes)
Total row size = 20b
Total table size = 20b * 1000 rows = 20,000b = 19.5kb

Of course that's just data storage size.
The java.util.Calendar and java.text.SimpleDateFormat classes have methods for changing the time zone and formatting/parsing dates. Have you looked at those?
20 years ago
ok, I believe I found the solution to my problem.
The schema location can also be a URL string so I can use ClassLoader.getResource() which returns the URL (jar:...) of the schema file. Then I can simply do this:Thanks for your help.
Yes, you can read any file in Java, you just need to know how to read it, i.e. how is the data stored in the file. File extensions do nothing magical - they just give a hint to whatever program you are using as to how to read the data. For example, if you have MS Word installed, then Windows associates .doc to Word and uses it to open that type of file.

As long as your program knows what format the data is in, then the extension can be anything. You could have files that store ascii text and use a .foobar extension. The point is - using Java, you can read any type of file; Your program just needs to know what format it's in to do anything useful, like displaying the data in a gui.

Since a .csv is normally just a comma-delimited ascii text file, then you can simply use a java.io.BufferedReader or some other character-based Reader.
20 years ago