myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Werner Punz <we...@gmx.at>
Subject Re: JBoss Seam & JSF
Date Thu, 15 Dec 2005 20:05:39 GMT
Nicola Benaglia wrote:
> Hi !
> I am experimenting this application framework that unifies the component 
> models of JSF and EJB 3.0.
> I'd like to know if any of you is also experimenting it and know his/her 
> impressions.
> 

Ok thanks to the message that the bug which stopped me was fixed
I started anew with a small testprogram, a simple blogger.

Well to sum it app, the full application logic was around 100 locs
and only having a partial understanding of ejb3 and seam it took me
an hour to get the app infrastructure to the point so that I could 
develop and another hour to write the thing from scratch.

I have a working non ejb version up and running now, embedded
into the booking example.

The coding was very straightforward and very clean, no explicit
transactional logic and no session handling, all done by Seam.

The linking between commandLinks within the table and the 
model-controller code was done automatically.

One bug encountered, the semi automated linking between a table and the 
model-controller code only works on the datatable, but refuses to
work on the tableList from tomahawk.


here is the core code:



@Scope(SESSION)
@Name("blogbackend")
public class BlogBackend implements Serializable {

	String blogTitle;

	String blogContent;

	
	@In(create = true)
	private Session bookingDatabase;

	@DataModel
	private List<Blog> blogs;
	@DataModelSelectionIndex
	int blogIndex = 0;
	

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	
	BlogBackend() {
		
	}
	
	public String newBlog() {
		this.setBlogTitle("");
		this.setBlogContent("");
		blogIndex = -1;
		return "blogdetail";
	}
	
	public String addBlog() {
		
		if(blogIndex == -1 || blogs.size() == 0) {
			
			Blog blog = new Blog();
			blog.setTitle(blogTitle);
			blog.setContent(blogContent);
			bookingDatabase.persist(blog);
			blogIndex = 0;
			refresh();
		} else {
			Blog blog = blogs.get(blogIndex);
			blog.setTitle(blogTitle);
			blog.setContent(blogContent);
			bookingDatabase.update(blog);
			refresh();
		}
		
		
		return "blogmaster";
	}

	@Factory("blogs")
	public void refresh() {
		Query query = bookingDatabase.createQuery("from Blog where 1=1 order 
by id desc");
		blogs = query.list();
		if(blogs == null)
			blogs = new LinkedList();
	}
	
	

	public String goDetail() {
		Blog detail = blogs.get(blogIndex);
		this.blogTitle = detail.getTitle();
		this.blogContent = detail.getContent();
		return "blogdetail";
	}


	
	public String getBlogContent() {
		return blogContent;
	}

	public void setBlogContent(String blogContent) {
		this.blogContent = blogContent;
	}

	public String getBlogTitle() {
		return blogTitle;
	}

	public void setBlogTitle(String blogTitle) {
		this.blogTitle = blogTitle;
	}

}

Given the fact that 1/3rd either are comments or
setters and getters the tightness of the code is
pretty impressive.


Mime
View raw message