At the beginning of this month, I wrote about a problem I faced after upgrading JBoss 4 to JBoss 5. I have a class that validates information. When user clicked a button, it first calls that validator method, which in turns return a true or false value. If validation passes, the user can proceed, otherwise, the user cannot process and the page is re-rendered with error messages. The problem I faced was that all the messages are appearing at the global level instead of specific component.
In the code, I used <rich:message for="componentId" /> for error messages.
After contacting JBoss support and a few test cases, I solved the problem. The problem was that when the validation failed, I return the page by writing return "page1.xhtml" in my code. If I changed that line of code to return "", the error messages are rendered at the right location.
Tuesday, September 28, 2010
Thursday, September 9, 2010
Seam User Transaction
I have to use Seam's user transaction for one of my stateful bean. I needed user managed transactions because I was doing batch processing. I was using Bean Managed Transactions.
On the view, there are two major process; one is a command button which calls a method and the other one is a <rich:dataTable> which has one entity per line, and h:selectOneBooleanCheckBox for each entity attributes. The idea is that I'm providing user with a list of books, and users can select if a book is Spanish, Chinese or Italian by selecting the appropriate check boxes. Since I'm using ajax, I put <a4j:support> inside <h:selectOneBooleanCheckBox>, which is supposed to automatically update the value in the database. But it didn't happen. The boolean value never gets updated.
After trying a few hours, I finally took out the transactionManagement annotation from the bean and made it a regular stateful bean. Then all those boolean values get updated. I think since my stateful bean is responsible for committing transactions, that's why I can't expect the container to automatically commit the boolean values in the entities.
On the view, there are two major process; one is a command button which calls a method and the other one is a <rich:dataTable> which has one entity per line, and h:selectOneBooleanCheckBox for each entity attributes. The idea is that I'm providing user with a list of books, and users can select if a book is Spanish, Chinese or Italian by selecting the appropriate check boxes. Since I'm using ajax, I put <a4j:support> inside <h:selectOneBooleanCheckBox>, which is supposed to automatically update the value in the database. But it didn't happen. The boolean value never gets updated.
After trying a few hours, I finally took out the transactionManagement annotation from the bean and made it a regular stateful bean. Then all those boolean values get updated. I think since my stateful bean is responsible for committing transactions, that's why I can't expect the container to automatically commit the boolean values in the entities.
Wednesday, September 8, 2010
We updated our JBoss from 4 to 5, and our Seam got updated to 2.2.1. There was some modification in the source code in order to comply with JBoss 5 and Seam. The big problem right now is the deprecation of FaceMessages, which is replaced with StatusMessages.
StatusMessages' addToControl() method didn't work. It works when a message is added to a global <h:messages>. But if I want to customize a particular input of a form with <rich:message>, it doesn't work. Instead, it displayed all the messages at the global level.
I think what is happening is that, there was something changed with the updated Seam, that makes searching of components in a form always returning null, which consequently causes all messages to be display at the global level.
Granted, my current form is huge and complicated. There're some other parts where there is only <h:form> and simple code, where displaying message in particular place worked. So, I think it's a matter of trying to rearrange my JSF view code to keep up with the changes or there is some bugs.
StatusMessages' addToControl() method didn't work. It works when a message is added to a global <h:messages>. But if I want to customize a particular input of a form with <rich:message>, it doesn't work. Instead, it displayed all the messages at the global level.
I think what is happening is that, there was something changed with the updated Seam, that makes searching of components in a form always returning null, which consequently causes all messages to be display at the global level.
Granted, my current form is huge and complicated. There're some other parts where there is only <h:form> and simple code, where displaying message in particular place worked. So, I think it's a matter of trying to rearrange my JSF view code to keep up with the changes or there is some bugs.
Monday, September 6, 2010
Two books that made my day
I know I have stopped writing about my work with Java or other programming topics. Since I finished my summer class, I have been pretty relaxed and enjoying my last few weeks of my holidays before my fall semester starts again. There was an immediate project at work that I had to work on, which exposed me to non-AJAX web development. But it was not interesting enough for me to write about it. So, instead I'll focus on two books that I read this past week: Love In The Time Of Cholera and The Red Pyramid.
I always admire good writings. A good writer can make a boring story interesting and better. Classic example is Jane Austen. All of her books are basically about romance between a rich guy and a poor girl, which is made more complicated by their different social classes. They always have happy endings. But I can never get tired of reading Jane Austen's novels. Love In the time of Cholera is another classic love story, but it is amazing because of the writing. I'm not sure who should I give credit to for such a beautiful writing: the translator or the writer himself, since its original version is actually released in Spanish.
Another book I read was called The Red Pyramid. It was a more modern story, writing is mediocre but it was the story that attracts me. I am always interested in ancient mythologies, especially Eyptian ones. My childhood dream has been to visit Egypt one day and I still hope to do so. But I actually didn't know much about Egyptian god and goddesses. That fact didn't occur to me till I read The Red Pyramid. It is similar to Percy Jackson's series in that both main characters are semi-deities. It is not a surprise especially because The Red Pyramid was written by the same author as Percy Jackson's.
I'm glad that I'm catching up on my readings, especially since I used to read a lot as a kid and teenager. I believed that reading was what actually made me who I am. Since I started my undergraduate, I kinda stopped reading. I read but it was more like textbooks. I'm happy that I've began this habit again.
Subscribe to:
Posts (Atom)