3 Replies Latest reply on May 21, 2009 2:26 PM by Arief ZJ

    Component in datatable restore incorrect state

    Arief Zaki Jumodi Newbie

      Hi,

      We have created a custom JSF component using the CDK which extends from UIInput which we name it Popup (for example). The Popup has an attribute that is similar to UIInput's value where we called it HiddenField.

      In the decode method of the popup's rendererBase we have something like this:

      String submittedValue = requestParams.get(clientId);
      if (submittedValue != null) {
       popup.setSubmittedValue(submittedValue);
      }
      String oldHiddenValue = popup.getHiddenField();
      if (oldHiddenValue == null) {
       oldHiddenValue = "";
      }
      String newHiddenValue = requestParams.get(clientId + UIPopup.HIDDEN_FIELD);
      if (newHiddenValue == null) {
       newHiddenValue = "";
      }
      popup.setHiddenField(newHiddenValue);
      


      By having "popup.setHiddenField()", the component should remember the value during the next RESTORE_VIEW phase and It does remember :)

      Unfortunately, it doesn't remember correctly once we use the popup component in a datatable.

      For example:
      In the datatable we have for 4 rows of data and each row will contain this popup. First 3 rows are readonly while the last one is editable(new row). Filled up the last popup and with some ajax-submit, the value will be kept in the server. (no db save yet).

      Then user wanted to clear out the last value. After clearing it and do an ajax-submit.
      Unfortunately, during the decode of the 1st row's popup, somehow it got the 4th row's popup's hiddenvalue.. thus our expected result goes wrong.

      With some debugging we noticed this:
      1. During saveState, the component's clientId is in this format: "form:table:rowIdx:compId".
      2. During restoreState, the component's clientId is still null and sometimes we could see it returning this format: "form:table:compId" (excluding row index)

      Does anyone know what have we done wrong here. Is this JSF bug or have we created the component incorrectly (especially the hiddenField property).

      Thanks in advance