2 Replies Latest reply on Jan 29, 2008 4:55 AM by ilya_shaikovsky

    Problem setting ActionExpression

    sdelvalle

      Hi all, I'm trying to create a page segment by creating objects in Java code, so I created a jspx as following

      ...
       <rich:panel binding="#{mainPanel}"/>
      ...


      The mainPanel class is defined as

      public class MainPanel extends HtmlPanel {
       public void generatePanel() {
       ...
       HtmlForm form = new HtmlForm();
       form.setId("listForm");
      
       HtmlDatascroller scroller = new HtmlDatascroller();
       scroller.setId("listScroller");
       scroller.setFor("listTable");
       scroller.setMaxPages(15);
       scroller.setStyle("width: 100%");
       scroller.setAjaxSingle(true);
       scroller.setRenderIfSinglePage(false);
       form.getChildren().add(scroller);
      
       HtmlDataTable dataTable = new HtmlDataTable();
       dataTable.setId("listTable");
       dataTable.setRows(20);
       dataTable.setWidth("100%");
       dataTable.setVar("item");
       DataModel dm = new DataModel(schema, values);
       dm.addDataModelListener(this);
       dataTable.setValue(dm);
       HtmlAjaxSupport support = new HtmlAjaxSupport();
       support.setId("rowAction");
       support.setActionExpression(Util.createMethodExpression(
       "#{mainPanel.selectRow}", String.class));
       support.setAjaxSingle(true);
       support.setEvent("onRowClick");
       support.setReRender("tabPanel");
       dataTable.getChildren().add(support);
       ...
       }
      
       public String selectRow() {
       ...
       }
      }


      The mainPanel bean scope is session

      The problem I'm having is the method selectRow is never called when I click on a row in the table, I have tried also implementing the DataModelListener interface in MainPanel, and adding dm.addDataModelListener(this); in the datamodel definition, having same result. Also tried implementing ActionListener, and adding support.addActionListener(this); to the ajaxsupport definition.

      I don't know what I'm doing wrong.

      Thanks in advance.

      Sergio

        • 1. Re: Problem setting ActionExpression
          sdelvalle

          Sorry, forgot to specify environment

          RichFaces 3.1.3
          Facelets 1.1.13
          JSF 1.2
          GlassFish V2U1

          Sergio

          • 2. Re: Problem setting ActionExpression
            ilya_shaikovsky

            you should add support as facet instead of children.

            this :

            inputText.setValue("test");
             HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();
             ajaxSupport.setId("support");
             ajaxSupport.setActionExpression(
             FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createMethodExpression(
             FacesContext.getCurrentInstance().getELContext(), "#{bean.action}", String.class, new Class[] {}));
             ajaxSupport.setEvent("onkeyup");
             ajaxSupport.setReRender("output");
             inputText.getFacets().put("a4jsupport", ajaxSupport);
            


            should works fine