[jboss-user] [JBoss Seam] - Re: Question regarding performance and multiple JavaBean bij
pnorman4
do-not-reply at jboss.com
Tue Apr 24 19:09:25 EDT 2007
I've done some research and a mini test application to show my results:
The bean
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Out;
| import org.jboss.seam.log.Log;
| import javax.faces.context.FacesContext;
|
| @Name("testBean")
| public class TestBean {
| @Logger Log log;
|
| @In
| public void setFacesContext(FacesContext facesContext) {
| log.debug(" === Inject: @In setFacesContext.");
| }
|
| @Out
| private String testValue = "test value";
|
| public String getTestValue() {
| return testValue;
| }
| }
|
The view
| <?xml version="1.0" ?>
| <jsp:root version="2.0"
| xmlns="http://www.w3.org/1999/xhtml"
| xmlns:jsp="http://java.sun.com/JSP/Page"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:ui="http://java.sun.com/jsf/facelets">
| <html>
| <body>
| <f:view>
| <h1><h:outputText value="Test Page"/></h1>
| <h:form id="form1">
| <h1>Bean access</h1>
| <h:outputText value="Property: #{testBean.testValue}" /><br/>
| <h:outputText value="Property: #{testBean.testValue}" /><br/>
| <h:outputText value="@Out Value: #{testValue}" /><br/>
| <h:outputText value="@Out Value: #{testValue}" /><br/>
| <h:outputText value="@Out Value: #{testValue}" /><br/>
| </h:form>
| </f:view>
| </body>
| </html>
| </jsp:root>
|
The result is that facesContext is injected 4 times - twice for each #{testBean.testValue}. Adding another #{testBean.testValue} will force two more injections!
The #{testValue} on the other hand does not enforce any injections.
Now I wonder:
* Is this behavior a bug?
* Do I get this behaviour because I'm using JavaBeans instead of EJB3 SessionBeans?
Also:
* To get the @Out outjection to work, I must first access the bean (with #{testBean.testValue} for instance). Is there another way to "wake up" the bean so that @Out works?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040381#4040381
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4040381
More information about the jboss-user
mailing list