The back button I did some research into. I don't know if its going to be fixed in the sense that the navigation would work like a "classic" app's back button would work as much as it'll prevent a user from submitting a form that they've "backed" to.
Its not that I want you to convince me of using one thing or another, or a religious discussion. I'm just trying to get a better understanding of the systems, how people are really using them, etc.
I like JSF, but for the navigation piece. By "navigation piece" I only mean the book-learned method of walking a database by way of dataTable tags. The rest of it is ok by me. In fact, I'm not sure I see the value of a struts integration piece for a new app. I looked at struts-faces (briefly), and I'm not even really clear on what it does.
So, back to my original question. I mean, I understand the model is just different, but the pattern I've put out there is pretty common and I think could use a better solution. Let me set up a more clear example:
page: /someapp/FooList.jsp
displays: A list of foos found in the database. Each foo links to a foo edit page (/someapp/FooEdit.jsp). It sends a param 'fooId' to the request on the query
string.
page: /someapp/FooEdit.jsp
displays: A particular foo. Takes a 'fooId' argument passed (or bombs if none passed). The user can edit properties of foo.
Now, to model this with "classic" jsp, we could create a java bean for FooList, which has a method that returns a list of foos. This method would simply connect to the database and create this list from current data. The jsp page would display each foo along with a link to...
/someapp/FooEdit.jsp?fooId=xxx
******JSF version******
The jsf version (again, what I got from at least the O'reilly book) would work as follows:
page: /someapp/FooList.jsf (still a jsp page, but mapped)
displays: A dataTable tag backed by a DataModel with a list of foos. Clicking on a commandLink will cause an action method to put a particular foo into the user's session and pass them to the edit page
page: /someapp/FooEdit.jsf
displays: The edit page. Shows the foo in the session (put there by the list page).
The problem I've had here all along is that, using the standard dataTable:
1) If you keep the list or DataModel in the session and not pull it from the database, your data will be consistent when you click on the link in FooList, but in order to see an update of current data in the database, you need to have an explicit link somewhere on the page to tell your code to dump the current data and reload. This is IMHO unnatural for a webapp, and keeps a lot of data sitting around in the session.
2) If you grab the list every time from the database, this will keep the data in the page current but has a couple problems. When you click the link, you need to regrab the whole list to get your particular Foo. That's just a performance problem. The big problem is that if the data has been updated since you saw it, you could be grabbing the wrong record. Like you click on foo with id 7 but you actually get foo id 8.
Now, we've had this discussion as mentioned before. The solution was the myfaces custom table. That does solve the data update problem in #2 above, so your data will be consistent. However, it doesn't do anything about the performance issue. You still need to grab the whole data set. Its actually slightly worse because you also have to scan the data and look for your id. Right? Not the end of the world, but if you had a lot of users hitting a site, I wouldn't recommend it. That, and not everybody is using myfaces or knows to use that custom tag.
Now, why did I go through all that? I don't want anybody to convince me to use or not use JSF. I'm just pointing out what I think is a place for improvement, or at least for a different way of implementing it. Either that, or somebody to say, "no, your assumptions are wrong here. Its not doing x. Its doing y.". Either that or, "well, there's a performance issue, but the development efficiency inherent in x might be worth it. Its a tradeoff". At the very least I think discussion is good. At best it might turn into some type of new component specific to the problem.
I like Dogs and pizza. Cats are not my bag. Girls with a single cat are ok, but multiple is a red flag.
I played football, but get bored watching sports.