4 Replies Latest reply on Jun 18, 2014 9:04 AM by Alfred Oliver

    migrating from richfaces 3 to richfaces 4.3.6 PopupPanel

    Alfred Oliver Newbie

      I'm migrating from richfaces 3 to richfaces 4.3.6 and does not work within a CommandButton PopupPanel, any ideas?


      public void aviso() {
             
              FacesContext context = FacesContext.getCurrentInstance();   
              HtmlForm frm = (HtmlForm)context.getViewRoot().findComponent("idform");      
              HtmlOutputText outputText = new HtmlOutputText();
              outputText.setValue("Test");      
             
              UICommandButton command = (UICommandButton) context.getApplication().createComponent(context, UICommandButton.COMPONENT_TYPE,
                                      "org.richfaces.UICommandButtonRenderer");
             
              command.setId("Carles_1");              
             //Action
              MethodExpression methodExpr =  context.getApplication().getExpressionFactory().createMethodExpression
                  (context.getELContext(),   "#{cotx.logout}", null ,new Class[]{ javax.faces.event.ActionEvent.class});
               //Listener
              command.addActionListener(new MethodExpressionActionListener(methodExpr));           
                             
              command.setStyleClass("button");
              command.setValue("CERRAR_carles");
                             
              UIPopupPanel modalPanel = (UIPopupPanel) context.getApplication().createComponent(context, UIPopupPanel.COMPONENT_TYPE, "org.richfaces.PopupPanelRenderer");      
              modalPanel.setId("carles");      
              modalPanel.setAutosized(true);      
              modalPanel.setShow(true);      
              modalPanel.setModal(true);                      
              modalPanel.getFacets().put("header", outputText);      
              modalPanel.getChildren().add(command);      
              frm.getChildren().add(modalPanel);
      }
      
        • 1. Re: migrating from richfaces 3 to richfaces 4.3.6 PopupPanel
          Michal Petrov Master

          I'm not sure what your issue is but the command button renderer type is "org.richfaces.CommandButtonRenderer". Was that the problem?

          • 2. Re: migrating from richfaces 3 to richfaces 4.3.6 PopupPanel
            Alfred Oliver Newbie

            Thanks for your reply.


            The problem is that the CommandButton does not execute the action "# {cotx.logout}". within the PopupPanel.

            popup.png

            • 3. Re: migrating from richfaces 3 to richfaces 4.3.6 PopupPanel
              liumin hu Master

              hi,

              It seems that you put the popuppanel in the form without set domattachement attribute.

              • 4. Re: Re: migrating from richfaces 3 to richfaces 4.3.6 PopupPanel
                Alfred Oliver Newbie

                Thank you very much, it works.

                Now there is another problem, not close the popuppanel. logout() and closedModalPanel(String pid) methods work


                this worked with richfaces 3.x


                public void logout(ActionEvent event) {

                            

                    Object obj = event.getSource();

                    

                    UICommandButton command = (UICommandButton)obj;

                        

                    //Closed Modal Panel

                    TplModalPanelParent panel = new TplModalPanelParent();

                    panel.closedModalPanel("carles");

                                            

                    command.setRender("idform");

                 

                }

                 

                //Closed modal panel

                public void closedModalPanel(String pid){

                    

                    int numberChildren = frm.getChildCount();

                              

                    if (numberChildren > 0) {

                 

                          UIComponent component = null;

                            

                        List<UIComponent> lstChildren = frm.getChildren();

                            

                        while (--numberChildren >= 0) {

                            

                            component = (UIComponent) lstChildren.get(numberChildren);

                                                                

                            if (component.getId().equals(pid.substring(3))) {

                                                            

                                lstChildren.remove(numberChildren);

                                continue;

                            }

                          }

                }