[jboss-user] [JBoss Seam] - Seam Design Question

tony.herstell@gmail.com do-not-reply at jboss.com
Wed Feb 6 19:05:06 EST 2008


1/

I have a number of resources
say:
Enum {A,B,C,D,E}

I have "Hour Slots" when they are being used.

I have users that can book the resource.

I have created a Conversational Bean to select the resource(s) and now want a show the current bookings (for certain bookings this will be on same page using Ajax as only can book upto 14 days in advance)... so the user can book into slot(s) that are free (this gets more complicated when I have to auto-fit complicated bookings but we won't go there).

My Proposed Solution:
Create a Session Scoped bean (ResourceAllocation) with some members:
AHourSlots
BHourSlots
CHourSlots
etc.

I chose Session as the site won't be hammered so I can afford a few database hits (and storage use) when new users hit the site to book a resource. (I can always move over to Application if need be later)... For now I somehow feel safer (VMS days) to throw away the resources when the session dies as any bugs in keeping it updated are localised to the max duration of a session ;)

I want in my .xhtml page to just have access to the coped variables like:
AHourSlots
BHourSlots
CHourSlots
etc.
And I believe that if I have them in ResourceAllocationImpl anotated with @Factory(scope=ScopeType.SESSION, value="AAllocation")
then this would do the trick.

Is this course likely to cause problems.
(prefer not to have things in components.xml if I can help it as too disjoint from the code).

2/

As the page is ajaxified I end up with the booking all on one page, BUT I want to force the user to log in (or register) before the booking is saved and I cant see a way to do this unless I force them to go to a page which has a loggedIn guard (me thinks a confirmation page)... Is there a way programatically to do summat like this:

public String saveTheBooking() {
   String nextNavigationPort = null;
   if (!loggedIn) {
      seam.core.nestToLogin();
   }
   if (loggedIn) {
      // Park the sucker under the users name
     em.persist(booking);
     nextNavigationPort = "home";
     return nextNavigationPort;
   } else {
      // Message the user to say refused to login so no-way-hozay
     ...
   }
}

This would be kinda useful for parking the booking part-through (as its quite complicated!)



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

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



More information about the jboss-user mailing list