facelets
  1. facelets
  2. FACELETS-357

When using ui:repeat and inputText with attributes that are 'nullable' (for example date attributes) they cannot be set to null by entering an empty String ("")

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: UNKNOWN
    • Fix Version/s: 1.1.15
    • Component/s: impl
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      357

      Description

      (Affected Facelets Version is 1.1.15.B1)
      When using ui:repeat in conjunction with an input field and a attribute with a
      type that can normally be set to null by a user (for example a date) by entering
      an empty string into the input field (""), it is not possible for the user to do
      so. A small example:

      TestBean.java:

      public class TestBean {
      public List testEntries=new LinkedList();
      public TestBean()

      { testEntries.add(new TestEntry()); }

      public class TestEntry implements Serializable{
      private Date testAttribute;

      public Date getTestAttribute()

      { return testAttribute; }

      public void setTestAttribute(Date testAttribute)

      { System.out.println("set:"+testAttribute); this.testAttribute = testAttribute; }

      }
      public List getEntries()

      { return testEntries; }

      }

      test.xhtml (excerpt):

      <ui:repeat value="#

      {TestBean.entries}

      " var="entry">
      <h:inputText value="#

      {entry.testAttribute}

      ">
      <f:convertDateTime type="date" dateStyle="medium"/>
      </h:inputText>
      </ui:repeat>

      When you now enter a Date (lets say 1/1/2009) it is accepted and set. If you try
      to set the date to null by entering an empty string into the input field, it
      gets set to its initial value (1/1/2009).

      The problem happens in the "populate" method of UIRepeat.SavedState . It uses
      "getValue" to get the current component value after the value was already set to
      null. The "getValue" method itself will then try to get a value from the value
      it is bind to instead, which is, at that state, still filled with the old data
      (1/1/2009) and returns this value. When the "apply" Method is fired afterwards
      the old value is then written again to the component value and the value binding
      won't get updated with the null value. Using "getLocalValue" instead of
      "getValue" seems to solve the problem:

      public void populate(EditableValueHolder evh) {
      this.value = evh.getLocalValue();
      this.valid = evh.isValid();
      this.submittedValue = evh.getSubmittedValue();
      this.localValueSet = evh.isLocalValueSet();
      }

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            marcelurbanek
          • Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: