- I found out that blog example I wrote about has a little bit of history behind it. Apparently it was developed in response to a blog of Simon Brown. He publishes a set of blogger application requirements to compare web frameworks. Although Gavin argues that a blogger application hardly JEE, he still developes the example. Read more on it here http://relation.to/Bloggers/ComparingWebFrameworksSeam .
- To validate against hibernate validators with JSF only thing you have to do is wrap the components with the "s:validateAll" tag. So if we have a name field in our page like;
Which is annotated like;<s:validateAll>
<h:inputText id="txt_name" value="#{newPhoto.name}" required="true" />
</s:validateAll>
"s:validateAll" tag will make sure nothing more than 20 characthers will pass and if tries to, a jsf error message will be raised. We could do all the basic validations but still not the required validation because, JSF does not call the validators if there is no value present...@Length(max = 20)
String name; - Really liked the jboss el. You can even use it with ejb-ql's. Which is useful with standard seam components like the credentials component. This example is to check the credentials of a user:
A little DSL and we don't have to do more method chaining to pass the parameters. You can also use the EL with some security annotations and possibly on more places...User u = (User) entityManager.createQuery(
"select u from User u where "
+ "u.login = #{credentials.username} and u.password = #{credentials.password}")
.getSingleResult(); - It's not beans with seam. They call it components. And you can configure, add and remove them through components.xml . You can inject variables to your components with out the scope limit. And components can outject variables.
- To configure components seam people chose to make a API of annotations instead of defining interfaces like the spring api has. I am not sure if the spring api has something new but this is what you used do if you needed a method to run after a bean has been created;
That is you have to implement the InitializingBean interface. On seam you have to annotate a method with the @Create annotation:public class SomeBean implements InitializingBean, ... {
...
public void afterPropertiesSet() throws Exception {
...
I personally liked the annotation approach better in a language perspective, but I guess its harder to implement and will depend on reflection api, so will be slower.@Create
public void initTestUsers() {
... - Another thing was my toy app was not working yesterday. It turned out that it could not access the dtd's in xml definitions because jboss was on maintainnance so I deleted them from xml's...
Wednesday, April 22, 2009
more notes on seam
Here is more tips on seam;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment