5 Replies Latest reply on Apr 16, 2010 3:51 AM by ilya_shaikovsky

    DBCS inplaceInput treeNode causes javascript error

    zjda

      Hi, I am using <rich:inplaceInput> inside <rich:treeNode> and it work fine.

       

                  <rich:treeNode type="Number">
                      <h:panelGrid columns="3">
                          <h:outputLabel value="#{propItem.nodeValue.name}:" for="num_property" />
                          <a4j:region>
                          <rich:inplaceInput id="num_property" editEvent="ondblclick"
                              defaultLabel="Double Click to Edit" value="#{propItem.nodeValue.value}" minInputWidth="250px"
                              selectOnEdit="true">
                              <a4j:support event="onviewactivated" oncomplete="rerender();"/>
                          </rich:inplaceInput>
                          </a4j:region>
                          <h:message for="num_property" errorClass="ValidateError" />
                      </h:panelGrid>
                  </rich:treeNode>

      However, if the <h:outputLabel> contains some dbcs (e.g. chinese) string, IE reports a javascript error after activate and deactivate the <rich:inplaceInput>. Afterward, the <rich:inplaceInput> cannot be activated anymore.

       

      I attach a war file with the souce code for you to reproduce the problem.  After deploying the war to tomcat, you can access the page:

       

      http://localhost:8080/rftest/faces/tree.jsp

       

      The first node causes the problem and second one always works fine.

       

      Thanks for help,

      -ZJ

        • 1. Re: DBCS inplaceInput treeNode causes javascript error
          ilya_shaikovsky

          reproduced. now checking how to resolve.

           

          B.t.w. it's not a issue reason but just question to you. Do you really need to call jsFunction oncomplete? Is it intended use of two ajax requests instead of single one? Why you just not re-rendering in support?

          • 2. Re: DBCS inplaceInput treeNode causes javascript error
            ilya_shaikovsky
            • 3. Re: DBCS inplaceInput treeNode causes javascript error
              zjda

              Hi Ilya,

               

              I am using the jsFunction to work around the problem I reported before: http://community.jboss.org/thread/14582?tstart=0.  Nick's suggestion is better and I should use his workaround.

               

              As you pointed out, I need a converter for the tree and I created one for it:

               

              public class DbcsTreeRowKeyConverter extends TreeRowKeyConverter {

                  @Override
                  protected String convertKeyToString(FacesContext context,  UIComponent component, Object value) {
                      long sum = 0;
                      String s = value.toString();
                        for ( int i = 0; i < s.length(); ++i ){
                            sum += (short) s.charAt(i);
                      }
                      return Long.toString(sum);
                  }
              }

               

              After adding rowKeyConverter="test.DbcsTreeRowKeyConverter" to the  tree, there is no javascript error and inplaceInput can be activated.  However, the value of the inplaceInput CANNOT be updated anymore (NodeData.setValue is not called when changing the value in inplaceInput).  I thought my DbcsTreeRowKeyConverter caused the problem.  However, when I set rowKeyConverter="org.richfaces.TreeRowKeyConverter" for the tree and remove the DBCS node (since TreeRowKeyConverter does not handle DBCS), I got same result.  Therefore, I think rowKeyConverter attribute and <a4j:region> do not work with each other.  If I remove the <a4j:region> around the <rich:inplaceInput>, it works fine (but, the whole tree will be decoded).  Is it a bug in RF or do I miss something?

               

              Your help is appreciated!

              -ZJ

              • 4. Re: DBCS inplaceInput treeNode causes javascript error
                zjda

                Hi.

                 

                I am trying to make it simple.  When I add rowKeyConverter="org.richfaces.TreeRowKeyConverter" to the tree, <rich:inplaceInput> will NOT submit its new value to the server when it is modified (set method for propItem.nodeValue.value is not called).  If I remove rowKeyConverter="org.richfaces.TreeRowKeyConverter", the inplaceInput will work fine.   

                 

                <a4j:form id="propertyForm">
                        <rich:tree id="propertytree" value="#{propertyTree.data}" var="propItem" switchType="client"
                            nodeFace="#{propItem.nodeValue.type}" rowKeyConverter="org.richfaces.TreeRowKeyConverter"
                            requestDelay="400" eventsQueue="treeEventQueue" >
                            <rich:treeNode type="Number" ajaxSingle="true">
                                <h:panelGrid columns="3">
                                    <h:outputLabel value="#{propItem.nodeValue.name}:" for="num_property" />
                                    <a4j:region>
                                    <rich:inplaceInput id="num_property" editEvent="ondblclick"
                                        defaultLabel="Double Click to Edit" value="#{propItem.nodeValue.value}" minInputWidth="250px"
                                        selectOnEdit="true">
                                        <a4j:support event="onviewactivated" reRender="propertyPanel"/>
                                    </rich:inplaceInput>
                                    </a4j:region>
                                    <h:message for="num_property" errorClass="ValidateError" />
                                </h:panelGrid>
                            </rich:treeNode>
                        </rich:tree>
                    </a4j:form>

                 

                Is it a RF bug?

                 

                Thanks,

                -ZJ

                • 5. Re: DBCS inplaceInput treeNode causes javascript error
                  ilya_shaikovsky

                  I guess you have just conversion errors. Add rich:messages and check the results of converter methods in debugger.. But removing it - not an option becuase rowKey should not contain special characters and them should be escaped.