0 Replies Latest reply on Oct 14, 2008 5:59 AM by Mari Muthu Arumagapandian

    Dynamic dropdown menu Problem......

    Mari Muthu Arumagapandian Newbie

      Hai,

      we created dynamic drop down menu using jsf with rich faces.
      In this jsf,


      <rich:dropDownMenu binding="#{MenuLists.master}">
       </rich:dropDownMenu>




      in java,


      public HtmlDropDownMenu getMaster() {
       System.out.println("inside getMaster");
       try
       {
       if(master==null)
       {
       master = new HtmlDropDownMenu();
       //menu.setStyle("border:1px solid #BCD1FF");
       master.setValue("Master");
       session1=HibernateSessionFactory.getSession();
       Query query = session1.createQuery("select amod.moduleMasterName from " +
       " AdmModuleMaster amod,AdmCategoryMaster acat where acat.categoryName='Master' " +
       "and amod.admCategoryMaster=acat");
       System.out.println("query"+query);
      
       List modList=(List) query.list();
      
       for(int i=0;i<modList.size();i++)
       {
       HtmlMenuGroup oHtmlMenuGroup=new HtmlMenuGroup();
       //Menugroup name from databse
       oHtmlMenuGroup.setValue(modList.get(i));
       Query query1 = session1.createQuery("select adfn.functionMasterName,admofn.moduleJspName from " +
       " AdmModuleMaster amod,AdmFunctionMaster adfn,AdmModuleFunctionMaster admofn where amod.moduleMasterName='"+modList.get(i)+"' " +
       "and admofn.admFunctionMaster=adfn and admofn.admModuleMaster=amod");
       System.out.println("query"+query);
       //List fnList=(List) query.list();
       //for(int j=0;i<fnList.size();j++)
       for (Iterator<?> iter = query1.iterate();iter.hasNext();)
       {
       Object[] row = (Object[])iter.next();
       HtmlMenuItem menuItem = new HtmlMenuItem();
       //Menuitem name from databse
       menuItem.setValue((String)row[0]);
       menuItem.setSubmitMode("none");
       //While click this item it will call another page.That page name taken from database
       menuItem.setOnclick("document.location.href='"+(String)row[1]+"'");
       oHtmlMenuGroup.getChildren().add(menuItem);
       }
       master.getChildren().add(oHtmlMenuGroup);
       }
       }
      
       }
       catch (Exception e) {
       System.out.println("Exception .."+e);
       }
       finally
       {
       return master;
       }
       }



      In faces config,


      <managed-bean>
       <managed-bean-name>MenuLists</managed-bean-name>
       <managed-bean-class>com.erp.admin.MenuLists</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       </managed-bean>


      It displayed drop down menu,.
      If we click menu item it will forward correponding page.
      After forwared, if we call any action in that forwared page, it shows the following Exception,


      --------------------------------------------------------------------------------

      exception

      javax.servlet.ServletException: /header.jsp(111,12) '#{MenuLists.master}' {0} object is read only base com.erp.admin.MenuLists@7ec736 property master
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
      com.erp.listener.ResponseFilter.doFilter(ResponseFilter.java:67)
      com.erp.listener.SessionExpiredFilter.doFilter(SessionExpiredFilter.java:171)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      root cause

      org.apache.jasper.el.JspPropertyNotWritableException: /header.jsp(111,12) '#{MenuLists.master}' {0} object is read only base com.erp.admin.MenuLists@7ec736 property master
      org.apache.jasper.el.JspValueExpression.setValue(JspValueExpression.java:88)
      com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:240)
      com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:245)
      com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:245)
      com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:245)
      com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:245)
      com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:195)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
      com.erp.listener.ResponseFilter.doFilter(ResponseFilter.java:67)
      com.erp.listener.SessionExpiredFilter.doFilter(SessionExpiredFilter.java:171)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      --------------------------------------------------------------------------------