1. There has been a change in the pawn structure. Your opponent has 8 and you don't have any.
2. Your opponent begins to throw pawns at your eyes.
3. You have a position won but your opponent has a gun.
4. The Director tells you not to bother turning in your scoresheet after the game.
5. Before the game begins you notice your opponents 1st initials are 'GM'.
6. After completing your development you sense your opponent playing the endgame.
7. Just as you make your opening move your opponent announces mate in 11.
8. You don't control any squares at all.
9. Your draw offer sends all the people watching your game into uncontrollable laughter.
10. Your opponent has 3 bishops.
11. Your opponent slaps his head and cries "Noooo what a mistake!!", then few moves later, you are down a queen.
12. You announce forced mate in 7 by sacking two pieces, then you resign after the 8'th move.
13. You crush your opponent on the chess board, but the opponent crushes you with the chess board.
This blog is mainly about Java...
Friday, December 3, 2010
Thursday, November 4, 2010
How to add RichFaces to your existing jQuery enabled site
As of Richfaces 3.0, jQuery has been inbuilt. If you don't know what jQuery is, you can watch a video about it here.
We have been using jQuery separately in our project, but wanted to add some Richfaces components. Now since Richfaces is using jQuery, there is a conflict that appears.
They both use $ as their main function name. That might brake the behaviour, and you might see error messages in your web browser, such as:
To resolve such cases jQuery introduces the
To use the jQuery that is bundled in RichFaces, you have to load the correct script.
Then you can assign jQuery to $j for convenience. Add the following in your javascript code:
Your new code now may look something like this:
And your Richfaces component will display and work without any problems! Thats it!
We have been using jQuery separately in our project, but wanted to add some Richfaces components. Now since Richfaces is using jQuery, there is a conflict that appears.
They both use $ as their main function name. That might brake the behaviour, and you might see error messages in your web browser, such as:
this.focusKeeper.observe is not a function
[Break on this error] Richfaces.ListBase.ASC="acs";Richfaces...ner('load',this.imagesOnLoad,true);}}
ListBase.js (line 4)
and
element.dispatchEvent is not a function
[Break on this error] event.eventName=eventName;event.memo=m...nt.fireEvent(event.eventType,event);}
3_3_1....eScript (line 265)
To resolve such cases jQuery introduces the
.noConflict() function.To use the jQuery that is bundled in RichFaces, you have to load the correct script.
<a:loadScript src="resource://jquery.js"/>
Then you can assign jQuery to $j for convenience. Add the following in your javascript code:
$j = jQuery.noConflict();
Then you have to replace all your former $() with $j() or the equivalents $. $[] and function($) with $j. $j[] and function($j)Your new code now may look something like this:
function showMessages() {
$j("div#messagetextPanel").fadeIn("fast");
}And your Richfaces component will display and work without any problems! Thats it!
Thursday, October 7, 2010
Why you should NOT use the Seam Application Framework
NOT TO BE CONFUSED WITH SEAM, WHICH IS AWESOME!
I am a very experienced Seam user. I have used Seam daily now for almost 3 years.
In this blog post, I will try to convince you to avoid the Seam Application Framework, and truly understanding when it should be used, and when it shouldn't.
What is Seam Application Framework?
Seam in Action says: "Seam is an application framework for Java EE. It provides a container that manages components and leverage's those components to tie the layers of an enterprise Java application together. Nestled within the Seam code base lies a handful of classes that comprise the Seam Application Framework. This "framework within a framework" is a specialized collection of component templates that effortlessly blanket the programming requirements of garden-variety web applications. Such tasks include performing create,read,update and delete (CRUD) operations on entity instances;querying for data; and developing JSF page controllers. You may be hesitant to give this spattering of classes much notice, but I assure you that they'll carry you a long way."
According to Dan Allen, he is encouraging you to check this "framework within a framework" out. However, though he is right, that there are benefits with this framework, I will prove that there are far more disadvantages than advantages and that he should have rewritten the last line to include that the framework is only really useful for small CRUD applications, and not something to leverage and build upon.
Way too many people are using this framework
If you have a look at the Seamframework.org forums, you will see tons of questions from people having problems and issues with the Seam Application Framework. Either a lot of people are developing small CRUD based applications, or there is a growing misconception about Seam and Seam Application Framework.
There are many people that are confused about this notion. They think that Seam == Seam Application Framework, and that they have to use it. And who can blame them? The seam-gen utility is a fantastic way of getting you quickly started. However, I have always encouraged people to only use the create-project and generate-entities part of the utility, and not the generate-ui part of it, this because most people I have talked with, are not developing small CRUD based applications, but rather medium sized enterprise apps, but since you get the Seam Application Framework for free, it is quite easy to extend and use it.
PROS
I did mention that there are a few pro's about using this framework, but it depends on people truly understanding the inner workings of the framework.
I also want to note, before I get spammed with comments about how wrong I am, that you can if you know what you are doing, speed things up. Details can be found here. However, this again requires some knowledge about Seam.
CONS
Consider this very very simple example. We have a SystemLog, and we want to display the log.
We have an action class that used the EntityQuery of the Seam Application Framework.
And this normal (non tweaked) seam component.
And a simple data table iterating over the elements
Now at first glance, I think the normal seam component is much cleaner and easier to read. Remember, this is a very simple example. In a normal real life example you would have extended the component to be much more complicated, and if you want to do this using the existing framework, you will need to find out what the framework already is doing, and correctly override those methods. Otherwise, you risk of doing the same thing twice.
If you ask your self what the @MeasureCalls annotation is doing, then have a look here, and scroll down to the second example. But a short description is that it measures the time of execution for a method.
When you run this example using the SystemLogNormal and the Query component, they are pretty much equal. However, you will see that the Query component is also calling the validate() method, which takes a few milliseconds to execute.
It is correct that a few milliseconds is hardly anything noteworthy, however this is a very very simple example, with very little data, and in a more realistic scenario, the number could possibly be different. Either way, the overall time difference is that the EntityQuery object is a few milliseconds slower.
As you can see, we get three outputs of "Inside systemlog". Really there should only be one. So adding a @Factory annotation on top of it will do the trick for both versions.
Then there are the Home and Query objects, with methods like isIdDefined(), clearDirty(), isManaged(), getEjbql(), RESTRICTIONS and more confusing methods which you need to read the documentation to understand.
Conclusion
In my opinion, for first time users who are learning Seam, it is more than enough to understand and learn the framework, instead of in addition learning "a framework inside a framework". The seam-gen utility is sort of a devil in disguise. Its great for a shortcut to get started, but its evil in disguise for new comers.
Newbies think Seam Application Framework is Seam, and all components they create must extends the Home, List or Query objects. Its confusing, and in my opinion they should avoid using it unless they know all the ins and out of both Seam and the application framework.
So if you are new to Seam, start by looking at the Seam examples that comes with the bundle. They are far better to use, than generating the UI with seam-gen and going from there.
I am a very experienced Seam user. I have used Seam daily now for almost 3 years.
In this blog post, I will try to convince you to avoid the Seam Application Framework, and truly understanding when it should be used, and when it shouldn't.
What is Seam Application Framework?
Seam in Action says: "Seam is an application framework for Java EE. It provides a container that manages components and leverage's those components to tie the layers of an enterprise Java application together. Nestled within the Seam code base lies a handful of classes that comprise the Seam Application Framework. This "framework within a framework" is a specialized collection of component templates that effortlessly blanket the programming requirements of garden-variety web applications. Such tasks include performing create,read,update and delete (CRUD) operations on entity instances;querying for data; and developing JSF page controllers. You may be hesitant to give this spattering of classes much notice, but I assure you that they'll carry you a long way."
According to Dan Allen, he is encouraging you to check this "framework within a framework" out. However, though he is right, that there are benefits with this framework, I will prove that there are far more disadvantages than advantages and that he should have rewritten the last line to include that the framework is only really useful for small CRUD applications, and not something to leverage and build upon.
Way too many people are using this framework
If you have a look at the Seamframework.org forums, you will see tons of questions from people having problems and issues with the Seam Application Framework. Either a lot of people are developing small CRUD based applications, or there is a growing misconception about Seam and Seam Application Framework.
There are many people that are confused about this notion. They think that Seam == Seam Application Framework, and that they have to use it. And who can blame them? The seam-gen utility is a fantastic way of getting you quickly started. However, I have always encouraged people to only use the create-project and generate-entities part of the utility, and not the generate-ui part of it, this because most people I have talked with, are not developing small CRUD based applications, but rather medium sized enterprise apps, but since you get the Seam Application Framework for free, it is quite easy to extend and use it.
PROS
I did mention that there are a few pro's about using this framework, but it depends on people truly understanding the inner workings of the framework.
- Quick to get started
- Excellent for small models,presentation and proof of concept
- Great in-built pagination of lists
- Can @Override the methods and inherit classes to extend/tweak upon the framework
I also want to note, before I get spammed with comments about how wrong I am, that you can if you know what you are doing, speed things up. Details can be found here. However, this again requires some knowledge about Seam.
CONS
- Its a bit slower
- More abstraction which might not suit your requirements
- More difficult to use than the plain components. You need to "learn a new framework as well as Seam"
Consider this very very simple example. We have a SystemLog, and we want to display the log.
@Entity
public class SystemLog {
@Getter @Setter
@Id
@GeneratedValue
private Long id;
@Getter @Setter
@NotEmpty
private String description;
@Getter @Setter
@Column
private String category;
@Getter @Setter
@Temporal(TemporalType.TIMESTAMP)
private Date date;
@Getter @Setter
@Column
private String username;
@Getter @Setter
@Column
private String organization;
@Getter @Setter
@Column(length = 1024)
@Lob
private String details;
@Getter @Setter
@Column
private String severity;
@Getter @Setter
@Column
private String ipAddress;
}
We have an action class that used the EntityQuery of the Seam Application Framework.
@Name("systemLogQuery")
@MeasureCalls
public class SystemLogQuery extends EntityQuery<SystemLog> {
@Logger Log log;
@Override
public String getEjbql() {
return "select sys from SystemLog sys";
}
@Override
public List<SystemLog> getResultList() {
log.warn("Inside systemlog query getResultList");
return super.getResultList();
}
}
And this normal (non tweaked) seam component.
@Name("systemLogNormal")
@MeasureCalls
public class SystemLogNormal {
@Logger Log log;
@In EntityManager entityManager;
List<SystemLog> result;
public List<SystemLog> getResultList() {
log.warn("Inside systemLog normal resultList");
if(result == null)
this.result = entityManager.createQuery("FROM SystemLog").getResultList();
return result;
}
}
And a simple data table iterating over the elements
<h:dataTable value="#{systemLogNormal.resultList}" var="sys">
<h:column>
<f:facet name="header">
description
</f:facet>
#{sys.description}
</h:column>
</h:dataTable>
Now at first glance, I think the normal seam component is much cleaner and easier to read. Remember, this is a very simple example. In a normal real life example you would have extended the component to be much more complicated, and if you want to do this using the existing framework, you will need to find out what the framework already is doing, and correctly override those methods. Otherwise, you risk of doing the same thing twice.
If you ask your self what the @MeasureCalls annotation is doing, then have a look here, and scroll down to the second example. But a short description is that it measures the time of execution for a method.
When you run this example using the SystemLogNormal and the Query component, they are pretty much equal. However, you will see that the Query component is also calling the validate() method, which takes a few milliseconds to execute.
It is correct that a few milliseconds is hardly anything noteworthy, however this is a very very simple example, with very little data, and in a more realistic scenario, the number could possibly be different. Either way, the overall time difference is that the EntityQuery object is a few milliseconds slower.
13:58:24,224 WARN [SystemLogQuery] Inside systemlog query getResultList
13:58:24,228 INFO [STDOUT] Hibernate:
select
systemlog0_.id as id0_,
systemlog0_.category as category0_,
systemlog0_.date as date0_,
systemlog0_.description as descript4_0_,
systemlog0_.details as details0_,
systemlog0_.ipAddress as ipAddress0_,
systemlog0_.organization as organiza7_0_,
systemlog0_.severity as severity0_,
systemlog0_.username as username0_
from
SystemLog systemlog0_
13:58:24,239 WARN [SystemLogQuery] Inside systemlog query getResultList
13:58:24,257 WARN [SystemLogQuery] Inside systemlog query getResultList
13:58:24,334 INFO [TimingFilter] 2.201607 ms 1 EntityQuery.validate()
13:58:24,334 INFO [TimingFilter] 15.967185 ms 3 SystemLogQuery.getResultList()
13:58:31,647 WARN [SystemLogNormal] Inside systemLog normal resultList
13:58:31,648 INFO [STDOUT] Hibernate:
select
systemlog0_.id as id0_,
systemlog0_.category as category0_,
systemlog0_.date as date0_,
systemlog0_.description as descript4_0_,
systemlog0_.details as details0_,
systemlog0_.ipAddress as ipAddress0_,
systemlog0_.organization as organiza7_0_,
systemlog0_.severity as severity0_,
systemlog0_.username as username0_
from
SystemLog systemlog0_
13:58:31,662 WARN [SystemLogNormal] Inside systemLog normal resultList
13:58:31,678 WARN [SystemLogNormal] Inside systemLog normal resultList
13:58:31,712 INFO [TimingFilter] 15.740409 ms 3 SystemLogNormal.getResultList()
As you can see, we get three outputs of "Inside systemlog". Really there should only be one. So adding a @Factory annotation on top of it will do the trick for both versions.
Then there are the Home and Query objects, with methods like isIdDefined(), clearDirty(), isManaged(), getEjbql(), RESTRICTIONS and more confusing methods which you need to read the documentation to understand.
Conclusion
In my opinion, for first time users who are learning Seam, it is more than enough to understand and learn the framework, instead of in addition learning "a framework inside a framework". The seam-gen utility is sort of a devil in disguise. Its great for a shortcut to get started, but its evil in disguise for new comers.
Newbies think Seam Application Framework is Seam, and all components they create must extends the Home, List or Query objects. Its confusing, and in my opinion they should avoid using it unless they know all the ins and out of both Seam and the application framework.
So if you are new to Seam, start by looking at the Seam examples that comes with the bundle. They are far better to use, than generating the UI with seam-gen and going from there.
Labels:
Seam
Friday, September 17, 2010
Devoxx versus JavaOne
Devoxx or JavaOne?
Thats the question...
It's really not that difficult to choose.
If you are based in Europe (as our company is), then you will for sure get more value for your money attending Devoxx instead of JavaOne.
However, if you look at a technical perspective, then still Devoxx comes on top in my opinion. The opening talk is by Mark Reinhold and one of the last talks, "Java state of the Union" is by no other than James Gosling. (I don't even need to link to him, every Java developer should know who he is), and there are tons of fameous speakers: Brian Goetz, The JavaPosse, Heinz Kabutz, Richard Bair and Roberto Chinnici just to name a few. (No pun intented for the others I didn't mention).
So it shouldn't come as a big surprise that I am also attending Devoxx. If you are going, lemme know and we can hook up!
Thats the question...
It's really not that difficult to choose.
If you are based in Europe (as our company is), then you will for sure get more value for your money attending Devoxx instead of JavaOne.
However, if you look at a technical perspective, then still Devoxx comes on top in my opinion. The opening talk is by Mark Reinhold and one of the last talks, "Java state of the Union" is by no other than James Gosling. (I don't even need to link to him, every Java developer should know who he is), and there are tons of fameous speakers: Brian Goetz, The JavaPosse, Heinz Kabutz, Richard Bair and Roberto Chinnici just to name a few. (No pun intented for the others I didn't mention).
So it shouldn't come as a big surprise that I am also attending Devoxx. If you are going, lemme know and we can hook up!
Sunday, September 12, 2010
Java 7, yet another delay
Mark Reinhold has published a blog stating what has been painfully obvious to everyone following the JDK 7 development: It will yet again be delayed until mid 2012(!)
Mark is further saying that there is an alternative which they are considering, and that "is to take everything we have now, test and stabilize it, and ship that as JDK 7. We could then finish Lambda, Jigsaw, the rest of Coin, and maybe a few additional key features in a JDK 8 release which would ship fairly soon thereafter."
I couldn't agree more. The community has waited too long for Java 7 to come out. There are so many problems in the current Java version, that makes people look around for alternatives in the Java Virtual Machine.
I am certain that if Java 7 will be delayed for yet two more years, then most people by that time will move to other languages such as Scala and Grails, which doesn't have the problems Java has today.
So, to sum up. Oracle has my vote to ship whatever they have now, and then come with the rest of it with JDK 8.
Mark is further saying that there is an alternative which they are considering, and that "is to take everything we have now, test and stabilize it, and ship that as JDK 7. We could then finish Lambda, Jigsaw, the rest of Coin, and maybe a few additional key features in a JDK 8 release which would ship fairly soon thereafter."
I couldn't agree more. The community has waited too long for Java 7 to come out. There are so many problems in the current Java version, that makes people look around for alternatives in the Java Virtual Machine.
I am certain that if Java 7 will be delayed for yet two more years, then most people by that time will move to other languages such as Scala and Grails, which doesn't have the problems Java has today.
So, to sum up. Oracle has my vote to ship whatever they have now, and then come with the rest of it with JDK 8.
Subscribe to:
Comments (Atom)
Labels
- Seam (14)
- Java (11)
- Hibernate (5)
- JPA (4)
- Seam 2 (4)
- Seam 2.1.1 (4)
- Seam Series (4)
- Devoxx (3)
- EJB3 (3)
- JavaOne (3)
- MySQL (3)
- PDF (3)
- jodconverter (3)
- jodconverter 3 (3)
- axis2 (2)
- hash password (2)
- pdfa (2)
- sigar (2)
- swing (2)
- testng (2)
- webservice (2)
- AngularJS (1)
- Cache (1)
- Comment (1)
- Dropwizard (1)
- Encryption (1)
- Enum (1)
- Freemarker (1)
- Guava (1)
- IE8 (1)
- IdentityManager (1)
- InnoDB (1)
- Iran (1)
- JOOReport (1)
- JSF (1)
- Jasypt (1)
- JavaPolis (1)
- Memory (1)
- MyISAM (1)
- ODT (1)
- OSS (1)
- OpenOffice (1)
- REST (1)
- Seam book (1)
- Tehran (1)
- UTF-8 (1)
- Ubuntu hardy (1)
- Windows vista (1)
- ant (1)
- chess (1)
- damenes tale (1)
- filters (1)
- firefox (1)
- html cache (1)
- interceptor (1)
- java 5 (1)
- java 6 (1)
- java 7 (1)
- javazone (1)
- javazone 2015 (1)
- jaxb (1)
- jboss (1)
- jboss 4 (1)
- jboss-ws (1)
- jdbc (1)
- jquery (1)
- jrebel (1)
- julebord (1)
- junit (1)
- musehånd (1)
- ojdbc (1)
- oracle (1)
- persistence.xml (1)
- prettify (1)
- ptql (1)
- richfaces (1)
- rollermouse pro (1)
- rpi (1)
- s:cache (1)
- seam-gen (1)
- second level cache (1)
- treecache (1)
- wicket (1)