2 Replies Latest reply on Oct 30, 2011 2:22 PM by Tom Giberius

    How is componentControl working?

    Tom Giberius Newbie

      I want to deselect a row in a table.

       

      I tried to do this with componentControl, the target landenTabel is a table in the form.

      When I add this code:

      * The actionListener is not called anymore (whitout componentControl it is called)

      * When I change from row an error is thrown

       

       

      My code:

      <a4j:commandButton id             ="refreshbutton"

                                                     value          ="#{tekst.refresh}"

                                                     actionListener ="#{landBean.refresh('alles')}"

                                                     execute        ="refreshbutton"

                                                     render         ="form"

                                                     style          ="margin-left: 10px"

                                                     >

                                      <rich:componentControl target="landenTabel"

                                                             operation="deselectRow"

                                                             event="click"

                                                             />

                                  </a4j:commandButton>

       

      Question: am I doing something wrong?

       

      The Error from org.richfaces.log.Context:

       

      For input string: "NaN"

      java.lang.NumberFormatException: For input string: "NaN"

      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)

      at java.lang.Integer.parseInt(Integer.java:492)

      at java.lang.Integer.parseInt(Integer.java:527)

      at org.richfaces.renderkit.SelectionRenderer$ClientSelection.<init>(SelectionRenderer.java:69)

      at org.richfaces.renderkit.SelectionRenderer.doDecode(SelectionRenderer.java:172)

      at org.richfaces.renderkit.ExtendedDataTableRenderer.doDecode(ExtendedDataTableRenderer.java:838)

      at org.richfaces.renderkit.RendererBase.decode(RendererBase.java:82)

      at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)

      at org.richfaces.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:824)

      at javax.faces.component.UIForm.processDecodes(UIForm.java:225)

      at org.richfaces.context.PartialViewExecuteVisitCallback.visit(PartialViewExecuteVisitCallback.java:55)

      at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:337)

      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1589)

      at javax.faces.component.UIForm.visitTree(UIForm.java:335)

      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)

      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)

      at org.richfaces.context.ExtendedPartialViewContextImpl.executeComponents(ExtendedPartialViewContextImpl.java:249)

      at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialExecutePhase(ExtendedPartialViewContextImpl.java:229)

      at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:208)

      at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)

      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)

      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)

      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)

      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)

      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)

      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)

      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)

      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)

      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)

      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)

      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

      at java.lang.Thread.run(Thread.java:722)

        • 1. Re: How is componentControl working?
          Tom Giberius Newbie

          I have used an ohter Java Script API call

           

          <rich:componentControl target="landenTabel"
                                   operation="selectRow"
                                    event="click"
                                  >
               <f:param value="1" />
          </rich:componentControl>

           

          This call seems to do something but on the visual it does not have the expected result:

          * An active row in a table has the following class: rf_edt_r_sel and rf_edt_r_act, this gives the active row a different look.

          * Now if above operation is fired then row 1 gets these classes but the wich was active keeps also rf_edt_r_sel and rf_edt_r_act, now it looks like that two rows are selected, or this is intended behaviour.

           

          What

           

          I want is when I press the refresh button that the visual selection (rf_edt_r_sel and rf_edt_r_act) is removed. In my bean I keep track of the active record, after pushing refresh I do not want a record to be selected.

           

          How can I remove the visual record selection ( e.g. remove the css class rf_edt_r_sel and rf_edt_r_act)

           

               

            

          • 2. Re: How is componentControl working?
            Tom Giberius Newbie

            I solved it with some Java Script:

             

            function clearSelectedRow(p_tabel){

              

                p_tabel = p_tabel + ":body";

                var tabel = document.getElementById(p_tabel);

                loopDoorDom(tabel);

            }

             

            function loopDoorDom(p_node) {

               

                    var kinderen = p_node.childNodes;

                    for( var i=0 ; i < kinderen.length ; i++) {

                        if ( kinderen[i].className == "rf-edt-r-sel rf-edt-r-act") {

                            kinderen[i].removeAttribute("class");

                        }

                        loopDoorDom( kinderen[i]);

                    }

             

             

            The Java Script is called by:

             

             

            <a4j:commandButton id             ="refreshbutton"

                                                           value          ="#{tekst.refresh}"

                                                           actionListener ="#{landBean.refresh('alles')}"

                                                           execute        ="refreshbutton"

                                                           render         ="form"

                                                           style          ="margin-left: 10px"

                                                           data       ="landenTabel"

                                                           oncomplete="clearSelectedRow(event.data)"

                                                           >

             

                                        </a4j:commandButton>

             

            The data attribute passes the name of the table and then you can use it in the Java Script. In this way I can use the code in bold the "clean" the selected row from a table.

             

            Notice that loopDoorDom is recursively called.