-
1. Re: Calling a method when a Session scope starts?
smokingapipe Aug 18, 2006 11:28 PM (in response to smokingapipe)Actually...
It looks like I could make up a Stateless bean, with scope=EVENT. That bean would be in scope for every single page request within the Seam application, right? So that bean would be present at every one.
Then I could annotate a member of that bean with @RequestParameter.
From there I'm not sure what to do. Could I use the @Observer annotation somehow so that a method of the bean would be called on every request?
Alternatively, I could put @RequestParameter on a getter/setter pair, and the setter could do the logic needed. The advantage is that the method would only be called when the affiliateId parameter is actually set.
I guess I'm trying to use a bean as a smart / light filter, which seems like it should be possible. -
2. Re: Calling a method when a Session scope starts?
smokingapipe Aug 19, 2006 12:05 AM (in response to smokingapipe)Ok, I tried that and it didn't work. The bean didn't get used.
Next I'm going to try to force the bean to be used on the page by using a value from it somewhere. -
3. Re: Calling a method when a Session scope starts?
pmuir Aug 21, 2006 4:35 AM (in response to smokingapipe)How about using page actions?
-
4. Re: Calling a method when a Session scope starts?
smokingapipe Aug 21, 2006 4:41 AM (in response to smokingapipe)That's what I ended up doing, and it works beautifully. It's a lot more elegant than writing a filter. No filter, and with about 5 lines of code, I can check a database and set a cookie. It does create a new object with every request, but it's a lightweight object so I don't think that matters.
I haven't found any docs that give a good description of what you can do in the pages.xml file, but obviously this part of it is pretty cool.
I assume that these components could do other stuff like do redirects. The ultimate in cool is if they could do effectively a JSP include, so I could use it for my SEO needs, and hide parameters within URLs (ie, map /blog-5885.seam to /blog-entry.jsp, and use the 5885 to set a parameter in it). I'm guess that's possible but I have no idea how, because as I said, there are no docs for what you can do in the pages.xml file.
I still have no idea how Seam figures out whether it creates an instance of a component for a given page or not. It seems like it is buggy, because I can create components with scope of EVENT, and they are not always accessible within a page. I don't get it. -
5. Re: Calling a method when a Session scope starts?
raja05 Aug 21, 2006 7:16 AM (in response to smokingapipe)"SmokingAPipe" wrote:
I assume that these components could do other stuff like do redirects. The ultimate in cool is if they could do effectively a JSP include, so I could use it for my SEO needs, and hide parameters within URLs (ie, map /blog-5885.seam to /blog-entry.jsp, and use the 5885 to set a parameter in it). I'm guess that's possible but I have no idea how, because as I said, there are no docs for what you can do in the pages.xml file.
This is possible and IIRC is also documented. You can have a page action that responds to blog-* and have that action return a totally different view id to be processed. For that view, you could use 5885 or whatever as a parameter.