6 Replies Latest reply on Aug 14, 2008 4:41 PM by tomek szzzaaos

    EntityManager and popup

    tomek szzzaaos Newbie


      having problem with EntityManager resolving to null, but its a bit odd.

      public class ShoppingCartBean implements Serializable, ShoppingCart, PopupCloseListener{
           private EntityManager entityManager;
              private Popup popup;
              public ShoppingCartBean(){
              public void popupClosed(PopupDialogBean dialog) {
                     //here entityManager is empty
              public void removeLine() {
                     //entityManager works fine here 

      it only happens in the method popupClosed which is called from another seam component, should I expect the entityManager be not null, is it normal behavior?

      I know it might look bit odd but I can't find other way to implement the modal popup panel(Icefaces) with facelets, could anyone point me to right example?

      Thank you,

        • 1. Re: EntityManager and popup
          Joshua Jackson Master

          How does your facelets page code look like?

          • 2. Re: EntityManager and popup
            tomek szzzaaos Newbie

            Thanks for your replay, ok Lets try... :)

            The main-template.xhtml contains header, footer, content part and the ice:panelPopup, so thats allow to block hole page instead of just one part.

            In the content template(below) there is a leftmenu (which might include  shopping cart and search box),
            and the main
            content which contains the main part of the page which could be product details(or ex. search results).


            <html xmlns="http://www.w3.org/1999/xhtml"
                            <ice:form rendered="#{!empty cart}">
                                 <ice:panelPopup styleClass="panelPopup"
                                        //simple yes/no question here
                            <div class="page">
                                    <div class="header">      
                                            <ui:include src="header.xhtml">
                                                    <ui:param name="projectName" value="Webshop" />
                                    <div class="content">                             
                                            <ui:insert name="content" />
                                    <div class="footer">
                                            <ui:include src="footer.xhtml" />

            and the content-template.jspx looks like:

            <div xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:ui="http://java.sun.com/jsf/facelets" style="height:100%"
                    <div class="left_content">
                            <ice:form partialSubmit="true">
                                    <div class="left_content_header">#{leftContentHeader}</div>
                                    <ui:insert name="left_content"/>
                    <div class="center_content">                      
                            <ice:form partialSubmit="true" enctype="multipart/form-data">
                                    <div class="center_content_header">#{contentHeader}</div>
                                    <ui:insert name="center_content"/>
                    <div id="sidebar">                                
                            <ui:insert name="sidebar" />

            and the part where Im trying to display the popup from:

            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                    <ui:define name="content">
                            <ui:decorate template="layout/content-template.jspx">
                                    <ui:define name="left_menu">
                                            <ui:include src="ui-components/search-box.xhtml"></ui:include>
                                            <ui:include src="ui-components/cart-box.xhtml" />
                                    <ui:define name="main_content">
                                         //search results, product info etc.
                                         //the popup panel is called from here and would be great if I could add it here
                                            <div class="stock_display">
                                                    <ice:panelGrid columns="1">                                       
                                                            <ice:panelGrid columns="2">
                                                                    <s:graphicImage styleClass="image"
                                                                            rendered="#{not empty stock.image.activeFullsizeImage}" 

            • 3. Re: EntityManager and popup
              judy guglielmin Novice

              You might try the property clientOnly for the panelPopup and set it to true.(this is new with ICEfaces1.7.1)

              This performs better in standard jsf request scope (for Seam).  But also, it is also not such a great idea to put the partialSubmit to true on the form itself.  It's better practice to place it only on the components you really need to validate,etc via ajax. Do you have other beans which are bypassing the interceptors active at this time?  This can also affect injection when using ICEfaces.

              • 4. Re: EntityManager and popup
                tomek szzzaaos Newbie

                It took me a while to be able to answer to your question, cos I'm just starting with seam.

                Anyway I have no other beans bypassing the interceptors. Other thing is that not only EntityManager is null, but any other seam component injected using @In is null as well, apart of @Logger private Log log.
                So I'm doing something wrong, could try anyone to spot the problem?

                Here are my popup classes:

                public class PopupAction implements Popup, Serializable  {
                     private PopupDialogBean popupDialog;
                     public PopupAction() {
                          popupDialog = new PopupDialogBean();
                     public PopupDialogBean getDialog() {
                          return popupDialog;
                     public void setDialog(PopupDialogBean popupDialog) {
                          this.popupDialog = popupDialog;

                public class PopupDialogBean implements Serializable {
                     public enum Type{
                     private static final long     serialVersionUID     = -7871399779158178271L;
                     private boolean visible;
                     private boolean modal;
                     private boolean draggable;
                        private boolean autoCentre;
                        private String text;
                        private String header;
                        private boolean booleanResponse;
                        private Type type;
                     private Set<PopupCloseListener> closeListeners;
                     public PopupDialogBean() {
                          closeListeners = new HashSet<PopupCloseListener>(); 
                     public void close() {
                          visible = false;
                          for(PopupCloseListener listener: closeListeners) {
                     public void addCloseListener(PopupCloseListener l) {
                     public void removeCloseListener(PopupCloseListener l) {
                     public boolean booleanResponse() {
                          return booleanResponse;
                        //getters and setters removed

                • 5. Re: EntityManager and popup
                  judy guglielmin Novice

                  Some of the ajax functions with ICEfaces bypass the interceptors, but you will get the injection on the creation of the bean.  You could copy them on initialization into other attributes in an init method.  This doesn't have to be a session-scoped bean by the way:-

                  public void init(){
                  //put your stuff from your contstructor here and check the values of your
                  // injected attributes.  You can also copy them into other non-injected class 

                  If you want more detailed assistance, you could always post a simple sample of your app to the ICEfaces forum

                  • 6. Re: EntityManager and popup
                    tomek szzzaaos Newbie

                    Thanks for help, will post to the ICEfaces forum for the further help.

                    Best regards,