Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!

Ben Gateau Jr

Greenhorn
+ Follow
since Jan 08, 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 Ben Gateau Jr

Hi all,

today i have passed the SCJP 6 Upgrade exam with 83%. It has 48 questions, you need 66% to pass (32 correct answers) in two and a half hours. I have to say I was really surprised how hard the exam was. For those who are planning an upgrade exam: to prepare you have to study the same material as for the normal exam, with paying extra attention for the newer stuff. I used KB book (great), ExamLam mocks (very good), and Enthuware mocks (ok). It took me approximately month and a half to prepare. Don't know if there's much difference between normal and upgrade exams, it didn't seem like that to me. I'd be very peeved if I got between 58 and 66 percent. Studying in the evening and on weekends, it was tiring. And having passed the exam in the past, I had expectation that I should pass. I can't say that I was really happy at the end, more relieved that I didn't fail. Weird. Before the exam I used the same method I used at the uni and it always worked for me: day before the exam I give myself a day off and let the knowledge settle in. What else? Don't panic, and keep fighting with each and every question they throw at you.

At the end, I'd like to thank this wonderful community, it is great having so much good information on your disposal, and so many helpful members. Best of luck to all who are preparing, Merry Christmas to all who celebrate it and Happy New Year to all!

Cheers, Ben
10 years ago
Got it.

Thank you both
Thank you Dejan. I removed the second question while you were answering as I figured it out. Sorry to waste your time.

About the first (and now the only) question: I understand that adding two bytes promotes the result to an int. What I don't understand is why the result of

is still byte? It's still adding two bytes together.

Thanks, Ben
Hi all,

Reading wonderful Kathy Sierra book, in chapter 3 there is an example when adding two bytes together:


The above code is causing compile error. My question is, what is different about the following code:

The second piece of code is not causing compilation to fail. Why?

Thanks, Ben
Hi Javid,

Exactly. I have found the solution here.

Regards, Ben.
Does anyone have any idea how to achieve this? I had high hopes for the Restrictions.conjunction() but it doesn't work well when the same field is used. Any links or recommended books would be appreciated too.

Regards, Ben.
Thank you anna and Bauke for the examples. I've made a mistake of not posting my code, it would be clear what was wrong. I had 'value' attribute set but only on 'selectItems'. That items can be selected by setting the 'valule' of selectManyListbox - I would not have guessed it for a long time. Thank you both so much for your help and assistance, and Bauke I appreciate your perseverance

Regards, Ben.
11 years ago
JSF
Bauke, perhaps I wasn't clear in my first post ... I have binding to the bean property in place and the 'value' attributes are all set. What I am after is a way of programatically selecting some of the items displayed in the listbox. I know the values of the items I want to select, I just need to know how to select them.

Regards, Ben.
11 years ago
JSF
Hi Anish,

For Struts1 you can use Struts Faces:
Struts Faces

Fort Struts2 there is JSF Plugin:
JSF plugin for Struts2

Hope that helps, Ben.
11 years ago
JSF
Hi Bauke,

Thank you for your reply. Can you please explain what you mean by 'value of the input component'? When translated to HTML, SELECT component contains OPTIONs whose values are product ids, and product names are displayed for viewing. What I need is to have SELECTED for those options whose id matches products ids in List<Products>. I can match them easily I think, but have problems marking them as SELECTED using selectManyListbox.

Regards, Ben.
11 years ago
JSF
Hi all,

I hope someone can help me with using Criteria API to create correct search query. I have many-to-many relationship between Clients and Products. On the search page I have list of all the products,
and when user selects some products, I would like query to return all the clients who have ALL the products selected by the user. For example, on the list we have ProductOne, ProductTwo, ProductThree, and
if the user selects ProductOne and ProductThree, I'd like all the clients who have (among the possible others) ProductOne and ProductThree.
At the moment I have a query which returns clients which have either of the two products, but I want only those who have both.



I understand that 'Restrictions.in' returns true for each given product, but I don't know how to rewrite it and what to used instead in order to return true only if Client has all the given products.

Regards, Ben.
Hi all,

I'd like someone to advise me how to have (only) some entries in selectManyListbox selected. I have many-to-many relationship between Clients and Products, and when I was adding new Client I was populating selectManyListbox with all the available Products. Everything was correctly inserted into database, and now I am trying to create edit page. This selectManyListbox should contain all the available products (like before), but I would like to have Client's products selected. So in the backing bean I have list with all the products in form of List<SelectItem> (used earlier when adding), and I have List<Product> retrieved from the database. SelectItem entries where created using product id and name (ie, new SelectItem(product.getId(),product.getName())). And I don't know how to combine them to have what I described earlier. <f:selectedItem> and <f:selectedItems> don't even have 'selected' attribute, or something similar. BTW, I am using MyFaces 1.2 and Facelets.

Regards, Ben.
11 years ago
JSF
My apologies - there was an error in my code. I was getting Products from the DB, but when they were selected from the listbox, I was only setting the name for each before adding them to the Set, and I wasn't setting the ID fields. What can I say ops:
Cheers, Ben.
Sridhar,
Initially I had save(), but I've changed it since to have saveOrUpdate(). I guess 'OrUpdate' part is only working on the Client table.

Bauke,
I am getting Product objects from the DB and setting them unchanged in the new Client. What I would like is to have inserts only in CLIENT and CLIENT_PRODUCT tables. At the moment I can either have attempt at an insert to all 3 tables (using cascade=all) or only to the CLIENT table (using cascade=none).

Thanks, Ben.
I found the solution to my problem, I'll put the solution here if someone has the same problem.
I was defining byte array parameter as an object and when I was adding it to the page it was by default added as a String in text field. The byte array was image which I wanted to display on the report, so first I had to convert byte array to ByteArrayInputStream on the Java side, define parameter as type InputStream, and then display it within the image, also as InputStream type.