1 Reply Latest reply on Aug 21, 2011 12:24 PM by Ilya Shaikovsky

    Rich javascript function findComponent

    Tapas Bose Newbie

      I am trying to add a dynamic onclick event using rich:findComponent as:

      {code:xml}

      <font class="topFirstTablehdCategory2" style="font-size: 12px; cursor: pointer;" onclick="#{rich:findComponent('benchmarkEndDate').value = channelPerformanceController.resetDate}">

              RESET

          </font>

      {code}

      But I am getting:

      {code}com.sun.el.parser.ParseException: Encountered "=" at line 1, column 48.{code}

      What I am willing to do, is to set string value to a rich:calender whose id is benchmarkEndDate supplied from the field resetDate of ChannelPerformanceController class.

      I also write a javascript method in the jsp page:

      {code}

          function setResetDate(id, date) {

              #{rich:findComponent('benchmarkEndDate').value} = date;

          }

      {code}

      is not working. It is called as: onclick="setResetDate('benchmarkEndDate', '#{channelPerformanceController.resetDate}')"

       

      It is rendering in browser as:

      {code}

          function setResetDate(id, date) {

                  2011-03-24 00:00:00.0 = date;

          }

      {code}

      This method:

      {code}

          function setResetDate(id, date) {

                  document.getElementById(#{rich:clientId(id)}) = date;

          }

      {code}

      is change into :

      {code}

          function setResetDate(id, date) {

                  document.getElementById() = date;

          }

      {code}

      What I am doing wrong? How can I achieve this?

        • 1. Re: Rich javascript function findComponent
          Ilya Shaikovsky Master

          RF has next kind of functions:

           

          functions which rendering JS code(called client funcs):

           

          • clientId
          • element
          • component

           

          and ones which just evaluates some server side expressions:

          • findComponent - evaluated to server side component instance
          • isUserInRole - evaluated to externalContext.isUserInRole

           

          So seems you using wrong kind of function to perform client side action. You should use rich:component and check proper JS method which changes current value of the calendar.