1 Reply Latest reply on Aug 31, 2007 2:19 AM by Fabian Hagen

    dynamic a4j:support Problem

    Fabian Hagen Newbie

      Hi,

      in my App i'm trying to build up a dynamic dataTable in which the inputfields should get some ajax4jsf support:

      <rich:dataTable id="testTable" binding="#{positionBean.dataTable}" value="#{positionBean.positions}" var="pos" ajaxKeys="#{positionBean.rowSet}"/>


      The whole binding without ajaxsupport works fine and everything is displayed.
      But if i want to add the support i got an exception.
      Here ist the "getDataTable" method:

      public HtmlDataTable getDataTable() {
       HtmlColumn col1 = new HtmlColumn();
       UIOutput desc = new UIOutput();
       String test = "testdaten";
       Application app = FacesContext.getCurrentInstance().getApplication();
      
       ValueBinding vb= app.createValueBinding("#{pos.description}");
       desc.setValueBinding("value", vb);
       desc.setRendererType("javax.faces.Text");
       col1.getChildren().add(desc);
       dataTable.getChildren().add(col1);
      
       //2 columns
       for(int i=0;i<2;i++)
       {
       HtmlAjaxSupport supportClick = new HtmlAjaxSupport();
       HtmlAjaxSupport supportChange = new HtmlAjaxSupport();
       HtmlColumn col = new HtmlColumn();
       UIInput input = new UIInput();
      
       ValueBinding bind = app.createValueBinding("#{pos.output["+ i + "]}");
       ValueBinding bindStyle = app.createValueBinding("#{pos.style["+ i + "]}");
       MethodBinding onClick = app.createMethodBinding("#{pos.showFormula}",null);
       MethodBinding onChange = app.createMethodBinding("#{positionBean.calculateAction}",null);
      
       input.setId("pos" + i);
       input.setValueBinding("value", bind);
       input.setValueBinding("styleClass", bindStyle);
       input.getChildren().add(supportClick);
       //input.setRendererType("javax.faces.Text");
      
       supportChange.setEvent("onclick");
       supportChange.setReRender("pos" + i);
       supportChange.setFocus("pos" +i);
       supportChange.setAction(onClick);
       supportChange.setParent(input);
      
       col.getChildren().add(input);
       dataTable.getChildren().add(col);
       }
      
       return dataTable;
       }
      


      If i remove the "supportChange.setParent(input);" line, the table is displayed but without ajax support.

      Here ist the exception i receive:

      30.08.2007 15:17:04 com.sun.facelets.FaceletViewHandler handleRenderException
      SCHWERWIEGEND: Error Rendering View[/pages/example.jsp]
      javax.faces.el.EvaluationException: AjaxUpdate component not found for id: :testTable:null
       at org.ajax4jsf.framework.ajax.EventValueBinding.getComponent(EventValueBinding.java:108)
       at org.ajax4jsf.framework.ajax.EventValueBinding.getValue(EventValueBinding.java:91)
       at javax.faces.component._ComponentAttributesMap.get(_ComponentAttributesMap.java:249)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderHTMLAttribute(HtmlRendererUtils.java:535)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderHTMLAttributes(HtmlRendererUtils.java:549)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:146)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:286)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChildren(RendererBase.java:262)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:284)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeCellChildren(AbstractRowsRenderer.java:282)
       at org.richfaces.renderkit.AbstractTableRenderer.encodeOneRow(AbstractTableRenderer.java:216)
       at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:86)
       at org.ajax4jsf.ajax.repeat.SequenceDataModel.walk(SequenceDataModel.java:101)
       at org.ajax4jsf.ajax.repeat.UIDataAdaptor.walk(UIDataAdaptor.java:917)
      
      [...]
      
      15:17:05,639 ERROR [Faces Servlet]:253 - Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.el.EvaluationException: AjaxUpdate component not found for id: :testTable:null
       at org.ajax4jsf.framework.ajax.EventValueBinding.getComponent(EventValueBinding.java:108)
       at org.ajax4jsf.framework.ajax.EventValueBinding.getValue(EventValueBinding.java:91)
       at javax.faces.component._ComponentAttributesMap.get(_ComponentAttributesMap.java:249)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderHTMLAttribute(HtmlRendererUtils.java:535)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderHTMLAttributes(HtmlRendererUtils.java:549)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:146)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:286)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChildren(RendererBase.java:262)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:284)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeCellChildren(AbstractRowsRenderer.java:282)
       at org.richfaces.renderkit.AbstractTableRenderer.encodeOneRow(AbstractTableRenderer.java:216)
       at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:86)
      
      [...]
      


      How to bind the support correctly?

        • 1. Re: dynamic a4j:support Problem
          Fabian Hagen Newbie

          Damn, i'm with stupid.

          I found the error.

          It seems to be important, that the support object gets his own id.
          Unlike the definition of the rich:dataTable - component where the support - tag doesn't need an id is needed on the server side.

          supportClick.setId("clickPosvalue");
          supportClick.setEvent("onclick");
          supportClick.setReRender("testForm:testTable");
          supportClick.setFocus("posvalue");
          supportClick.setAction(onClick);
          supportClick.setParent(input);
          


          The only thing which is still not running is the "setFocus" Part.
          There I got a JavaScript Exception in Firefox.

          focusElement.focus is not a function
          [Break on this error] if(focusElement){LOG.debug("Set focus to control ");focusElement.focus();}else{L...