7 Replies Latest reply on Jan 19, 2009 12:01 PM by ethnarch

    MethodExpressionActionListener programmatically created work

    ethnarch

      I am programmatically building up some components to display. Along the way i am trying to add a method expression to some of the components to perform an action.

      Also in all browser I will enter the into the backing beans phase events. Only in IE 6 however it actually hits the bizRuleMgmt.onSelectRulePart method. Very strange behavior is this a bug or something I am doing incorrectly?


      versions:
      jsf 1.2
      richfaces 3.1.3.GA

      Here is some of the code I am using.

       public UIComponent processRulePart(BRPart part){
       HtmlPanelMenuItem panelMenuItem = new HtmlPanelMenuItem();
       String subjectColumn = part.getFkSubjectColDefId().getName();
       String comparitor = part.getFkBRComparitor().getName();
       String value = part.getFkValueColRefId().getColName();
       MethodExpression methodExpression = getMethodExpression("#{bizRuleMgmt.onSelectRulePart}");
       MethodExpressionActionListener actionListener = new MethodExpressionActionListener(methodExpression);
       panelMenuItem.addActionListener(actionListener);
       panelMenuItem.setLabel(subjectColumn+" "+comparitor+" "+value);
       return panelMenuItem;
       }
      
       public MethodExpression getMethodExpression(String expression){
       Application app = context.getApplication();
       ExpressionFactory expressionFactory = app.getExpressionFactory();
       Class [] classList=new Class[1];
       classList[0]=ActionEvent.class;
       MethodExpression methodExpression = expressionFactory.createMethodExpression(
       context.getELContext(),
       expression, null, classList);
       return methodExpression;
       }
      




        • 1. Re: MethodExpressionActionListener programmatically created
          ethnarch

          I probably should have posted this code also, this is where I am generating the new object go easy on me if this is all wrong. The summaryFactory is where the code above lives.


          public void encodeEnd(FacesContext context){
           BizRulesSummaryPanelFactory summaryFactory = new BizRulesSummaryPanelFactory();
           HtmlOutputLabel p = new HtmlOutputLabel();
           p.setValue("test");
           BRRule brRule = (BRRule)getAttributes().get("brRule");
          
           try{
           if(brRule!=null){
           UIComponent component = summaryFactory.build(this, brRule, context);
           component.encodeAll(context);
           this.getChildren().add(component);
           }
           this.getChildren().add(p);
           }catch(IOException e){
           logger.error(e);
           }
           }
          


          • 2. Re: MethodExpressionActionListener programmatically created
            ethnarch

            I tried doing this another way by binding my assembled parts to a panelmenu through the backing bean. This gave me the same result. It seems to be rather easily reproducible. Here is my new code.

            I am not using the binding tag on the jsp page instead I am just using the tag as a place holder.

            <rich:panelMenu id="ruleSummaryPanel"/>



            Then in my backing bean I am doing this.
             HtmlPanelMenu panelMenu =
             (HtmlPanelMenu)FacesContext.getCurrentInstance().getViewRoot().findComponent("frmMain:ruleSummaryPanel");
             if(panelMenu!=null){
             Application application = FacesContext.getCurrentInstance().getApplication();
             HtmlPanelMenuGroup panelMenuGroup =
             (HtmlPanelMenuGroup)application.createComponent(HtmlPanelMenuGroup.COMPONENT_TYPE);
             panelMenuGroup.setLabel("test01");
             HtmlPanelMenuItem panelItem =
             (HtmlPanelMenuItem)application.createComponent(HtmlPanelMenuItem.COMPONENT_TYPE);
             //create method expression
             ExpressionFactory expressionFactory = application.getExpressionFactory();
             Class [] classList=new Class[1];
             classList[0]=ActionEvent.class;
             MethodExpression methodExpression = expressionFactory.createMethodExpression(
             FacesContext.getCurrentInstance().getELContext(),
             "#{ruleMgmt.onSelectSection}", null, classList);
             MethodExpressionActionListener actionListener = new MethodExpressionActionListener(methodExpression);
            
            
             panelMenuGroup.getChildren().add(panelItem);
             panelItem.addActionListener(actionListener);
             panelMenu.getChildren().add(panelMenuGroup);


            The problem is pretty easily reproduced in this way. The actionListener will work propertly in ie6 and 7 but not in any other browsers. Does anybody know why?

            • 3. Re: MethodExpressionActionListener programmatically created
              nbelaevski

              Hi,

              Probably a bug in 3.1.3.GA. What about 3.1.6, does it work there?

              • 4. Re: MethodExpressionActionListener programmatically created
                ethnarch

                I haven't tried that, but I probably should have thanks I'll let you know.

                • 5. Re: MethodExpressionActionListener programmatically created
                  nbelaevski

                  Right, sorry, thank you in advance for checking with 3.1.6.SR1! BTW, the problem looks similar to: https://jira.jboss.org/jira/browse/RF-4239. Have you tried with FF2/Safari or Opera?

                  • 6. Re: MethodExpressionActionListener programmatically created
                    ethnarch

                    3.1.6
                    gives me the same problem

                    I tried it in FF3, Opera and Chrome. Only IE 6 and 7 work.

                    BTW, the problem looks similar to: https://jira.jboss.org/jira/browse/RF-4239

                    That's interesting I never tried doing this hardcoded or with a different type of component. I might try this some other other way.

                    • 7. Re: MethodExpressionActionListener programmatically created
                      ethnarch

                      I switched out the HtmlPanelMenuItem for an HtmlCommandButton and this works. I think this bug matches my problem.