[weld-dev] Bean created twice
Arun Gupta
arun.p.gupta at oracle.com
Thu Jul 22 14:26:09 EDT 2010
For the attached simple application (WAR and source), accessing
http://localhost:8080/HelloConversation/faces/index.xhtml creates
ShoppingCart twice. Any idea ?
Utility class is ...
@Named("util")
@ConversationScoped
public class ConvUtil implements Serializable {
@Inject ShoppingCart cart;
public ShoppingCart getCart() {
return cart;
}
}
index.xhtml has ...
<h:inputText value="#{util.cart}" title="name" id="name"
required="true" />
ShoppingCart is ...
@Named
@ConversationScoped
public class ShoppingCart implements Serializable {
public ShoppingCart() {
System.out.println("Creating shopping cart ..." +
Calendar.getInstance().get(Calendar.MILLISECOND));
}
}
At least the log messages like:
INFO: Creating shopping cart ...264
INFO: Creating shopping cart ...265
are printed.
Tried changing the scope of ShoppingCart to RequestScoped but still the
same. Changed @Named to @javax.faces.bean.ManagedBean on ShoppingCart.
What am I not doing correctly ?
-Arun
--
Blog: http://blogs.sun.com/arungupta
Twitter: http://twitter.com/arungupta
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HelloConversation.zip
Type: application/zip
Size: 24029 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/weld-dev/attachments/20100722/49c9cf30/attachment-0001.zip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HelloConversation.war
Type: application/octet-stream
Size: 5413 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/weld-dev/attachments/20100722/49c9cf30/attachment-0001.obj
More information about the weld-dev
mailing list