[jboss-user] [JBoss Seam] - Re: Some philosophy on the context name and access to Java B

toni do-not-reply at jboss.com
Fri Nov 24 08:46:58 EST 2006


Let me give you a short example to put the above said into a meanigfull context: 

Lets says I have a database table, which stores customers all of which I would like to list row by row in a JSF table, which is contained inside a single JSP page. Each row also contains action links which represent actions that can be performed on a customer, like edit, delelete, display and "add another address".

For the JSP page I only need a reference to a DataModel.

The reference to the instance of the DataModel should be obtained from a "context variable", which references an "instance" of a class, which implements DataModel and is kept in one of the 5 seam contexts. 

If I name the jsp page "displayCustomers.jsp" and call it via a GET request, then I run into the fact, that the context variable is not accessible, because no seam component get's referenced in a MVC pull fashion from the page. 

That's what I meant by saying ".jsp pages, which do not contain any value or method binding".

Because no calls to a seam component have been made from the jsp page, the no context variable for the DataModel has not been set. 

I could use a Page Action, to achievie this so that it calls some method on a seam component that sets the context variable and loads the clients from the database before the .jsp file gets rendered like this:

@DataModel @Out
@Factory("loadClientsFromDatabase")
List clients;

But I find that cumbersome, because I have so many pages which list entities the same fashion.

And using "pull-MVC" defeats the purpose of the @DataModel, because the idea of using it is not having to use "pull-MVC". I mean if I use something like:

 <h:dataTable value="#{seamcomponent.loadClientsViaPullMVC}" var="c" rendered="#{seamcomponent.loadClientsViaPullMVC.rowCount>0}">

Then I don't need a @DataModel inside "seamcomponent" anymore. I also noticed, that it is not possible to use @DataModelSelection in a seam component, which does not also contain the @DataModel annotation.

That I find also strange, because I can think of many use cases in which you would want another seam component to retrieve the selected Customer to perform some actions on him.

For example, if I had a "action link" add address, then in the AddAdressAction I would want to place a @DataModelSelection to get the selected Customer from. If I do this currently, then I won't be able to easily retrieve the customer. I have to put "AddAddressAction.add()" method into the Seam Bean, which has the DataModel, where it does not belong and increases component dependancy.

I hope in this light my last post makes more sense?!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3988401#3988401

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3988401



More information about the jboss-user mailing list