Jeroen Kema

Greenhorn
+ Follow
since Feb 25, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jeroen Kema

When I google the title of this book, I see the following link:

http://www.mhprofessional.com/product.php?isbn=0072259523

It's the official site of the publisher, and it says the book is expected at July 30, 2011 At that time, there will probably be an updated version of this certification for a long time
I've fixed it already

I've added the following line to my gtdonline.taglib.xml file:



Now, the taglib is picked up during initialization and the custom tag is rendered in the browser
10 years ago
JSF
Hi,

I'm building a JSF custom taglibrary where I define some template components. I've been struggling for a few days to solve a problem with my custom tags. The problem is that my custom tags are not rendered. This is what I've added to my project:

web.xml: (I've only picked the relevant code)


faces-config.xml:


gtdonline.taglib.xml:


and the costuom messages.xhtml:


When I want to use the tag library in one of my pages, I simply add the namespace as following:


When I load the page in my browser, the <gtd:messages/> tag remains as it is in the html source.

When I google for similar problems, I'm finding threads where people wrote their own renderer class and added it also to the faces-config.xml. But as far as I know, I shouldn't edit the faces-config.xml when I use the <tag><tag-name/><source/></tag> tags to tag my custom facelet templates.

Can anybody help me to fix this problem?
10 years ago
JSF

Pieter Jacobs wrote:Hi guys,

1- When will you really use "throw" (an exception), and when "System.out.println" (whether to print the stacktrace or whatever) ?

example:
2- When using "Properties", you use a FileInputStream which is declared within a "try / catch" block; do I use "throw" in this case (within the "catch" block) meaning that the app should terminate because it can not continue if it does not get the value from the properties file ?

It was difficult to put this into words; I hope it makes sense!

Cheers,
Pieter



Hi Pieter,

Have a look at this: http://www.oracle.com/technology/pub/articles/dev2arch/2006/11/effective-exceptions.html

It explains when to use checked and unchecked exceptions and what to do with it. If you're implementing the exeption handling as in the article, you can catch the IOException when reading the properties, and throw an unchecked excpetion from there, because you said you cannot recover the exception from there. A fault barrier, which will probably exists within your user interface layer, should catch these unchecked exception and pass the message to a nice error dialog which explains why the application can't run further anymore.

System.out.println is something that should be avoided as much as possible. When you want some debug output, you should use java logging. You can restrict the logging level when the application is going into production. You don't want to have system.out.println in you production environment, do you?

Regards,
Jeroen
Thanks all

Roel De Nijs wrote:Hi Jeroen,

Congratulations with a great score

Jeroen Kema wrote:
I already new I would have some penalty points on my GUI, because I was forgotten to use SwingUtilities.invokeLater for invoking my service layer which resides on the server. This will cause a frozen user interface when the connection is very poor. That's why I have 31 points out of 40, which is more than I expected actually.


I don't think that's the reason why you lost 9 points on your gui score, because I also didn't use it (not forgotten, just didn't know ). So I guess it's due to something else...

In your other thread you were thinking about implementing a system check. Did you do it or not?

Kind regards,
Roel



Yes, I implemented some sort of optimistic locking. The interface of my book method is: HotelRoom book(HotelRoom hotelRoom, String customerId). The hotelRoom object is the original hotelroom that was recieved from the server. When booking a hotelroom, I pass the original hotelroom and the customer ID to the service layer. This layer checks if all fields of the hotelroom object are exactly the same as the one that resides in the data file. If there is a difference between them, I abort the update action and throw a checked exception with a message something like 'hotel room not up to date, please refresh you results'.
11 years ago
Hi everybody,

Today I received a message that I've passed my SCJD with the score of 367/400

General Considerations (maximum = 100): 99
Documentation (maximum = 70): 70
O-O Design (maximum = 30): 30
GUI (maximum = 40): 31
Locking (maximum = 80): 80
Data store (maximum = 40): 40
Network server (maximum = 40): 17

I already new I would have some penalty points on my GUI, because I was forgotten to use SwingUtilities.invokeLater for invoking my service layer which resides on the server. This will cause a frozen user interface when the connection is very poor. That's why I have 31 points out of 40, which is more than I expected actually.

The reason why I've only got 17 points out of 40 on my network server is very strange to me and not expected. I used RMI for my network layer and I thought it was designed properly enough. I'm sure I haven't forgotten generating the rmi stubs. It's really a shame Sun doesn't give some feedback about the scores, because I'm very curious why I have such a poor score on my network server..

Anyway, after all I've passed my SCJD, so it's time to start with the next one
11 years ago

James Tharakan wrote:Doesn't a custom made class hide the Alpha class Object.



No, because the custom made Object class also extends java.lang.Object
I think your result is:
here
james

The explanation of this result is as following:
Every class extends java.lang.Object. You created an Object class in a different package. This is why you don't see 'james' when you're initializing a 'objecttest' object.

The new Object() statement creates in instance of you own Object class, because the compiler probably checks first if an Object class exists in the same package as the Objecttest class. If this class does not exists in the current package, the Object class of package java.lang will be used.
Please use the [code] tags if you're posting code

The difference between "new Thread(new A(),"name_thread2").run(); " and "new Thread(new A(),"name_thread3").start();":
the start() method creates a new Thread and executes the run method in that thread. If you invoke the run() method directly, the code in run will execute in the current thread. This also expains why your code prints two lines with the same thread name.

Alecsandru Cocarla wrote:

Jeroen Kema wrote:
In this situation, the user asks for hotelrooms in New York, but gets a hotelroom in Washington. I think you should call this a bug. What you mentioned, that the record could be manipulated immediately after the service.findHotelRoom() has finished, is not really a problem because this is something you can handle by checking if the record on the client is still up to date.


This won't happen. You forgot a step here: findByCriteria won't give youthe exact matches, but the startsWith matches. But you need to return exact matches. So the last step is not "read record and return", it is "read record, check exact match, return".


Hmm, I've forgotten the exact match thing... This is also a good solution for this problem. Thanks for mentioning

Alecsandru Cocarla wrote:

Jeroen Kema wrote:
I think this is something that should be checked by the system, not by the user.


Well, have fun implementing this system check... And good luck!


You sound a little bit irritated, I hope I'm wrong. Do you think implementing this check is too complex?

Alecsandru Cocarla wrote:I'd say option 1. Otherwise, while the modifying thread waits, you find the records, everything is perfect. But, immediately after, the modifying thread comes into action and performs the changes anyway. So the user will receive a non-updated (outdated) version of the records. Unless you implement some notifying mechanism, from the server to the client, there's no way you can avoid this. So no need to synchronize anything, you're just making your life harder.



There is a big difference between data manipulation between findByCriteria and readRecord and data manipulation after a synchronized execution of findByCriteria and readRecord. In the first situation, the following could occur (in pseudo-code):

Thread-1: service.searchHotelRooms(location = "New York")
Thread-2: lockRecord(1);
Thread-1: findByCriteria({..,..,"New York",..}) returns record number 1.
Thread-2: updateRecord(1, {..,..,"Washington",..}, cookie);
Thread-1: readRecord(1) returns a HotelRoom with location = Washington.

In this situation, the user asks for hotelrooms in New York, but gets a hotelroom in Washington. I think you should call this a bug. What you mentioned, that the record could be manipulated immediately after the service.findHotelRoom() has finished, is not really a problem because this is something you can handle by checking if the record on the client is still up to date.

What I did is show the booked record to the user, before and after the booking succeeded, such that the user can decide if he booked the expected record or not.


I think this is something that should be checked by the system, not by the user.

Roel De Nijs wrote:Jeroen,

maybe another alternative could be: maybe you can implement in the Data-class a method like


which does the regular find and for every record number does a read.

so your service method will call this method and you have all info needed

just a thought
Kind regards,
Roel



You mean that you create an extension to the DBAccess interface? Something like:



Is this a solution that will be accepted by Sun? I ask this, because the DBAccess interface may not be altered.
Hi SCJ developers,

I'm developing at my URLyBird 1.2.3 assignment, and I have a question about the GUI search functionality.

I've created a Service layer between the GUI and the Data interface. This service layer has a method named findByNameAndLocation. Roughly, the implementation of this method is as following: at first the Data.findByCriteria methodis called to find the matching record numbers, and after that for every record number the Data.readRecord method is called to get the data.

Now I'm in doubt about what to do with the situation that between the invocation of findByCriteria and readRecord another thread could manipulate one of the founded record numbers.

1. Must I take into account that an updateRecord or deleteRecord could manipulate/delete a record that has just been found by findByCriteria, which means that the result of readRecord could be unexpected (i.e. RecordNotFound or altered name/location data)?

2. Do I have to synchronize the findByCriteria and readRecord calls in my Service class? Keep in mind that the calls of both methods are interface calls, so the user does know nothing about synchronization of the Data implementation.

I hope you can help me with these questions!

Regards,

Jeroen