[JBoss Seam] - Re: pages-2.0.xsd schema - undocumented features
by wschwendt
"hstang" wrote :
| anonymous wrote : The "in"-element can have 3 attributes:
| |
| | name (required)
| | value (required)
| | scope (optional)
|
| name is the context variable name, e.g. a component name
|
| value is a value expression where you want to set that that looked up component
|
| so [in name="foo" value="#{bar.foo}"] will set your component named "foo" to your component named "bar"'s foo
Thanks, hstang. Makes sense. Before posting my original question above, I had already thought about whether the in-element could be simply meant to bind a context variable to a value (e.g. seam component), as some sort of declarative prerender logic. But I didn't want to post my wild guess.
Anyway, if your assumption is true (have not tested it yet), the name of the element ("in") is a misnomer, as there is actually no injection. Only the value of a context variable is set.
But I don't know whether a better name for this element would be something like "setContextVar", for example.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060188#4060188
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060188
18Â years, 9Â months
[JBoss Seam] - Re: Using log4j's NDC
by trautmane
For what it is worth, here is what I'm currently using with Seam 1.2.1 to add the Seam identity username to the log4j mapped diagnostic context:
| @Startup
| @Scope(ScopeType.APPLICATION)
| @Name("some.package.loggingContextFilter")
| @Intercept(InterceptionType.NEVER)
| @Install
| public class LoggingContextFilter extends AbstractFilter {
|
| /** Identifier for the username "diagnostic context". */
| public static final String USERNAME_CONTEXT = "username";
|
| public void doFilter(ServletRequest servletRequest,
| ServletResponse servletResponse,
| FilterChain filterChain)
| throws IOException, ServletException {
|
| if (servletRequest instanceof HttpServletRequest) {
| HttpServletRequest req = (HttpServletRequest) servletRequest;
| String path = req.getServletPath();
| if ((path != null) && (path.endsWith(".seam"))) {
| HttpSession session = req.getSession();
| Object o = session.getAttribute("org.jboss.seam.security.identity");
| if (o instanceof Identity) {
| Identity identity = (Identity) o;
| String username = identity.getUsername();
| if (username != null) {
| MDC.put(USERNAME_CONTEXT, username);
| }
| }
| }
| }
|
| filterChain.doFilter(servletRequest, servletResponse);
|
| MDC.remove(USERNAME_CONTEXT);
| }
| }
|
You could do something similar with the NDC if you wanted.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060184#4060184
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060184
18Â years, 9Â months